Skip to content

Instantly share code, notes, and snippets.

@krokodilerian
Created August 5, 2015 10:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save krokodilerian/f0510a5661931a1d68a1 to your computer and use it in GitHub Desktop.
Save krokodilerian/f0510a5661931a1d68a1 to your computer and use it in GitHub Desktop.
do_checks.sh
#!/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