Created
August 5, 2015 10:04
-
-
Save krokodilerian/f0510a5661931a1d68a1 to your computer and use it in GitHub Desktop.
do_checks.sh
This file contains 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
#!/bin/bash | |
# Do local checks and send output to nagios | |
# by maniax | |
nagioshost=nagios.ludost.net | |
hst=`hostname` | |
cd `dirname $0` || exit 3 | |
#sleep `expr $RANDOM % 60` | |
# get check results | |
for i in checks/*; do | |
. $i | |
output=$output"$hst\t`basename $i`\t$ret\t$chk\n\027" | |
done | |
# submit checks | |
for i in `seq 1 10`; do | |
/bin/echo -ne "$output" | /usr/sbin/send_nsca -c send_nsca.cfg -H $nagioshost >/dev/null 2>/dev/null | |
if [ $? -eq 0 ]; then | |
exit 0 | |
fi | |
sleep $i | |
done | |
echo Unable to submit checks | |
exit 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment