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"
45 $tc_cmd -s class show dev $x
47 # check FireQOS names for classes
48 if [ ! -z "$fix_names" -a -f /var/run/fireqos/ifaces/$x ]
50 name="$(cat /var/run/fireqos/ifaces/$x)"
51 echo "SETDEVICENAME $name"
54 . /var/run/fireqos/$name.conf
55 for n in $interface_classes_monitor
57 setclassname $(echo $n | tr '|' ' ')
60 echo "SETDEVICEGROUP $interface_dev"
66 cat /proc/net/dev | grep ":" | cut -d ':' -f 1 | while read dev
68 l=$($tc_cmd class show dev $dev | wc -l)
69 [ $l -ne 0 ] && echo $dev
73 # update devices and class names
74 # once every 2 minutes
75 names_every=$((120 / sleep_time))
77 # exit this script every hour
78 # it will be restarted automatically
79 exit_after=$((3600 / sleep_time))
89 if [ $c -le 1 -o $c -ge $names_every ]
93 devices="$( all_devices )"
101 echo "WORKTIME $LOOPSLEEPMS_LASTWORK"
103 loopsleepms $sleep_time
105 [ $gc -gt $exit_after ] && exit 0