diff options
author | Felix Fietkau <nbd@nbd.name> | 2021-11-19 23:50:50 +0100 |
---|---|---|
committer | Felix Fietkau <nbd@nbd.name> | 2021-11-19 23:51:20 +0100 |
commit | b764cb9e5b1040b6dc13773f8cc153ce6cd7c44d (patch) | |
tree | f54e7c60db691dfbe1a379dc8514c929812a38a0 /package/network/config/qosify/files | |
parent | 991966f1f55d72f0350acf4b0151059a354783ec (diff) | |
download | upstream-b764cb9e5b1040b6dc13773f8cc153ce6cd7c44d.tar.gz upstream-b764cb9e5b1040b6dc13773f8cc153ce6cd7c44d.tar.bz2 upstream-b764cb9e5b1040b6dc13773f8cc153ce6cd7c44d.zip |
qosify: add qosify-status script
This will show detailed status for all devices/interfaces
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Diffstat (limited to 'package/network/config/qosify/files')
-rw-r--r-- | package/network/config/qosify/files/qosify-status | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/package/network/config/qosify/files/qosify-status b/package/network/config/qosify/files/qosify-status new file mode 100644 index 0000000000..dc58232268 --- /dev/null +++ b/package/network/config/qosify/files/qosify-status @@ -0,0 +1,70 @@ +#!/bin/sh +. /usr/share/libubox/jshn.sh + +dev_status() { + tc -s qdisc sh dev "$1" root + echo +} + +common_status() { + json_get_vars ifname ingress egress + + [ -n "$ifname" ] || return + + [ "$egress" -gt 0 ] && { + echo "egress status:" + dev_status "$ifname" + } + [ "$ingress" -gt 0 ] && { + echo "ingress status:" + dev_status "$(printf %.16s "ifb-$ifname")" + } +} + +is_active() { + json_get_vars active + + [ "${active:-0}" -gt 0 ] +} + +device_status() { + local name="$2" + + json_select "$name" + + if is_active; then + status="active" + else + status="not found" + fi + + echo "===== device $name: $status =====" + + is_active && common_status + + json_select .. +} + +interface_status() { + local name="$2" + + json_select "$name" + + if is_active; then + status="active" + elif ubus -S -t 0 wait_for "network.interface.$name"; then + status="down" + else + status="not found" + fi + + echo "===== interface $name: $status =====" + + is_active && common_status + + json_select .. +} + +json_load "$(ubus call qosify status)" +json_for_each_item device_status devices +json_for_each_item interface_status interfaces |