Skip to content

Instantly share code, notes, and snippets.

@rakesh-patnaik
Created July 29, 2015 22:13
Show Gist options
  • Save rakesh-patnaik/0ef7f49862c1872c6496 to your computer and use it in GitHub Desktop.
Save rakesh-patnaik/0ef7f49862c1872c6496 to your computer and use it in GitHub Desktop.
composite nagios check
#!/bin/bash
nrpe="/usr/local/nagios/libexec/check_nrpe"
hostname="127.0.0.1"
check_one="$1"
check_two="$2"
$nrpe -H $hostname -c $check_one
return_one=$?
$nrpe -H $hostname -c $check_two
return_two=$?
output=3
if [ "$return_one" -ge 0 ] && [ "$return_two" -ge 0 ]; then
output=0
status="OK"
fi
if [ "$return_one" -ge 1 ] && [ "$return_two" -ge 1 ]; then
output=1
status="WARNING"
fi
if [ "$return_one" -eq 2 ] && [ "$return_two" -eq 2 ]; then
output=2
status="CRITICAL"
fi
echo $status
exit $output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment