Changeset 25052


Ignore:
Timestamp:
2011-01-20T18:33:41+01:00 (6 years ago)
Author:
acinonyx
Message:

[package] qos-scripts: Rework qos-stat script

Location:
trunk/package/qos-scripts
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/package/qos-scripts/Makefile

    r23238 r25052  
    11#  
    2 # Copyright (C) 2006-2010 OpenWrt.org 
     2# Copyright (C) 2006-2011 OpenWrt.org 
    33# 
    44# This is free software, licensed under the GNU General Public License v2. 
     
    1010PKG_NAME:=qos-scripts 
    1111PKG_VERSION:=1.2.1 
    12 PKG_RELEASE:=3 
     12PKG_RELEASE:=4 
    1313 
    1414PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME) 
  • trunk/package/qos-scripts/files/usr/bin/qos-stat

    r6501 r25052  
    11#!/bin/sh 
    2 echo '#################' 
    3 echo '# EGRESS STATUS #' 
    4 echo '#################' 
    5 echo 
    6 for iface in $(tc qdisc show | grep hfsc | awk '{print $5}' | grep -v imq); do 
    7         tc -s class show dev "$iface" 
    8 done 
     2# Copyright (C) 2011 OpenWrt.org 
    93 
    10 echo '##################' 
    11 echo '# INGRESS STATUS #' 
    12 echo '##################' 
    13 echo 
    14 for iface in $(tc qdisc show | grep hfsc | awk '{print $5}' | grep imq); do 
    15         tc -s class show dev "$iface" 
    16 done 
     4. /etc/functions.sh 
     5 
     6include /lib/network 
     7 
     8get_ifname() { 
     9        local interface="$1" 
     10        local cfgt 
     11 
     12        scan_interfaces 
     13        config_get cfgt "$interface" TYPE 
     14        [ "$cfgt" == "interface" ] && config_get "$interface" ifname 
     15} 
     16 
     17config_cb() { 
     18        config_get TYPE "$CONFIG_SECTION" TYPE 
     19        [ "interface" == "$TYPE" ] && { 
     20                config_get device "$CONFIG_SECTION" ifname 
     21                [ -z "$device" ] && device="$(get_ifname ${CONFIG_SECTION})" 
     22                config_set "$CONFIG_SECTION" device "$device" 
     23        } 
     24} 
     25 
     26config_load qos 
     27 
     28print_comments() { 
     29        echo '' 
     30        echo '# Interface: '"$1" 
     31        echo '# Direction: '"$2" 
     32        echo '# Stats:     '"$3" 
     33        echo '' 
     34}        
     35 
     36interface_stats() { 
     37        local interface="$1" 
     38        local device 
     39 
     40        config_get device "$interface" device 
     41        config_get_bool enabled "$interface" enabled 1 
     42        [ -z "$device" -o 1 -ne "$enabled" ] && { 
     43                return 1 
     44        } 
     45        config_get_bool halfduplex "$interface" halfduplex 
     46 
     47        [ 1 -ne "$halfduplex" ] && { 
     48                unset halfduplex 
     49                print_comments "$interface" "Egress" "Start" 
     50                tc -s class show dev "$device" 
     51                print_comments "$interface" "Egress" "End" 
     52        } 
     53 
     54        print_comments "$interface" "Ingress${halfduplex:+/Egress}" "Start" 
     55        tc -s class show dev "$(iptables -v -L PREROUTING -t mangle | awk '/IMQ: todev .*$/ && $6 ~ /'$device'/ {print "imq"$12}')" 
     56        print_comments "$interface" "Ingress${halfduplex:+/Egress}" "End" 
     57} 
     58 
     59[ -z "$1" ] && config_foreach interface_stats interface || interface_stats "$1" 
Note: See TracChangeset for help on using the changeset viewer.