2 LuCI - Lua Configuration Interface
4 Copyright 2011 Jo-Philipp Wich <xm@subsignal.org>
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
10 http://www.apache.org/licenses/LICENSE-2.0
15 module("luci.tools.status", package.seeall)
17 local uci = require "luci.model.uci".cursor()
19 function dhcp_leases()
21 local nfs = require "nixio.fs"
22 local leasefile = "/var/dhcp.leases"
24 uci:foreach("dhcp", "dnsmasq",
26 if s.leasefile and nfs.access(s.leasefile) then
27 leasefile = s.leasefile
32 local fd = io.open(leasefile, "r")
35 local ln = fd:read("*l")
39 local ts, mac, ip, name = ln:match("^(%d+) (%S+) (%S+) (%S+)")
40 if ts and mac and ip and name then
42 expires = os.difftime(tonumber(ts) or 0, os.time()),
45 hostname = (name ~= "*") and name
56 function wifi_networks()
58 local ntm = require "luci.model.network".init()
61 for _, dev in ipairs(ntm:get_wifidevs()) do
65 name = dev:get_i18n(),
70 for _, net in ipairs(dev:get_wifinets()) do
71 rd.networks[#rd.networks+1] = {
72 name = net:shortname(),
73 link = net:adminlink(),
75 mode = net:active_mode(),
76 ssid = net:active_ssid(),
77 bssid = net:active_bssid(),
78 encryption = net:active_encryption(),
79 frequency = net:frequency(),
80 channel = net:channel(),
81 signal = net:signal(),
82 quality = net:signal_percent(),
84 bitrate = net:bitrate(),
85 ifname = net:ifname(),
86 assoclist = net:assoclist()