-
-
Save Grauwolf/8335012 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env zsh | |
# 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. | |
# | |
set -o pipefail | |
if [[ -e /etc/mrpe.conf ]] | |
then | |
echo "mrpe.conf should not exist when running mrped" | |
exit 1 | |
fi | |
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" | tr \\n \\1) | |
echo -n "(${PLUGIN##*/}) $descr $? $OUTPUT" | |
)& | |
pids=(${pids[@]} $!) | |
done | |
for j in ${pids[@]}; do | |
wait $j &> /dev/null | |
done | |
fi |
Paralysed! :-) Thanks Farhad!
Downside: Currently its a drop in replacement ; GNU Parallel isn't installed on all systems and adds an additional dependency.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Should probably do this with GNU Parallel instead.