summaryrefslogtreecommitdiffstats
path: root/plugins.d
diff options
context:
space:
mode:
authorCosta Tsaousis (ktsaou) <costa@tsaousis.gr>2017-01-31 01:47:39 +0200
committerCosta Tsaousis (ktsaou) <costa@tsaousis.gr>2017-01-31 01:47:39 +0200
commitc4c7be1b1ea78a5f74cc2247af2111d2b6ab8c1d (patch)
tree950fac474da599d527c4be473edc4c64d99f4c38 /plugins.d
parent91c1bc20b8f7b3e10745b9daf3b2ca8eb43ab3f5 (diff)
find fireqos run dir automatically; fixes #1684
Diffstat (limited to 'plugins.d')
-rwxr-xr-xplugins.d/tc-qos-helper.sh76
1 files changed, 73 insertions, 3 deletions
diff --git a/plugins.d/tc-qos-helper.sh b/plugins.d/tc-qos-helper.sh
index 6dd9bfb59b..074fece9a5 100755
--- a/plugins.d/tc-qos-helper.sh
+++ b/plugins.d/tc-qos-helper.sh
@@ -12,12 +12,58 @@
export PATH="${PATH}:/sbin:/usr/sbin:/usr/local/sbin"
export LC_ALL=C
+
+# -----------------------------------------------------------------------------
+# find /var/run/fireqos
+
+# the default
+fireqos_run_dir="/var/run/fireqos"
+
+function realdir {
+ local r="$1"
+ local t=$(readlink "$r")
+
+ while [ "$t" ]
+ do
+ r=$(cd $(dirname "$r") && cd $(dirname "$t") && pwd -P)/$(basename "$t")
+ t=$(readlink "$r")
+ done
+
+ dirname "$r"
+}
+
+if [ ! -d "${fireqos_run_dir}" ]
+ then
+
+ # the fireqos executable - we will use it to find its config
+ fireqos="$(which fireqos 2>/dev/null || command -v fireqos 2>/dev/null)"
+
+ if [ ! -z "${fireqos}" ]
+ then
+
+ fireqos_exec_dir="$(realdir ${fireqos})"
+
+ if [ ! -z "${fireqos_exec_dir}" -a "${fireqos_exec_dir}" != "." -a -f "${fireqos_exec_dir}/install.config" ]
+ then
+
+ LOCALSTATEDIR=
+ source "${fireqos_exec_dir}/install.config"
+
+ if [ -d "${LOCALSTATEDIR}/run/fireqos" ]
+ then
+ fireqos_run_dir="${LOCALSTATEDIR}/run/fireqos"
+ fi
+ fi
+ fi
+fi
+
+# -----------------------------------------------------------------------------
+# logging functions
+
PROGRAM_FILE="$0"
PROGRAM_NAME="$(basename $0)"
PROGRAM_NAME="${PROGRAM_NAME/.plugin}"
-# -----------------------------------------------------------------------------
-
logdate() {
date "+%Y-%m-%d %H:%M:%S"
}
@@ -52,6 +98,7 @@ debug() {
[ $debug -eq 1 ] && log DEBUG "${@}"
}
+
# -----------------------------------------------------------------------------
plugins_dir="${NETDATA_PLUGINS_DIR}"
@@ -59,19 +106,33 @@ plugins_dir="${NETDATA_PLUGINS_DIR}"
config_dir=${NETDATA_CONFIG_DIR-/etc/netdata}
tc="$(which tc 2>/dev/null || command -v tc 2>/dev/null)"
-fireqos_run_dir="/var/run/fireqos"
+
+
+# -----------------------------------------------------------------------------
+# user configuration
+
+# time in seconds to refresh QoS class/qdisc names
qos_get_class_names_every=120
+
+# time in seconds to exit - netdata will restart the script
qos_exit_every=3600
+# what to use? classes or qdiscs?
tc_show="qdisc" # can also be "class"
+
+# -----------------------------------------------------------------------------
# check if we have a valid number for interval
+
t=${1}
update_every=$((t))
[ $((update_every)) -lt 1 ] && update_every=${NETDATA_UPDATE_EVERY}
[ $((update_every)) -lt 1 ] && update_every=1
+
+# -----------------------------------------------------------------------------
# allow the user to override our defaults
+
if [ -f "${config_dir}/tc-qos-helper.conf" ]
then
source "${config_dir}/tc-qos-helper.conf"
@@ -87,7 +148,10 @@ case "${tc_show}" in
;;
esac
+
+# -----------------------------------------------------------------------------
# default sleep function
+
LOOPSLEEPMS_LASTWORK=0
loopsleepms() {
sleep $1
@@ -97,6 +161,10 @@ loopsleepms() {
# with a high resolution timer function for precise looping.
. "${plugins_dir}/loopsleepms.sh.inc"
+
+# -----------------------------------------------------------------------------
+# final checks we can run
+
if [ -z "${tc}" -o ! -x "${tc}" ]
then
fatal "cannot find command 'tc' in this system."
@@ -105,6 +173,8 @@ fi
tc_devices=
fix_names=
+# -----------------------------------------------------------------------------
+
setclassname() {
if [ "${tc_show}" = "qdisc" ]
then