From 58daab21cd043e1dc37024a7f99b396788372918 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 9 Mar 2024 14:19:48 +0100 Subject: Merging upstream version 1.44.3. Signed-off-by: Daniel Baumann --- .../tc.plugin/integrations/tc_qos_classes.md | 5 +- collectors/tc.plugin/tc-qos-helper.sh.in | 99 +++++++++++++++++----- 2 files changed, 82 insertions(+), 22 deletions(-) (limited to 'collectors/tc.plugin') diff --git a/collectors/tc.plugin/integrations/tc_qos_classes.md b/collectors/tc.plugin/integrations/tc_qos_classes.md index 2e013fc0..7a665066 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 | diff --git a/collectors/tc.plugin/tc-qos-helper.sh.in b/collectors/tc.plugin/tc-qos-helper.sh.in index 0fab69ee..3298c39a 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 +# (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--" <