Module: check_mk
Branch: master
Commit: 2e8018483f53f605a0f47af073e849b92260128b
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=2e8018483f53f6…
Author: Sebastian Herbord <sh(a)mathias-kettner.de>
Date: Mon Jan 25 14:05:15 2016 +0100
mrpe sections run via runas can now also be cached, as can mrpe sections in the solaris
agent
see werk #2922
---
agents/check_mk_agent.linux | 27 ++++++++++++++++++++++++++-
agents/check_mk_agent.solaris | 28 +++++++++++++++++++++++++++-
2 files changed, 53 insertions(+), 2 deletions(-)
diff --git a/agents/check_mk_agent.linux b/agents/check_mk_agent.linux
index 4c03094..26492ca 100755
--- a/agents/check_mk_agent.linux
+++ b/agents/check_mk_agent.linux
@@ -778,13 +778,38 @@ then
grep -Ev '^[[:space:]]*($|#)' "$include" | \
while read descr cmdline
do
+ interval=
+ if [[ $cmdline =~ \(([^\)]*)\)[[:space:]](.*) ]]
+ then
+ parameters=${BASH_REMATCH[1]}
+ cmdline=${BASH_REMATCH[2]}
+
+ # split multiple parameter assignments
+ IFS=':' read -a parlist <<< $parameters
+ for par in "${parlist[@]}"
+ do
+ # split each assignment
+ IFS='=' read key value <<< $par
+ if [ "$key" = "interval" ]
+ then
+ interval=$value
+ # no other parameters supported currently
+ fi
+ done
+ fi
+
PLUGIN=${cmdline%% *}
if [ -n "$PREFIX" ] ; then
cmdline="$PREFIX\"$cmdline\""
fi
- OUTPUT=$(eval "$cmdline")
+ if [ -z "$interval" ]
+ then
+ OUTPUT=$(eval "$cmdline")
+ else
+ OUTPUT=$(run_cached $descr $interval "$cmdline")
+ fi
echo -n "(${PLUGIN##*/}) $descr $? $OUTPUT" | tr \\n \\1
echo
done
diff --git a/agents/check_mk_agent.solaris b/agents/check_mk_agent.solaris
index 56d9c56..ca0b1d2 100755
--- a/agents/check_mk_agent.solaris
+++ b/agents/check_mk_agent.solaris
@@ -312,7 +312,33 @@ then
grep -v '^ *#' "$MK_CONFDIR/mrpe.cfg" | grep -v '^ *$' | \
while read descr cmdline
do
- OUTPUT=$($cmdline)
+ interval=
+ if [[ $cmdline =~ \(([^\)]*)\)[[:space:]](.*) ]]
+ then
+ parameters=${BASH_REMATCH[1]}
+ cmdline=${BASH_REMATCH[2]}
+
+ # split multiple parameter assignments
+ IFS=':' read -a parlist <<< $parameters
+ for par in "${parlist[@]}"
+ do
+ # split each assignment
+ IFS='=' read key value <<< $par
+ if [ "$key" = "interval" ]
+ then
+ interval=$value
+ # no other parameters supported currently
+ fi
+ done
+ fi
+
+ if [ -z "$interval" ]
+ then
+ OUTPUT=$($cmdline)
+ else
+ OUTPUT=$(run_cached $descr $interval "$cmdline")
+ fi
+
echo "$descr $? $OUTPUT"
done
fi