Nagios: Dynamically add a new network host to Nagios

When you are one of a few System Administrators in a large enterprise, new hosts are added that you may not hear about. I created a Perl script that uses the “dig” command to:

  1. Find new hosts added to DNS and obtain the hostname and IP address.
  2. Searches the Nagios hosts directory to make sure it does not exist within Nagios.
  3. Adds the commented-out host definition to a file new_found_host.cfg file. You want the entry to be commented out, because if there is a new entry in DNS that does not mean the server is actually up-and-running.
  4. Scheduled to run in the crontab each night and send out email about new hosts discovered on the domain.

When you initially run the script you will receive a listing of ALL hosts found in DNS, unless you modify the exclude search filters in the Perl script. However, once it is added to the host configuration file, the host will not be rediscovered in subsequent passes.

The Perl script was created quickly, so there is a whole lot of room for System Administrators to modify the script. The script is covered under the GNU license, so we ask that you share with the Nagios community any methods to improve the script.

Here is a link to the ZIP file. Nagios: Dynamically discover hosts on a domain and add them to a Nagios hosts file. The files are placed in a folder, then zipped so you do not have to worry about trying to find them once you open the package.

Bookmark and Share

0 Response to “Nagios: Dynamically add a new network host to Nagios”

Comments are currently closed.