3 # default time function
6 now_ms="$(date +'%s')000"
9 # default sleep function
10 LOOPSLEEPMS_LASTWORK=0
12 [ "$1" = "tellwork" ] && shift
16 # if found and included, this file overwrites loopsleepms()
17 # with a high resolution timer function for precise looping.
18 . "$NETDATA_PLUGINS_DIR/loopsleepms.sh.inc"
20 # check if we have a valid number for interval
23 [ $((sleep_time)) -lt 1 ] && $NETDATA_UPDATE_EVERY
24 [ $((sleep_time)) -lt 1 ] && sleep_time=1
29 echo >&2 "tc: Cannot find a 'tc' command in this system."
37 echo "SETCLASSNAME $3 $2"
44 $tc_cmd -s class show dev $x
46 # check FireQOS names for classes
47 if [ ! -z "$fix_names" -a -f /var/run/fireqos/ifaces/$x ]
49 name="$(cat /var/run/fireqos/ifaces/$x)"
50 echo "SETDEVICENAME $name"
53 interface_classes_monitor=
54 . /var/run/fireqos/$name.conf
55 for n in $interface_classes_monitor
57 setclassname $(echo $n | tr '|' ' ')
59 echo "SETDEVICEGROUP $interface_dev"
65 cat /proc/net/dev | grep ":" | cut -d ':' -f 1 | while read dev
67 l=$($tc_cmd class show dev $dev | wc -l)
68 [ $l -ne 0 ] && echo $dev
72 # update devices and class names
73 # once every 2 minutes
74 names_every=$((120 / sleep_time))
76 # exit this script every hour
77 # it will be restarted automatically
78 exit_after=$((3600 / sleep_time))
88 if [ $c -le 1 -o $c -ge $names_every ]
92 devices="$( all_devices )"
100 echo "WORKTIME $LOOPSLEEPMS_LASTWORK"
102 loopsleepms $sleep_time
104 [ $gc -gt $exit_after ] && exit 0