Skip to content
Snippets Groups Projects
Commit 58d25fcc authored by Per Cederqvist's avatar Per Cederqvist
Browse files

Added check_hostextinfo.

parent d3316e2a
No related branches found
No related tags found
No related merge requests found
DESTDIR = /usr/local/nagios/libexec/ DESTDIR = /usr/local/nagios/libexec/
SCRIPTS = check_cups check_glsa check_saned check_lpd check_hddtemp \ SCRIPTS = check_cups check_glsa check_saned check_lpd check_hddtemp \
check_link_status check_true check_lysrdiff check_syslog \ check_link_status check_true check_lysrdiff check_syslog \
check_ping check_enodia_monitored check_ping check_enodia_monitored check_hostextinfo
all:; all:;
......
#!/bin/sh
HOSTEXT=`tempfile`
HOSTS=`tempfile`
DIFF=`tempfile`
MISSING=`tempfile`
EXTRA=`tempfile`
awk '$1 != "#" { print $1 }' /etc/nagios/hostextinfo.txt \
| sort > $HOSTEXT
sed -n 's/^[ ]*host_name[ ][ ]*\(.*\)$/\1/p' /etc/nagios/hosts.cfg \
| sort > $HOSTS
diff -U0 $HOSTS $HOSTEXT > $DIFF
diffrv=$?
sed -n -e 1,2d -e 's/^-//p' $DIFF > $MISSING
sed -n -e 1,2d -e 's/^+//p' $DIFF > $EXTRA
case $diffrv in
0) echo OK
rv=0;;
1) echo -n CRITICAL - /etc/nagios/hostextinfo.txt:
if [ `wc -l < $MISSING` -gt 0 ]
then
echo -n ' 'Add `cat $MISSING`.
fi
if [ `wc -l < $EXTRA` -gt 0 ]
then
echo -n ' 'Remove `cat $EXTRA`.
fi
echo
rv=2;;
*) echo CRITICAL - diff failed
rv=2;;
esac
rm $HOSTEXT $HOSTS $DIFF
exit $rv
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment