From c14b6ccaecba0a85fee0261774d31187a6c66f71 Mon Sep 17 00:00:00 2001 From: Daniel Alder Date: Wed, 13 Dec 2023 15:16:20 +0100 Subject: [PATCH 1/5] Allow customizing the list of monitored network interfaces This is a simple way to customize the selection of network interfaces. If INTERFACE_NAMES_OVERRIDE is set in muninlite.conf, that list is used instead of auto-detection. As muninlite.conf itself is also a script, it is even possible to write a custom command. This feature is helpful in environments with virtual machines or containers, like docker or lxc where there are lots of br-*, veth*, lxcbr* etc interfaces where monitoring doesn't make much sense. I didn't find a way to reliably filter physical interfaces. --- muninlite.in | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/muninlite.in b/muninlite.in index 6b6e376..1bd1b26 100755 --- a/muninlite.in +++ b/muninlite.in @@ -78,7 +78,11 @@ RES="" for PLUG in $PLUGINS; do case "$PLUG" in if_|if_err_) - interface_names=$(sed 's/^ *//; s/:.*$//; / /d; /^lo$/d' /proc/net/dev) + if [ -z "$INTERFACE_NAMES_OVERRIDE" ]; then + interface_names=$(sed 's/^ *//; s/:.*$//; / /d; /^lo$/d' /proc/net/dev) + else + interface_names="$INTERFACE_NAMES_OVERRIDE" + fi for INTER in $interface_names; do INTERRES=$(echo "$INTER" | sed -e 's/\./VLAN/' -e 's/\-/_/g') RES="$RES ${PLUG}${INTERRES}" From 71cc9a81106dc2199e5686a54fcff7c0aff6ef5e Mon Sep 17 00:00:00 2001 From: Daniel Alder Date: Wed, 13 Dec 2023 17:35:57 +0100 Subject: [PATCH 2/5] Add examples for config with INTERFACE_NAMES_OVERRIDE --- muninlite.conf | 3 +++ 1 file changed, 3 insertions(+) diff --git a/muninlite.conf b/muninlite.conf index 192b84d..667f16e 100644 --- a/muninlite.conf +++ b/muninlite.conf @@ -1,3 +1,6 @@ # the following variables are added to the top of the assembled muninlite script NTP_PEER="pool.ntp.org" DF_IGNORE_FILESYSTEM_REGEX="(none|unknown|rootfs|iso9660|squashfs|udf|romfs|ramfs|debugfs|cgroup_root|devtmpfs)" + +#INTERFACE_NAMES_OVERRIDE="eth0" +#INTERFACE_NAMES_OVERRIDE="$(sed 's/^ *//; s/:.*$//; / /d' /proc/net/dev | grep -P '^(eth|wlan|en)')" From 903869d10cd58891c77e9a633ab1fc5eb2710abb Mon Sep 17 00:00:00 2001 From: Daniel Alder Date: Wed, 13 Dec 2023 17:43:24 +0100 Subject: [PATCH 3/5] Fix "parameter not set" error ./muninlite: 651: INTERFACE_NAMES_OVERRIDE: parameter not set --- muninlite.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/muninlite.in b/muninlite.in index 1bd1b26..eb9ec39 100755 --- a/muninlite.in +++ b/muninlite.in @@ -78,7 +78,7 @@ RES="" for PLUG in $PLUGINS; do case "$PLUG" in if_|if_err_) - if [ -z "$INTERFACE_NAMES_OVERRIDE" ]; then + if [ -z "${INTERFACE_NAMES_OVERRIDE:-}" ]; then interface_names=$(sed 's/^ *//; s/:.*$//; / /d; /^lo$/d' /proc/net/dev) else interface_names="$INTERFACE_NAMES_OVERRIDE" From e0f0687247958a19911d0f874fd8bff3b50fbede Mon Sep 17 00:00:00 2001 From: daald Date: Thu, 14 Dec 2023 02:29:15 +0100 Subject: [PATCH 4/5] Make example more portable Co-authored-by: Kenyon Ralph --- muninlite.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/muninlite.conf b/muninlite.conf index 667f16e..89c36df 100644 --- a/muninlite.conf +++ b/muninlite.conf @@ -3,4 +3,4 @@ NTP_PEER="pool.ntp.org" DF_IGNORE_FILESYSTEM_REGEX="(none|unknown|rootfs|iso9660|squashfs|udf|romfs|ramfs|debugfs|cgroup_root|devtmpfs)" #INTERFACE_NAMES_OVERRIDE="eth0" -#INTERFACE_NAMES_OVERRIDE="$(sed 's/^ *//; s/:.*$//; / /d' /proc/net/dev | grep -P '^(eth|wlan|en)')" +#INTERFACE_NAMES_OVERRIDE="$(sed 's/^ *//; s/:.*$//; / /d' /proc/net/dev | grep -E '^(eth|wlan|en)')" From 6f27355dc64ddc1ad9588f1402a21ad112bfbc01 Mon Sep 17 00:00:00 2001 From: Daniel Alder Date: Fri, 15 Dec 2023 22:42:18 +0100 Subject: [PATCH 5/5] Remove example code as requested --- muninlite.conf | 1 - 1 file changed, 1 deletion(-) diff --git a/muninlite.conf b/muninlite.conf index 89c36df..3b47427 100644 --- a/muninlite.conf +++ b/muninlite.conf @@ -3,4 +3,3 @@ NTP_PEER="pool.ntp.org" DF_IGNORE_FILESYSTEM_REGEX="(none|unknown|rootfs|iso9660|squashfs|udf|romfs|ramfs|debugfs|cgroup_root|devtmpfs)" #INTERFACE_NAMES_OVERRIDE="eth0" -#INTERFACE_NAMES_OVERRIDE="$(sed 's/^ *//; s/:.*$//; / /d' /proc/net/dev | grep -E '^(eth|wlan|en)')"