summaryrefslogtreecommitdiffstats
path: root/collectors/tc.plugin
diff options
context:
space:
mode:
Diffstat (limited to 'collectors/tc.plugin')
-rw-r--r--collectors/tc.plugin/integrations/tc_qos_classes.md5
-rwxr-xr-xcollectors/tc.plugin/tc-qos-helper.sh.in99
2 files changed, 82 insertions, 22 deletions
diff --git a/collectors/tc.plugin/integrations/tc_qos_classes.md b/collectors/tc.plugin/integrations/tc_qos_classes.md
index 2e013fc00..7a6650660 100644
--- a/collectors/tc.plugin/integrations/tc_qos_classes.md
+++ b/collectors/tc.plugin/integrations/tc_qos_classes.md
@@ -4,6 +4,7 @@ meta_yaml: "https://github.com/netdata/netdata/edit/master/collectors/tc.plugin/
sidebar_label: "tc QoS classes"
learn_status: "Published"
learn_rel_path: "Data Collection/Linux Systems/Network"
+most_popular: False
message: "DO NOT EDIT THIS FILE DIRECTLY, IT IS GENERATED BY THE COLLECTOR'S metadata.yaml FILE"
endmeta-->
@@ -130,8 +131,8 @@ sudo ./edit-config netdata.conf
| Name | Description | Default | Required |
|:----|:-----------|:-------|:--------:|
-| script to run to get tc values | Path to script `tc-qos-helper.sh` | usr/libexec/netdata/plugins.d/tc-qos-helper.s | False |
-| enable show all classes and qdiscs for all interfaces | yes/no flag to control what data is presented. | yes | False |
+| script to run to get tc values | Path to script `tc-qos-helper.sh` | usr/libexec/netdata/plugins.d/tc-qos-helper.s | no |
+| enable show all classes and qdiscs for all interfaces | yes/no flag to control what data is presented. | yes | no |
</details>
diff --git a/collectors/tc.plugin/tc-qos-helper.sh.in b/collectors/tc.plugin/tc-qos-helper.sh.in
index 0fab69eef..3298c39a3 100755
--- a/collectors/tc.plugin/tc-qos-helper.sh.in
+++ b/collectors/tc.plugin/tc-qos-helper.sh.in
@@ -2,54 +2,113 @@
# netdata
# real-time performance and health monitoring, done right!
-# (C) 2017 Costa Tsaousis <costa@tsaousis.gr>
+# (C) 2023 Netdata Inc.
# SPDX-License-Identifier: GPL-3.0-or-later
#
# 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"
+export PATH="${PATH}:/sbin:/usr/sbin:/usr/local/sbin:@sbindir_POST@"
export LC_ALL=C
+cmd_line="'${0}' $(printf "'%s' " "${@}")"
+
# -----------------------------------------------------------------------------
-# logging functions
+# logging
-PROGRAM_NAME="$(basename "$0")"
+PROGRAM_NAME="$(basename "${0}")"
PROGRAM_NAME="${PROGRAM_NAME/.plugin/}"
-logdate() {
- date "+%Y-%m-%d %H:%M:%S"
+# these should be the same with syslog() priorities
+NDLP_EMERG=0 # system is unusable
+NDLP_ALERT=1 # action must be taken immediately
+NDLP_CRIT=2 # critical conditions
+NDLP_ERR=3 # error conditions
+NDLP_WARN=4 # warning conditions
+NDLP_NOTICE=5 # normal but significant condition
+NDLP_INFO=6 # informational
+NDLP_DEBUG=7 # debug-level messages
+
+# the max (numerically) log level we will log
+LOG_LEVEL=$NDLP_INFO
+
+set_log_min_priority() {
+ case "${NETDATA_LOG_LEVEL,,}" in
+ "emerg" | "emergency")
+ LOG_LEVEL=$NDLP_EMERG
+ ;;
+
+ "alert")
+ LOG_LEVEL=$NDLP_ALERT
+ ;;
+
+ "crit" | "critical")
+ LOG_LEVEL=$NDLP_CRIT
+ ;;
+
+ "err" | "error")
+ LOG_LEVEL=$NDLP_ERR
+ ;;
+
+ "warn" | "warning")
+ LOG_LEVEL=$NDLP_WARN
+ ;;
+
+ "notice")
+ LOG_LEVEL=$NDLP_NOTICE
+ ;;
+
+ "info")
+ LOG_LEVEL=$NDLP_INFO
+ ;;
+
+ "debug")
+ LOG_LEVEL=$NDLP_DEBUG
+ ;;
+ esac
}
-log() {
- local status="${1}"
- shift
+set_log_min_priority
- echo >&2 "$(logdate): ${PROGRAM_NAME}: ${status}: ${*}"
+log() {
+ local level="${1}"
+ shift 1
+
+ [[ -n "$level" && -n "$LOG_LEVEL" && "$level" -gt "$LOG_LEVEL" ]] && return
+
+ systemd-cat-native --log-as-netdata --newline="--NEWLINE--" <<EOFLOG
+INVOCATION_ID=${NETDATA_INVOCATION_ID}
+SYSLOG_IDENTIFIER=${PROGRAM_NAME}
+PRIORITY=${level}
+THREAD_TAG=tc-qos-helper
+ND_LOG_SOURCE=collector
+ND_REQUEST=${cmd_line}
+MESSAGE=${*//\\n/--NEWLINE--}
+
+EOFLOG
+ # AN EMPTY LINE IS NEEDED ABOVE
+}
+info() {
+ log "$NDLP_INFO" "${@}"
}
warning() {
- log WARNING "${@}"
+ log "$NDLP_WARN" "${@}"
}
error() {
- log ERROR "${@}"
-}
-
-info() {
- log INFO "${@}"
+ log "$NDLP_ERR" "${@}"
}
fatal() {
- log FATAL "${@}"
- exit 1
+ log "$NDLP_ALERT" "${@}"
+ exit 1
}
-debug=0
debug() {
- [ $debug -eq 1 ] && log DEBUG "${@}"
+ log "$NDLP_DEBUG" "${@}"
}
# -----------------------------------------------------------------------------