1
0
mirror of https://github.com/opinkerfi/nagios-plugins.git synced 2024-11-24 19:33:46 +01:00
nagios-plugins/misc/nagios_autodiscover

29 lines
520 B
Plaintext
Raw Normal View History

2010-11-07 18:59:13 +01:00
#!/bin/sh
IPS=`fping -a -g $1 2>/dev/nul`
if [ $? -gt 2 ]; then
echo failed to run fping
exit 1
fi
#addgroup --group misc --alias "Misc hosts"
for ip in $IPS; do
# Check if this host already exists
grep -qw $ip /var/log/nagios/objects.cache
if [ $? -eq 0 ]; then
continue
fi
RES=`host $ip`
if [ $? -gt 0 ]; then
HOSTN=$ip
else
2010-11-08 22:23:13 +01:00
HOSTN=`echo $RES | head -n 1 | sed 's/.*name pointer //' | sed 's/\.$//'`
2010-11-07 18:59:13 +01:00
fi
echo $ip = $HOSTN
2010-11-08 22:23:13 +01:00
addhost --host $HOSTN --ip $ip --group misc --templates autodiscover
2010-11-07 18:59:13 +01:00
done