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

Check that Nagios monitors all hosts found by Enodia.

parent fc93e91b
No related branches found
No related tags found
No related merge requests found
DESTDIR = /usr/local/nagios/libexec/
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
all:;
......
#!/bin/sh
# Check that all hosts in /opt/enodia/export/active_ips.txt are
# monitored by Nagios. More accurately, for each line in
# active_ips.txt, check that /usr/local/nagios/var/checked_ips/$ip
# exists and is at most 24 hours old. That file is created by the
# check_ping script.
CHECKED=/usr/local/nagios/var/checked_ips
UNCHECKED=`tempfile`
unmonitored=""
find "$CHECKED" -mtime +1 -exec rm {} \;
while read ip host
do
if [ ! -f $CHECKED/$ip ]
then
echo "$ip ($host)" >> "$UNCHECKED"
fi
done < /opt/enodia/export/active_ips.txt
unchecked=`wc -l < "$UNCHECKED"`
if [ $unchecked = 0 ]
then
echo "OK - all checked | unchecked=0"
mv -f "$UNCHECKED" /usr/local/nagios/var/unchecked
exit 0
else
echo -n "CRITICAL - $unchecked unchecked hosts: "
sed 's/\.lysator\.liu\.se)$/)/' "$UNCHECKED" \
| awk 'BEGIN { sz = 0 }
NR > 1 && sz < 198 { printf ", "; sz += 2 }
sz < 200 { printf "%s", $0; sz += length($0) }
END { if (sz >= 200) printf ", others" } ' \
| sed 's/, \([^,]*\)$/ and \1/'
echo ". | unchecked=$unchecked"
mv -f "$UNCHECKED" /usr/local/nagios/var/unchecked
exit 2
fi
#!/bin/sh
[ "$1" = "-H" ] || fatal
HOSTADDRESS="$2"
[ "$3" = "-w" ] || fatal
WARN="$4"
[ "$5" = "-c" ] || fatal
CRIT="$6"
[ "$7" = "-p" ] || fatal
P="$8"
IP_TMP=`tempfile`
if getent hosts $HOSTADDRESS > "$IP_TMP"
then
read ip host < "$IP_TMP"
touch /usr/local/nagios/var/checked_ips/$ip
fi
rm -f "$IP_TMP"
exec /usr/nagios/libexec/check_ping -H "$HOSTADDRESS" -w "$WARN" -c "$CRIT" -p "$P"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment