net/mwan3: add downtime ubus information

Get downtime information for the tracked mwan3 wan interfaces.
The information shows how long this interface is in disconnected state.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
This commit is contained in:
Florian Eckert
2018-10-09 08:32:03 +02:00
parent 1236003733
commit 1ee9fb4aff
2 changed files with 13 additions and 1 deletions
+9 -1
View File
@@ -37,7 +37,8 @@ get_mwan3_status() {
local running="0"
local age=0
local uptime=0
local pid device time_p time_n time_u
local downtime=0
local pid device time_p time_n time_u time_d
network_get_device device $1
@@ -59,9 +60,16 @@ get_mwan3_status() {
let uptime=time_n-time_u
}
time_d="$(cat "$MWAN3TRACK_STATUS_DIR/${iface}/DOWNTIME")"
[ -z "${time_d}" ] || [ "${time_d}" = "0" ] || {
time_n="$(get_uptime)"
let downtime=time_n-time_d
}
json_add_object "${iface}"
json_add_int age "$age"
json_add_int uptime "${uptime}"
json_add_int downtime "${downtime}"
json_add_int "score" "$(cat "$MWAN3TRACK_STATUS_DIR/${iface}/SCORE")"
json_add_int "lost" "$(cat "$MWAN3TRACK_STATUS_DIR/${iface}/LOST")"
json_add_int "turn" "$(cat "$MWAN3TRACK_STATUS_DIR/${iface}/TURN")"