aboutsummaryrefslogtreecommitdiffstats
path: root/package
diff options
context:
space:
mode:
authorVasilis Tsiligiannis <b_tsiligiannis@silverton.gr>2011-01-20 17:33:41 +0000
committerVasilis Tsiligiannis <b_tsiligiannis@silverton.gr>2011-01-20 17:33:41 +0000
commit1d7e6597959dec3cf7e5f62453508c92d2924e49 (patch)
tree16373c140bbb33ebea612a8d483c0e78a1284b98 /package
parentb872aec3572d0348cb5543a10b5ee6c21f906846 (diff)
downloadupstream-1d7e6597959dec3cf7e5f62453508c92d2924e49.tar.gz
upstream-1d7e6597959dec3cf7e5f62453508c92d2924e49.tar.bz2
upstream-1d7e6597959dec3cf7e5f62453508c92d2924e49.zip
[package] qos-scripts: Rework qos-stat script
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@25052 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'package')
-rw-r--r--package/qos-scripts/Makefile4
-rwxr-xr-xpackage/qos-scripts/files/usr/bin/qos-stat73
2 files changed, 60 insertions, 17 deletions
diff --git a/package/qos-scripts/Makefile b/package/qos-scripts/Makefile
index 7a374697e5..c999e7e679 100644
--- a/package/qos-scripts/Makefile
+++ b/package/qos-scripts/Makefile
@@ -1,5 +1,5 @@
#
-# Copyright (C) 2006-2010 OpenWrt.org
+# Copyright (C) 2006-2011 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=qos-scripts
PKG_VERSION:=1.2.1
-PKG_RELEASE:=3
+PKG_RELEASE:=4
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
diff --git a/package/qos-scripts/files/usr/bin/qos-stat b/package/qos-scripts/files/usr/bin/qos-stat
index fc940a8218..d7858d7a11 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"