Last active
December 5, 2017 19:54
-
-
Save PotcFdk/6fcea8cb06177eeb96870d85909a6eda to your computer and use it in GitHub Desktop.
FRITZ!Box Fon WLAN 7170 status script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?lua | |
box.header("Cache-Control: no-cache\n") | |
box.header("Content-Type: text/plain; charset=utf-8\n") | |
box.header("Expires: -1\n") | |
box.header("Pragma: no-cache\n\n") | |
dofile ("/usr/www/avm/errors/kids/dkjson.lua") | |
?> | |
<?lua | |
function trim (str) | |
return (str:gsub("^%s+", ""):gsub("%s+$", "")) | |
end | |
function run (cmd) | |
local handle = io.popen(cmd) | |
local result = handle:read("*a") | |
handle:close() | |
return result | |
end | |
print (json.encode ({ | |
success = true, | |
data = { | |
dsl = { | |
down = trim (run ("ctlmgr_ctl r dslstatglobal status/in")), | |
up = trim (run ("ctlmgr_ctl r dslstatglobal status/out")), | |
status = trim (run ("ctlmgr_ctl r dslstatistic status/ifacestat0/connection_status")) | |
}, | |
inetstat = { | |
time = trim (run ("ctlmgr_ctl r inetstat status/TimeStamp")), | |
today = { | |
--calls = ctlmgr_ctl r inetstat status/Today/OutgoingCalls | |
TX = trim (run ("ctlmgr_ctl r inetstat status/Today/BytesSentLow")), | |
RX = trim (run ("ctlmgr_ctl r inetstat status/Today/BytesReceivedLow")) | |
}, | |
yesterday = { | |
TX = trim (run ("ctlmgr_ctl r inetstat status/Yesterday/BytesSentLow")), | |
RX = trim (run ("ctlmgr_ctl r inetstat status/Yesterday/BytesReceivedLow")) | |
}, | |
this_week = { | |
TX = trim (run ("ctlmgr_ctl r inetstat status/ThisWeek/BytesSentLow")), | |
RX = trim (run ("ctlmgr_ctl r inetstat status/ThisWeek/BytesReceivedLow")) | |
}, | |
last_week = { | |
TX = trim (run ("ctlmgr_ctl r inetstat status/LastWeek/BytesSentLow")), | |
RX = trim (run ("ctlmgr_ctl r inetstat status/LastWeek/BytesReceivedLow")) | |
}, | |
this_month = { | |
TX = trim (run ("ctlmgr_ctl r inetstat status/ThisMonth/BytesSentLow")), | |
RX = trim (run ("ctlmgr_ctl r inetstat status/ThisMonth/BytesReceivedLow")) | |
}, | |
last_month = { | |
TX = trim (run ("ctlmgr_ctl r inetstat status/LastMonth/BytesSentLow")), | |
RX = trim (run ("ctlmgr_ctl r inetstat status/LastMonth/BytesReceivedLow")) | |
}, | |
total = { | |
TX = trim (run ("ctlmgr_ctl r inetstat status/Total/BytesSentLow")), | |
RX = trim (run ("ctlmgr_ctl r inetstat status/Total/BytesReceivedLow")) | |
} | |
}, | |
eth = { | |
eth0 = trim (run ("ctlmgr_ctl r eth0 status/carrier")), | |
eth1 = trim (run ("ctlmgr_ctl r eth1 status/carrier")), | |
eth2 = trim (run ("ctlmgr_ctl r eth2 status/carrier")), | |
eth3 = trim (run ("ctlmgr_ctl r eth3 status/carrier")) | |
}, | |
wlan = { | |
enabled = trim (run ("ctlmgr_ctl r wlan settings/ap_enabled")), | |
active_stations = trim (run ("ctlmgr_ctl r wlan settings/active_stations")) | |
}, | |
usb = { | |
name = trim (run ("ctlmgr_ctl r usbdevices status/physmedium0/name")), | |
vendor = trim (run ("ctlmgr_ctl r usbdevices status/physmedium0/vendor")), | |
model = trim (run ("ctlmgr_ctl r usbdevices status/physmedium0/model")), | |
conntype = trim (run ("ctlmgr_ctl r usbdevices status/physmedium0/conntype")), | |
capacity = trim (run ("ctlmgr_ctl r usbdevices status/physmedium0/capacity")), | |
status = trim (run ("ctlmgr_ctl r usbdevices status/physmedium0/status")) | |
} | |
} | |
})) | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment