summaryrefslogtreecommitdiff
path: root/package/qos-scripts/files
diff options
context:
space:
mode:
authorVasilis Tsiligiannis <acinonyx@openwrt.gr>2011-01-20 17:33:41 +0000
committerVasilis Tsiligiannis <acinonyx@openwrt.gr>2011-01-20 17:33:41 +0000
commita98c957eb5976d01dde80b0f8286fd7f7359da26 (patch)
tree81c2d94e7cde6b27fb319be248bd0a8271577137 /package/qos-scripts/files
parent876dd50e11fff287af351f77e3b43003e240d385 (diff)
downloadmtk-20170518-a98c957eb5976d01dde80b0f8286fd7f7359da26.zip
mtk-20170518-a98c957eb5976d01dde80b0f8286fd7f7359da26.tar.gz
mtk-20170518-a98c957eb5976d01dde80b0f8286fd7f7359da26.tar.bz2
qos-scripts: Rework qos-stat script
SVN-Revision: 25052
Diffstat (limited to 'package/qos-scripts/files')
-rwxr-xr-xpackage/qos-scripts/files/usr/bin/qos-stat73
1 files changed, 58 insertions, 15 deletions
diff --git a/package/qos-scripts/files/usr/bin/qos-stat b/package/qos-scripts/files/usr/bin/qos-stat
index fc940a8..d7858d7 100755
--- a/package/qos-scripts/files/usr/bin/qos-stat
+++ b/package/qos-scripts/files/usr/bin/qos-stat
@@ -1,16 +1,59 @@
#!/bin/sh
-echo '#################'
-echo '# EGRESS STATUS #'
-echo '#################'
-echo
-for iface in $(tc qdisc show | grep hfsc | awk '{print $5}' | grep -v imq); do
- tc -s class show dev "$iface"
-done
-
-echo '##################'
-echo '# INGRESS STATUS #'
-echo '##################'
-echo
-for iface in $(tc qdisc show | grep hfsc | awk '{print $5}' | grep imq); do
- tc -s class show dev "$iface"
-done
+# Copyright (C) 2011 OpenWrt.org
+
+. /etc/functions.sh
+
+include /lib/network
+
+get_ifname() {
+ local interface="$1"
+ local cfgt
+
+ scan_interfaces
+ config_get cfgt "$interface" TYPE
+ [ "$cfgt" == "interface" ] && config_get "$interface" ifname
+}
+
+config_cb() {
+ config_get TYPE "$CONFIG_SECTION" TYPE
+ [ "interface" == "$TYPE" ] && {
+ config_get device "$CONFIG_SECTION" ifname
+ [ -z "$device" ] && device="$(get_ifname ${CONFIG_SECTION})"
+ config_set "$CONFIG_SECTION" device "$device"
+ }
+}
+
+config_load qos
+
+print_comments() {
+ echo ''
+ echo '# Interface: '"$1"
+ echo '# Direction: '"$2"
+ echo '# Stats: '"$3"
+ echo ''
+}
+
+interface_stats() {
+ local interface="$1"
+ local device
+
+ config_get device "$interface" device
+ config_get_bool enabled "$interface" enabled 1
+ [ -z "$device" -o 1 -ne "$enabled" ] && {
+ return 1
+ }
+ config_get_bool halfduplex "$interface" halfduplex
+
+ [ 1 -ne "$halfduplex" ] && {
+ unset halfduplex
+ print_comments "$interface" "Egress" "Start"
+ tc -s class show dev "$device"
+ print_comments "$interface" "Egress" "End"
+ }
+
+ print_comments "$interface" "Ingress${halfduplex:+/Egress}" "Start"
+ tc -s class show dev "$(iptables -v -L PREROUTING -t mangle | awk '/IMQ: todev .*$/ && $6 ~ /'$device'/ {print "imq"$12}')"
+ print_comments "$interface" "Ingress${halfduplex:+/Egress}" "End"
+}
+
+[ -z "$1" ] && config_foreach interface_stats interface || interface_stats "$1"