Auto Discovery of Hosts - Need a Nudge in the Right Directio


I am replacing an existing OpenNMS monitoring system with a nicely designed Nagios system. Nagios beats this old system hands down. The one thing that OpenNMS did that I can’t seem to replicate however is the auto discovery of new hosts. Obviously OpenNMS does this using scripting and snmp traps. I assume I would use a similar system with Nagios. I set up the original list of hosts using an nMpa scan and the scripts described in the Jospehson book. Those worked well as an initial discovery but are impractical for constant monitoring to discover new hosts.

Anybody have a way of doing this now? I would really appreciate any help you can throw my way.




well i would imagine the only way to do it would be to make a script that does a quick nmap -sP and searches your current nagios host configs for matches. if a match is found, do a more intrusive nmap + SNMP scan to get info, then print a new host entry to your hosts.cfg and add the host to different services based on some nmap/SNMP output, and restart nagios. throw the script in cron so it’s run every x amount of time.

You could also use another automatic network discovery application, like Netdisco or some other variant, and parse through the output of that in order to generate nagios configs.

Do you know regex? perl would help you a ton here

other than that i can’t really think of anything. Nagios doesn’t have the ability to actively look for new hosts and assign service checks to them. Good luck!


Hey MP - I had somewhat envisioned what you have suggested here, but the lazy side of me was hoping that someone had already done this in some fashion. I have to believe that everyone who has implemented Nagios has this issue! What do you do when your host roster changes? Is everyone keeping a manual roster? Doesn’t seem to make sense. Some of you must be in large network environments that force you to use some type of automation to add hosts and have some clever and dazzling way to get new hosts into Nagios? It just has to be! :wink:


well, that could be my case … or not :slight_smile:
What we do here, is keep an up-to-date reference of our whole IT system.
In short, it’s just a database with all the servers listed, the switchs, softwares, databases…etc

So, we just have to get the data from this DB, parse it using some perl scripts and generate the cfg files.

Pretty easy and lazy (well …after the set up is done!) :slight_smile:

and anyway, having a listing of all your hardware and software is somewhat an obligation :wink:

sorry if this didn’t help you a lot, but that’s definitely the best way we found to monitor everything (well …almost everything, since it’s based on the teams keeping the reference up to date)


Hey Loose - thanks for the reply. I agree any up to snuff IT group had better have an accurate inventory of their assets. We absolutely do have that.

My problem, or I guess more accurately management’s problem, is that the OpenNMS system did auto-discovery. It uses SNMP traps to discover when a new host has been added and sends alerts and creates a host entry. They see it as a fundamental feature.

I have been selling Nagios as a significant upgrade, but they keep coming back with “but it doesn’t do auto -discovery”. Thankfully they are sold on Nagios despite this, and we will enjoy many of the system’s advantages over OpenNMS, but this is one feature that I would have expected to be there and IMO sorely miss. Not to look a gift horse in the mouth, this is a fantastic piece of software at any price, particularly free, and I am very appreciative to all who worked on it and continue to support it. I just would have expected such a widely implemented app to have solved what has to be a problem every installation has encountered.

Just imagine if it did discover and create host entires for every machine plugged into your network, how valuable would that be? I am not a coder or I would seriously consider attacking this issue. I have been looking for an excuse to learn Perl, maybe this is it:?:

Thanks for your feedback regardless!


Hey Joe,

Basically, nagios doesn’t do host discovery because it’s used to monitor such a huge variety of devices/servers, that the logic required to automatically assign specific services to specific hosts would be pretty much impossible for the developers to code for.

Auto device discovery + service assignment isn’t really a huge issue when all you’re monitoring are SNMP-enabled devices like routers and switches. Nagios can monitor these very well, but most of its attractive functionality is for the ability to monitor servers and services (ie: log in to a website, run a query, return output, parse output, alert based on output). it wouldn’t really work if nagios saw a new server get added, sees that port 80 is open, then decides to assign HTTP services to it when really you want squid services associated to it.

Anyways theres still some stuffs you could do, i would for sure look into a dedicated device discovery software and parse output from there. Loose’s method would also be pretty pimped, just gotta make sure those ops guys keep the database up to date!


Hey MP

Thanks for the input. I guess I am viewing Nagios too specifically. I work in an environment where we want to monitor every production machine from the minute it is connected to the network. Every host gets a PING up/down check by default. I also watch a handful of other machines for disk space issues and http, smtp, ftp availability, but out of 400 plus hosts I watch just up/down on 375 or more. This is a broad variety of server types, Unix, Linux, Windows servers, and a large number of routers and switches. We add/remove hosts regularly and the company policy is that I monitor all hosts for up/down. So my needs with the program are probably different than many users, and I am not considering that the typical use is for more static environments. However - don’t most Nagios implementations use the app to check up/down for all their machines? I have to believe you would want that info, at least for every server and network infrastructure piece of equipment.

OpenNMS has a built in capacity to alert when a new host is added to the network. I saw Nagios as basically an upgrade to OpenNMS. Both are monitoring programs and both work fairly extensively with SNMP.

I am tossing the idea around of coding this using nMap against the roster of known hosts. If I can get this to a point where I think it might help the community I will let you all know. I really like the idea of being able to contribute.

Thanks again for taking the time!



I was looking into a lot of the same stuff. I was wondering if anyone got somewhere on this?