gettext-full: link libiconv when building host pkg
[openwrt/openwrt.git] / package / network / config / qosify / files / qosify-status
1 #!/bin/sh
2 . /usr/share/libubox/jshn.sh
3
4 dev_status() {
5 tc -s qdisc sh dev "$1" root
6 echo
7 }
8
9 common_status() {
10 json_get_vars ifname ingress egress
11
12 [ -n "$ifname" ] || return
13
14 [ "$egress" -gt 0 ] && {
15 echo "egress status:"
16 dev_status "$ifname"
17 }
18 [ "$ingress" -gt 0 ] && {
19 echo "ingress status:"
20 dev_status "$(printf %.16s "ifb-$ifname")"
21 }
22 }
23
24 is_active() {
25 json_get_vars active
26
27 [ "${active:-0}" -gt 0 ]
28 }
29
30 device_status() {
31 local name="$2"
32
33 json_select "$name"
34
35 if is_active; then
36 status="active"
37 else
38 status="not found"
39 fi
40
41 echo "===== device $name: $status ====="
42
43 is_active && common_status
44
45 json_select ..
46 }
47
48 interface_status() {
49 local name="$2"
50
51 json_select "$name"
52
53 if is_active; then
54 status="active"
55 elif ubus -S -t 0 wait_for "network.interface.$name"; then
56 status="down"
57 else
58 status="not found"
59 fi
60
61 echo "===== interface $name: $status ====="
62
63 is_active && common_status
64
65 json_select ..
66 }
67
68 json_load "$(ubus call qosify status)"
69 json_for_each_item device_status devices
70 json_for_each_item interface_status interfaces