From 1b9e7ae64862f451d220fefc75a303e275905181 Mon Sep 17 00:00:00 2001 From: daald Date: Mon, 13 Jan 2025 09:38:13 +0100 Subject: [PATCH] Allow customizing the list of monitored network interfaces (#18) * 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. * Add examples for config with INTERFACE_NAMES_OVERRIDE * Fix "parameter not set" error ./muninlite: 651: INTERFACE_NAMES_OVERRIDE: parameter not set * Make example more portable Co-authored-by: Kenyon Ralph * Remove example code as requested --------- Co-authored-by: Kenyon Ralph --- muninlite.conf | 2 ++ muninlite.in | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/muninlite.conf b/muninlite.conf index 192b84d..3b47427 100644 --- a/muninlite.conf +++ b/muninlite.conf @@ -1,3 +1,5 @@ # 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" diff --git a/muninlite.in b/muninlite.in index 10f5d7a..55f321b 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}"