Module: check_mk
Branch: master
Commit: 709eac569e50c521e912aeb597b41294431a8d8e
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=709eac569e50c5…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Fri Jan 24 14:39:36 2014 +0100
New local check mrpe_include
---
.werks/265 | 37 +++++++++++++++++++++++++++++++++++++
ChangeLog | 1 +
agents/plugins/mrpe_include | 26 ++++++++++++++++++++++++++
3 files changed, 64 insertions(+)
diff --git a/.werks/265 b/.werks/265
new file mode 100644
index 0000000..70fbe59
--- /dev/null
+++ b/.werks/265
@@ -0,0 +1,37 @@
+Title: mpre_include: new local check, allows to include further mrpe configurations
+Level: 2
+Component: checks
+Version: 1.2.5i1
+Date: 1390568187
+Class: feature
+
+H1:<b class=new>1.2.5</b> Additional MRPE local check with new features
+This version brings the new local check <tt>mrpe_include</tt> where you can
+configure additional include files for mrpe and under which user context
+the commands of these files are run. It allows non-root users to add additional
+mrpe commands without modifying the <tt>mrpe.cfg</tt> file.
+You can assign include files to users and define in which user context the commands
+should be executed.
+
+This check is configured with the configuration
+file <tt>mrpe_include.cfg</tt>. In a default installation this file is
located
+within the Check_MK config directory under
<tt>/etc/check_mk/mrpe_include.cfg</tt>.
+
+The <tt>mrpe_include.cfg</tt> does not contain the new mrpe commands,
+though a user name followed by a include path.
+Here is an example:
+
+F+:/etc/check_mk/mrpe_include.cfg
+# Execute as user ab
+ab /etc/check_mk/mrpe_ab_commands.cfg
+# Execute as user lm
+lm /etc/other/mrpe_lm.cfg
+# Execute with no user context change
+- /etc/mrpe_default.cfg
+F-:
+
+Each line consists of two parameters, the user followed by the include file.
+Each command within the include file is executed as this user.
+If you do not want to change the user context (default is root), you can set the user to
<tt>-</tt>.
+The included files have the same configuration syntax as the
<tt>mrpe.cfg</tt>.
+
diff --git a/ChangeLog b/ChangeLog
index bc7cdbf..4533170 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -66,6 +66,7 @@
* 0125 unitrends_backup:Unitrends Backup...
* 0126 mikrotik_signal: Check for mikrotik wifi bridges
* 0127 hp_proliant_raid: Check for proliant RAID status.
+ * 0265 mpre_include: new local check, allows to include further mrpe
configurations...
* 0103 FIX: services: Fixed bug with service inventory defined in main.mk...
* 0299 FIX: borcade_mlx_fan: Prettified output, handling "other" state now
* 0300 FIX: cisco_fru_power: Trying not to inventorize not plugged in FRUs...
diff --git a/agents/plugins/mrpe_include b/agents/plugins/mrpe_include
new file mode 100755
index 0000000..3fcfb64
--- /dev/null
+++ b/agents/plugins/mrpe_include
@@ -0,0 +1,26 @@
+#!/bin/bash
+echo '<<<mrpe>>>'
+grep -Ev '^[[:space:]]*($|#)' "$MK_CONFDIR/mrpe_include.cfg" | \
+while read user include
+do
+ if [ -f $include ] ; then
+ PREFIX=""
+ if [ "$user" != "-" ] ; then
+ PREFIX="su $user -c "
+ fi
+
+ grep -Ev '^[[:space:]]*($|#)' "$include" | \
+ while read descr cmdline
+ do
+ PLUGIN=${cmdline%% *}
+ if [ -n "$PREFIX" ] ; then
+ cmdline="$PREFIX\"$cmdline\""
+ fi
+ OUTPUT=$(eval "$cmdline")
+ echo -n "(${PLUGIN##*/}) $descr $? $OUTPUT" | tr \\n \\1
+ echo
+ done
+ fi
+done
+
+