Skip to content

Instantly share code, notes, and snippets.

@sts sts/mrped
Created Dec 3, 2013

Embed
What would you like to do?
Check_MK use /etc/check_mk/mrpe.d instead of /etc/check_mk/mrpe.conf
#!/bin/bash
# MK's Remote Plugin Executor NG ;-)
#
# Workaround for check_mks inability to use scripts from a mrpe.d directory
# http://lists.mathias-kettner.de/pipermail/checkmk-en/2013-February/008646.html
#
# Make sure mrpe.cfg doesn't exist, or you will end up with two <<<mrpe>>>
# output sections.
#
if [ "$(ls -A /etc/check_mk/mrpe.d)" ] ; then
echo '<<<mrpe>>>'
grep -rhEv '^[[:space:]]*($|#)' "/etc/check_mk/mrpe.d" |
while read descr cmdline
do
PLUGIN=${cmdline%% *}
OUTPUT=$(eval "$cmdline")
echo -n "(${PLUGIN##*/}) $descr $? $OUTPUT" | tr \\n \\1
echo
done
fi
@sts

This comment has been minimized.

Copy link
Owner Author

commented Dec 3, 2013

This is a pretty neat way to do this, and non-intrusive and pretty much what the original check would do.

Find the original code below:

if [ -e "$MK_CONFDIR/mrpe.cfg" ]
then
    echo '<<<mrpe>>>'
    grep -Ev '^[[:space:]]*($|#)' "$MK_CONFDIR/mrpe.cfg" | \
    while read descr cmdline
    do
        PLUGIN=${cmdline%% *}
        OUTPUT=$(eval "$cmdline")
        echo -n "(${PLUGIN##*/}) $descr $? $OUTPUT" | tr \\n \\1
        echo
    done
fi
@sts

This comment has been minimized.

Copy link
Owner Author

commented Jan 31, 2014

Please mind the great fork of this, running all scripts in parallel: https://gist.github.com/Grauwolf/8335012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.