1
0
mirror of git://projects.qi-hardware.com/openwrt-xburst.git synced 2024-12-27 09:49:52 +02:00
openwrt-xburst/package/qos-scripts/files/usr/bin/qos-stat
acinonyx 67fd33b342 [package] qos-scripts: Rework qos-stat script
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@25052 3c298f89-4303-0410-b956-a3cf2f4a3e73
2011-01-20 17:33:41 +00:00

60 lines
1.4 KiB
Bash
Executable File

#!/bin/sh
# 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"