1
0
mirror of https://git.openwrt.org/feed/packages.git synced 2024-06-26 01:27:41 +02:00

net/mwan3: expand ubus to show when last mwan3track check was done

To know how old the ubus output is, add an age parameter which indicats
how old the check informations on the interface are.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
This commit is contained in:
Florian Eckert 2017-07-31 13:57:51 +02:00
parent 815e83d461
commit 929bec6402
2 changed files with 10 additions and 1 deletions

View File

@ -34,7 +34,8 @@ get_mwan3_status() {
local iface="${1}"
local iface_select="${2}"
local running="0"
local pid device
local age=0
local pid device time_p time_n
network_get_device device $1
@ -44,7 +45,14 @@ get_mwan3_status() {
running="1"
fi
time_p="$(cat "$MWAN3_STATUS_DIR/${iface}/TIME")"
[ -z "${time_p}" ] || {
time_n="$(date +'%s')"
let age=time_n-time_p
}
json_add_object "${iface}"
json_add_int age "$age"
json_add_string "score" "$(cat "$MWAN3_STATUS_DIR/${iface}/SCORE")"
json_add_string "lost" "$(cat "$MWAN3_STATUS_DIR/${iface}/LOST")"
json_add_string "turn" "$(cat "$MWAN3_STATUS_DIR/${iface}/TURN")"

View File

@ -154,6 +154,7 @@ main() {
echo "${lost}" > /var/run/mwan3track/$1/LOST
echo "${score}" > /var/run/mwan3track/$1/SCORE
echo "${turn}" > /var/run/mwan3track/$1/TURN
echo "$(date +'%s')" > /var/run/mwan3track/$1/TIME
host_up_count=0
sleep "${sleep_time}" &