Network Discovery
Dan Stromberg
strombrg at dcs.nac.uci.edu
Tue Jan 18 23:14:52 CET 2005
Actually, isn't there some sort of script already available that does
this?
I'm cozy with nmap+grep+sed, you're cozy with nmap+grep+sed, but a
significant fraction of the world is not.
On Sun, 2005-01-16 at 13:34 +0100, Andreas Ericsson wrote:
> 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.
>
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: <https://www.monitoring-lists.org/archive/users/attachments/20050118/f9bade5e/attachment.sig>
More information about the Users
mailing list