aboutsummaryrefslogtreecommitdiff
path: root/net/mwan3
diff options
context:
space:
mode:
authorAaron Goodman <aaronjg@stanford.edu>2020-11-10 08:53:34 -0500
committerAaron Goodman <aaronjg@stanford.edu>2020-11-10 09:03:33 -0500
commit321a52862a373bba37b93ba5e37bdf54cd66db6c (patch)
tree9785bf5a17bbba8b615b4b1325d31da04594ce28 /net/mwan3
parente405b261d6c52ceb1706a13ea2fe9a94f475d9ab (diff)
mwan3: cleanup indenting in rpcd interface status
Signed-off-by: Aaron Goodman <aaronjg@stanford.edu>
Diffstat (limited to 'net/mwan3')
-rwxr-xr-xnet/mwan3/files/usr/libexec/rpcd/mwan3119
1 files changed, 60 insertions, 59 deletions
diff --git a/net/mwan3/files/usr/libexec/rpcd/mwan3 b/net/mwan3/files/usr/libexec/rpcd/mwan3
index 4b53d5979..0d8693e64 100755
--- a/net/mwan3/files/usr/libexec/rpcd/mwan3
+++ b/net/mwan3/files/usr/libexec/rpcd/mwan3
@@ -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
+ return
+ fi
- 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
+ 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 () {