Network Discovery
Andreas Ericsson
ae at op5.se
Sun Jan 16 13:34:32 CET 2005
Steven Coutts wrote:
> Is there anyway for Nagios to do automatic network discovery?
>
man nmap
man grep
man sed
Something like this should work;
for ip in `nmap -sP -T Insane 192.168.0.1-254 | grep "appears to be up"
| gawk '{ print $2 }'`; do
sed "s/@host@/$ip/" host.in >> hosts.cfg
done
Where host.in look something like this
define host{
use default-host-template
host_name @host at -name
address @host@
alias @host at -alias
}
Then, supposing you have some way of getting a
tab/comma/semi-colon/whatever separated list of hostnames, ip's and
descriptions (in field order), you can do
cat that_list | while read host_name ip alias; do
sed -i -e "s/$ip-name/$host_name/" -e "s/$ip-alias/$alias/" hosts.cfg
done
Mind the line-breaks.
> Or do I have to manually have to type all my hosts in the hosts.cfg file?
>
Then add a service PING to all hosts, as such;
define service {
use default-service
service_description PING
host_name *
check_command check_ping!100.0,40%!500.0,80%
}
Delete the nodes you don't want to monitor, and keep fiddling a bit.
I suggest you then divide the hosts into various groups depending on
what you want to check on them and simply add a bunch of services to the
proper hostgroups. It will save you a lot of typing.
--
Andreas Ericsson andreas.ericsson at op5.se
OP5 AB www.op5.se
Lead Developer
-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues
Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek.
It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue.
::: Messages without supporting info will risk being sent to /dev/null
More information about the Users
mailing list