mwan3: cleanup indenting in rpcd interface status
Signed-off-by: Aaron Goodman <aaronjg@stanford.edu>
This commit is contained in:
parent
e405b261d6
commit
321a52862a
1 changed files with 61 additions and 60 deletions
|
@ -79,67 +79,68 @@ get_mwan3_status() {
|
|||
local up="0"
|
||||
local enabled time_p time_n time_u time_d status track_status
|
||||
|
||||
|
||||
if [ "${iface}" = "${iface_select}" ] || [ "${iface_select}" = "" ]; then
|
||||
track_status="$(mwan3_get_mwan3track_status "$1")"
|
||||
[ "$track_status" = "active" ] && running="1"
|
||||
time_p="$(cat "$MWAN3TRACK_STATUS_DIR/${iface}/TIME")"
|
||||
[ -z "${time_p}" ] || {
|
||||
time_n="$(get_uptime)"
|
||||
let age=time_n-time_p
|
||||
}
|
||||
|
||||
time_u="$(cat "$MWAN3TRACK_STATUS_DIR/${iface}/ONLINE")"
|
||||
[ -z "${time_u}" ] || [ "${time_u}" = "0" ] || {
|
||||
time_n="$(get_uptime)"
|
||||
let online=time_n-time_u
|
||||
}
|
||||
|
||||
time_d="$(cat "$MWAN3TRACK_STATUS_DIR/${iface}/OFFLINE")"
|
||||
[ -z "${time_d}" ] || [ "${time_d}" = "0" ] || {
|
||||
time_n="$(get_uptime)"
|
||||
let offline=time_n-time_d
|
||||
}
|
||||
|
||||
local uptime="0"
|
||||
|
||||
config_get enabled "$iface" enabled 0
|
||||
network_get_uptime uptime "$iface"
|
||||
network_is_up "$iface" && up="1"
|
||||
|
||||
if [ -f "$MWAN3TRACK_STATUS_DIR/${iface}/STATUS" ]; then
|
||||
status="$(cat "$MWAN3TRACK_STATUS_DIR/${iface}/STATUS")"
|
||||
else
|
||||
status="unknown"
|
||||
fi
|
||||
|
||||
json_add_object "${iface}"
|
||||
json_add_int age "$age"
|
||||
json_add_int online "${online}"
|
||||
json_add_int offline "${offline}"
|
||||
json_add_int uptime "${uptime}"
|
||||
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")"
|
||||
json_add_string "status" "${status}"
|
||||
json_add_boolean "enabled" "${enabled}"
|
||||
json_add_boolean "running" "${running}"
|
||||
json_add_boolean "up" "${up}"
|
||||
json_add_array "track_ip"
|
||||
for file in $MWAN3TRACK_STATUS_DIR/${iface}/TRACK_*; do
|
||||
[ -z "${file#*/TRACK_OUTPUT}" ] && continue
|
||||
[ -z "${file#*/TRACK_\*}" ] && continue
|
||||
track="${file#*/TRACK_}"
|
||||
json_add_object
|
||||
json_add_string ip "${track}"
|
||||
json_add_string status "$(cat "${file}")"
|
||||
json_add_int latency "$(cat "$MWAN3TRACK_STATUS_DIR/${iface}/LATENCY_${track}")"
|
||||
json_add_int packetloss "$(cat "$MWAN3TRACK_STATUS_DIR/${iface}/LOSS_${track}")"
|
||||
json_close_object
|
||||
done
|
||||
json_close_array
|
||||
json_close_object
|
||||
if [ "${iface}" != "${iface_select}" ] && [ "${iface_select}" != "" ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
track_status="$(mwan3_get_mwan3track_status "$1")"
|
||||
[ "$track_status" = "active" ] && running="1"
|
||||
time_p="$(cat "$MWAN3TRACK_STATUS_DIR/${iface}/TIME")"
|
||||
[ -z "${time_p}" ] || {
|
||||
time_n="$(get_uptime)"
|
||||
let age=time_n-time_p
|
||||
}
|
||||
|
||||
time_u="$(cat "$MWAN3TRACK_STATUS_DIR/${iface}/ONLINE")"
|
||||
[ -z "${time_u}" ] || [ "${time_u}" = "0" ] || {
|
||||
time_n="$(get_uptime)"
|
||||
let online=time_n-time_u
|
||||
}
|
||||
|
||||
time_d="$(cat "$MWAN3TRACK_STATUS_DIR/${iface}/OFFLINE")"
|
||||
[ -z "${time_d}" ] || [ "${time_d}" = "0" ] || {
|
||||
time_n="$(get_uptime)"
|
||||
let offline=time_n-time_d
|
||||
}
|
||||
|
||||
local uptime="0"
|
||||
|
||||
config_get enabled "$iface" enabled 0
|
||||
network_get_uptime uptime "$iface"
|
||||
network_is_up "$iface" && up="1"
|
||||
|
||||
if [ -f "$MWAN3TRACK_STATUS_DIR/${iface}/STATUS" ]; then
|
||||
status="$(cat "$MWAN3TRACK_STATUS_DIR/${iface}/STATUS")"
|
||||
else
|
||||
status="unknown"
|
||||
fi
|
||||
|
||||
json_add_object "${iface}"
|
||||
json_add_int age "$age"
|
||||
json_add_int online "${online}"
|
||||
json_add_int offline "${offline}"
|
||||
json_add_int uptime "${uptime}"
|
||||
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")"
|
||||
json_add_string "status" "${status}"
|
||||
json_add_boolean "enabled" "${enabled}"
|
||||
json_add_boolean "running" "${running}"
|
||||
json_add_boolean "up" "${up}"
|
||||
json_add_array "track_ip"
|
||||
for file in $MWAN3TRACK_STATUS_DIR/${iface}/TRACK_*; do
|
||||
[ -z "${file#*/TRACK_OUTPUT}" ] && continue
|
||||
[ -z "${file#*/TRACK_\*}" ] && continue
|
||||
track="${file#*/TRACK_}"
|
||||
json_add_object
|
||||
json_add_string ip "${track}"
|
||||
json_add_string status "$(cat "${file}")"
|
||||
json_add_int latency "$(cat "$MWAN3TRACK_STATUS_DIR/${iface}/LATENCY_${track}")"
|
||||
json_add_int packetloss "$(cat "$MWAN3TRACK_STATUS_DIR/${iface}/LOSS_${track}")"
|
||||
json_close_object
|
||||
done
|
||||
json_close_array
|
||||
json_close_object
|
||||
}
|
||||
|
||||
main () {
|
||||
|
|
Loading…
Reference in a new issue