1
0
mirror of https://github.com/opinkerfi/nagios-plugins.git synced 2024-09-28 16:33:46 +02:00

nrpe.d added for check_nagios

This commit is contained in:
root 2011-10-24 17:21:17 +00:00
parent aaa9b2d55a
commit 1941f62f8f
3 changed files with 43 additions and 3 deletions

View File

@ -0,0 +1,38 @@
#!/bin/sh
PERFDATA=""
MESSAGE="Nagios configuration is valid"
EXIT_CODE=3
TMPFILE=`mktemp`
nagios -v /etc/nagios/nagios.cfg > $TMPFILE
RESULT=$?
# grep -E '^\s+Checked'
warnings=`grep -c -E "^Warning:" "$TMPFILE"`
errors=`grep -c -E "^Error:" "$TMPFILE"`
PERFDATA="warnings=$warnings errors=$errors"
# If there are any warnings
if [ $warnings -gt 0 ]; then
MESSAGE="nagios.cfg has $warnings warnings"
EXIT_CODE=1
fi
# If nagios -v fails. Config is invalid
if [ $RESULT -gt 0 ]; then
MESSAGE="Could not validate Nagios configuration."
EXIT_CODE=2
fi
if [ $EXIT_CODE -eq "3" ]; then
EXIT_CODE=0
fi
echo "$MESSAGE | $PERFDATA"
grep -E "^Error|^Warning" "$TMPFILE"
rm -f TMPFILE
exit $EXIT_CODE

View File

@ -13,16 +13,16 @@ sort | uniq > $TMP
LINES=`cat $TMP | wc -l`
PERFDATA="'ghost_clients'=$LINES"
PERFDATA="'ghost_services'=$LINES"
if [ $LINES -gt 0 ]; then
echo "$LINES ghost clients found in Nagios log files | $PERFDATA"
echo "$LINES ghost services found in Nagios log files | $PERFDATA"
echo ""
cat $TMP
rm -f $TMP
exit 1
fi
echo "No ghost clients found in Nagios log files | $PERFDATA"
echo "No ghost services found in Nagios log files | $PERFDATA"
rm -f $TMP
exit 0

View File

@ -0,0 +1,2 @@
command[check_nagios_configuration]=/usr/lib64/nagios/plugins/check_nagios_configuration
command[check_nagios_ghostservices]=/usr/lib64/nagios/plugins/check_nagios_ghostservices