From: Costa Tsaousis (ktsaou) Date: Tue, 20 Dec 2016 22:37:23 +0000 (+0200) Subject: tc-qos-helper.sh optimization to avoid forks; added support for reading class names... X-Git-Tag: v1.5.0~111^2 X-Git-Url: https://arthur.barton.de/gitweb/?p=netdata.git;a=commitdiff_plain;h=d849dd5f0aa2150fda857a923fcc109096b5ee91 tc-qos-helper.sh optimization to avoid forks; added support for reading class names from /etc/iproute2/tc_cls; fixes #837 --- diff --git a/plugins.d/loopsleepms.sh.inc b/plugins.d/loopsleepms.sh.inc index 4f2e0235..ef3db192 100644 --- a/plugins.d/loopsleepms.sh.inc +++ b/plugins.d/loopsleepms.sh.inc @@ -139,7 +139,7 @@ loopsleepms() { # calculate ms since last run [ ${LOOPSLEEPMS_LASTRUN} -gt 0 ] && \ - LOOPSLEEPMS_LASTWORK=$((now_ms - LOOPSLEEPMS_LASTRUN - LOOPSLEEPMS_LASTSLEEP)) + LOOPSLEEPMS_LASTWORK=$((now_ms - LOOPSLEEPMS_LASTRUN - LOOPSLEEPMS_LASTSLEEP + current_time_ms_accuracy)) # echo "# last loop's work took $LOOPSLEEPMS_LASTWORK ms" # remember this run diff --git a/plugins.d/tc-qos-helper.sh b/plugins.d/tc-qos-helper.sh index 7e1e92cf..94d0a62f 100755 --- a/plugins.d/tc-qos-helper.sh +++ b/plugins.d/tc-qos-helper.sh @@ -5,8 +5,8 @@ # (C) 2016 Costa Tsaousis # GPL v3+ # -# This script is a helper to allow netdata collect tc data -# parsing tc output has been implemented in C, inside netdata +# This script is a helper to allow netdata collect tc data. +# tc output parsing has been implemented in C, inside netdata # This script allows setting names to dimensions. export PATH="${PATH}:/sbin:/usr/sbin:/usr/local/sbin" @@ -90,21 +90,34 @@ if [ -z "${tc}" -o ! -x "${tc}" ] fatal "cannot find command 'tc' in this system." fi -devices= +tc_devices= fix_names= setclassname() { echo "SETCLASSNAME $3 $2" } -show_tc() { - local x="${1}" interface_dev interface_classes interface_classes_monitor +show_tc_cls() { + local x="${1}" - echo "BEGIN ${x}" - ${tc} -s class show dev ${x} + if [ -f /etc/iproute2/tc_cls ] + then + local classid name rest + while read classid name rest + do + [ -z "${classid}" -o -z "${name}" -o "${classid}" = "#" -o "${name}" = "#" -o "${classid:0:1}" = "#" -o "${name:0:1}" = "#" ] && continue + setclassname "" "${name}" "${classid}" + done