From 42963323c43dc9331c77f0f672e911abd3c25aa7 Mon Sep 17 00:00:00 2001 From: runesk Date: Fri, 14 Jan 2011 20:24:16 +0000 Subject: [PATCH] Accepted patch from Jozsef Marton. Plugins might now be added dynamicly using the plugindir_ git-svn-id: svn://svn.code.sf.net/p/muninlite/code/muninlite@24 35caa317-6b62-4e8a-81c0-b04f0c356266 --- munin-node.in | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/munin-node.in b/munin-node.in index 8f1d8bf..86ccd6a 100755 --- a/munin-node.in +++ b/munin-node.in @@ -5,7 +5,7 @@ # # For latest version, see http://muninlite.sf.net/ # -# Copyright (c) 2007 Rune Nordbøe Skillingstad +# Copyright (c) 2007-2011 Rune Nordbøe Skillingstad # # Licensed under GPLv2 (see LICENSE file for full License) # @@ -16,6 +16,10 @@ VERSION="@@VERSION@@" @@CONF@@ +# if plugindir_ is present in $PLUGINS, +# iexecutables (scripts, binaries) matching the following pattern will be scanned and operated as plugins +PLUGINPATTERN=$(dirname $0)"/munin-node-plugin.d/*" + # Remove unwanted plugins from this list PLUGINS="@@PLUGINS@@" # ===== LIB FUNCTIONS ===== @@ -85,6 +89,20 @@ do if netstat -s >/dev/null 2>&1; then RES="$RES netstat" fi + elif [ "$PLUG" = "plugindir_" ]; then + for MYPLUGIN in $(ls -1 $PLUGINPATTERN 2>/dev/null ); + do + if [ -f $MYPLUGIN -a -x $MYPLUGIN ]; then + MYPLUGINNAME=$(basename $MYPLUGIN) + #ensure we don't have name collision + if echo "$RES" | grep "\b$MYPLUGINNAME\b" >/dev/null 2>&1 ; then + MYPLUGINNAME="plugindir_$MYPLUGINNAME" + fi + RES="$RES $MYPLUGINNAME" + eval "fetch_${MYPLUGINNAME}() { $MYPLUGIN ; };" + eval "config_${MYPLUGINNAME}() { $MYPLUGIN config ; };" + fi + done else RES="$RES $PLUG"; fi