]> arthur.barton.de Git - netdata.git/blobdiff - plugins.d/tc-qos-helper.sh
tc now supports hierarchical qdiscs too
[netdata.git] / plugins.d / tc-qos-helper.sh
index 60342e9fe5378f94c087a4d9b988194a39ff44b3..6dd9bfb59b29da4b3e5e70c167547b99d2eed265 100755 (executable)
@@ -63,6 +63,8 @@ fireqos_run_dir="/var/run/fireqos"
 qos_get_class_names_every=120
 qos_exit_every=3600
 
+tc_show="qdisc" # can also be "class"
+
 # check if we have a valid number for interval
 t=${1}
 update_every=$((t))
@@ -75,6 +77,16 @@ if [ -f "${config_dir}/tc-qos-helper.conf" ]
     source "${config_dir}/tc-qos-helper.conf"
 fi
 
+case "${tc_show}" in
+    qdisc|class)
+        ;;
+
+    *)
+        error "tc_show variable can be either 'qdisc' or 'class' but is set to '${tc_show}'. Assuming it is 'qdisc'."
+        tc_show="qdisc"
+        ;;
+esac
+
 # default sleep function
 LOOPSLEEPMS_LASTWORK=0
 loopsleepms() {
@@ -94,10 +106,17 @@ tc_devices=
 fix_names=
 
 setclassname() {
-    echo "SETCLASSNAME $3 $2"
+    if [ "${tc_show}" = "qdisc" ]
+        then
+        echo "SETCLASSNAME $4 $2"
+    else
+        echo "SETCLASSNAME $3 $2"
+    fi
 }
 
 show_tc_cls() {
+    [ "${tc_show}" = "qdisc" ] && return 1
+
     local x="${1}"
 
     if [ -f /etc/iproute2/tc_cls ]
@@ -143,8 +162,7 @@ show_tc() {
     echo "BEGIN ${x}"
 
     # netdata can parse the output of tc
-    ${tc} -s class show dev ${x}
-    ${tc} -s qdisc show dev ${x}
+    ${tc} -s ${tc_show} show dev ${x}
 
     # check FireQOS names for classes
     if [ ! -z "${fix_names}" ]