3 export PATH="${PATH}:/sbin:/usr/sbin:/usr/local/sbin"
5 # default time function
8 now_ms="$(date +'%s')000"
11 # default sleep function
12 LOOPSLEEPMS_LASTWORK=0
14 [ "$1" = "tellwork" ] && shift
18 # if found and included, this file overwrites loopsleepms()
19 # with a high resolution timer function for precise looping.
20 . "$NETDATA_PLUGINS_DIR/loopsleepms.sh.inc"
22 # check if we have a valid number for interval
25 [ $((sleep_time)) -lt 1 ] && $NETDATA_UPDATE_EVERY
26 [ $((sleep_time)) -lt 1 ] && sleep_time=1
31 echo >&2 "tc: Cannot find a 'tc' command in this system."
39 echo "SETCLASSNAME $3 $2"
46 $tc_cmd -s class show dev $x
48 # check FireQOS names for classes
49 if [ ! -z "$fix_names" -a -f /var/run/fireqos/ifaces/$x ]
51 name="$(cat /var/run/fireqos/ifaces/$x)"
52 echo "SETDEVICENAME $name"
55 interface_classes_monitor=
56 . /var/run/fireqos/$name.conf
57 for n in $interface_classes_monitor
59 setclassname $(echo $n | tr '|' ' ')
61 echo "SETDEVICEGROUP $interface_dev"
67 cat /proc/net/dev | grep ":" | cut -d ':' -f 1 | while read dev
69 l=$($tc_cmd class show dev $dev | wc -l)
70 [ $l -ne 0 ] && echo $dev
74 # update devices and class names
75 # once every 2 minutes
76 names_every=$((120 / sleep_time))
78 # exit this script every hour
79 # it will be restarted automatically
80 exit_after=$((3600 / sleep_time))
90 if [ $c -le 1 -o $c -ge $names_every ]
94 devices="$( all_devices )"
102 echo "WORKTIME $LOOPSLEEPMS_LASTWORK"
104 loopsleepms $sleep_time
106 [ $gc -gt $exit_after ] && exit 0