Network Discovery

Andreas Ericsson ae at op5.se
Tue Jan 18 23:25:28 CET 2005


Dan Stromberg wrote:
> Actually, isn't there some sort of script already available that does
> this?
> 

I think so, but thinking up the code was faster than finding the link 
(which would have been the inevitable second question).

> I'm cozy with nmap+grep+sed, you're cozy with nmap+grep+sed, but a
> significant fraction of the world is not.
> 

Yes, and it's a shame that those un-cozy folks aren't so cozy with 
google and 10-15 minutes of navigating the www.nagios.org either. I know 
the nmap2nagios is there somewhere.

Anyways, Mr. Coutts. I believe you should be able to find nmap2nagios 
somewhere on www.nagios.org if you aren't cozy enough with nmap+grep+sed 
to copy-paste the script in my original post (although I'm fairly 
certain it should work ok).

> 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.
>>
>>

-- 
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