3 export PATH="${PATH}:/sbin:/usr/sbin:/usr/local/sbin"
6 PROGRAM_NAME="$(basename $0)"
7 PROGRAM_NAME="${PROGRAM_NAME/.plugin}"
9 plugins_dir="${NETDATA_PLUGINS_DIR}"
10 [ -z "$plugins_dir" ] && plugins_dir="$( dirname $PROGRAM_FILE )"
12 config_dir=${NETDATA_CONFIG_DIR-/etc/netdata}
13 tc="$(which tc 2>/dev/null)"
14 fireqos_run_dir="/var/run/fireqos"
15 qos_get_class_names_every=120
18 # check if we have a valid number for interval
21 [ $((update_every)) -lt 1 ] && update_every=${NETDATA_UPDATE_EVERY}
22 [ $((update_every)) -lt 1 ] && update_every=1
24 # allow the user to override our defaults
25 if [ -f "${config_dir}/tc-qos-helper.conf" ]
27 source "${config_dir}/tc-qos-helper.conf"
30 # default sleep function
31 LOOPSLEEPMS_LASTWORK=0
36 # if found and included, this file overwrites loopsleepms()
37 # with a high resolution timer function for precise looping.
38 . "${plugins_dir}/loopsleepms.sh.inc"
40 if [ -z "${tc}" -o ! -x "${tc}" ]
42 echo >&2 "${PROGRAM_NAME}: Cannot find command 'tc' in this system."
50 echo "SETCLASSNAME $3 $2"
54 local x="${1}" interface_dev interface_classes interface_classes_monitor
57 ${tc} -s class show dev ${x}
59 # check FireQOS names for classes
60 if [ ! -z "${fix_names}" -a -f "${fireqos_run_dir}/ifaces/${x}" ]
62 name="$(<"${fireqos_run_dir}/ifaces/${x}")"
63 echo "SETDEVICENAME ${name}"
67 interface_classes_monitor=
68 source "${fireqos_run_dir}/${name}.conf"
69 for n in ${interface_classes_monitor}
71 setclassname ${n//|/ }
73 [ ! -z "${interface_dev}" ] && echo "SETDEVICEGROUP ${interface_dev}"
79 cat /proc/net/dev | grep ":" | cut -d ':' -f 1 | while read dev
81 l=$(${tc} class show dev ${dev} | wc -l)
82 [ $l -ne 0 ] && echo ${dev}
86 # update devices and class names
87 # once every 2 minutes
88 names_every=$((qos_get_class_names_every / update_every))
90 # exit this script every hour
91 # it will be restarted automatically
92 exit_after=$((qos_exit_every / update_every))
102 if [ ${c} -le 1 -o ${c} -ge ${names_every} ]
106 devices="$( all_devices )"
114 echo "WORKTIME ${LOOPSLEEPMS_LASTWORK}"
116 loopsleepms ${update_every}
118 [ ${gc} -gt ${exit_after} ] && exit 0