nnscfgmaker.sh: a nagios/nsclient++ cfg maker

Dear all,

We are in the process of changing the monitoring system on part of our network from Zenoss to Nagios. This is not a Zenoss vs. Nagios debate, as both products are awesome and do the things they are designed for very well. We (Christian and myself) use a combination of Cacti for bandwith monitoring and Zenoss for server and device monitoring. Now, recently we decided to change the latter to Nagios. It is know for its “great deal of flexibility when integrating Nagios into their environment” (Galstad, 2005)

As Zenoss was configured using SNMP Informant to grab information about the MS Windows servers (available disk space, CPU load, etc) and Nagios uses NSClient++; one of the time consuming tasks was getting the client on the server (thank you domain 🙂 ) and configuring each and every server on the Nagios server. I guess there should be some sort of discovery tool for Nagios, but I couldn’t directly find one.

In order to tackle the copy-pasting for a few dozen config files, and to brush up my bash scripting again, I wrote the Nagios Nsclient++ cfg maker, yeah, what’s in a name eh. This client enumerates the target server about what is installed and makes a CFG file based on that. Oh yeah, we’re using nagios with its text files, not the SQL version.

You can download it here (bash script). As it’s GPL’d, feel free to change and redistribute it. As we mainly house HP servers, APC UPS’s and most of them run Windows (for now, evil laugh), so it’s a bit windows/hp minded.

The syntax is very easy, just run the script with the hostname of the server that you want to “enumerate”. Doing that, you’ll have something similar as the output below:

mike@mon:/usr/local/nagios/etc/servers$ ./nnscfgmaker.sh server2
Nagios NSclient++ (check_nt) CFG maker

 + logfile: server2.cfg
 + pinging the server.. ok
 + checking of nsclient++ is installed
 + adding hdd c:\
 + adding hdd e:\
 + adding hdd f:\
 + adding hdd g:\
 + adding hdd h:\
 + adding hdd i:\
 + adding process: MS SQL Server (sqlservr.exe)
 + adding service: Automatic Updates (wuauserv)
 + adding service: DNS Client (DNSCache)
 + adding service: Event Log (Eventlog)
 + adding service: Messenger (Messenger)
 + adding service: Server Service (lanmanserver)
 + adding service: Windows Time (w32time)
 + adding service: SNMP service (SNMP)
 + adding service: HP OpenView Ctrl Service (ovctrl)
 + adding service: Backup Exec Server (BackupExecRPCService)
 + adding service: HP Insight Server Agent (CqMgServ)
 + adding service: HP Insight NIC Agent (CpqNicMgmt)
 + adding service: HP Insight Storage Agent (CqMgStor)
 + adding service: TrendMicro OfficeScan NT Listener (tmlisten)
 + adding service: Trendmicro Antivirus RealTime Scan (ntrtscan)
 - done

mike@mon:/usr/local/nagios/etc/servers$

This creates a files called server2.cfg, which Nagios can read and process.

Hope you like it, let me know if you have any questions or comments.

Take care,
Michael

Ethan Galstad (2005), Nagios. [online] Available from: http://archive.fosdem.org/2005/index/interviews/interviews_galstad.html (Accessed: 28 Jan 2010)


Posted

in

, ,

by

Comments

6 responses to “nnscfgmaker.sh: a nagios/nsclient++ cfg maker”

  1. Santiago Avatar
    Santiago

    Thanks a lot. Very good script I modified it so it sends the nsclient password and only one ip if there are multiple ips for a host name.

  2. Michael Hendrickx Avatar

    Hi Santiago,

    Could you please share the script? I’ve made some changes also, will post that soon, but maybe we can collaborate.

    Thanks,
    Michael

  3. Santiago Avatar
    Santiago

    Where shall I send it?

    email me

  4. Peepzu Avatar
    Peepzu

    nice script, helped me!! thank u

  5. Hema Arun Avatar
    Hema Arun

    It doesn’t work with latest version of nsclient. Could you please provide one with this support as well?

  6. Michael Hendrickx Avatar

    Hi Hema, I;m sorry – I haven’t used Nagios for a while (the original blog post is 8 years old); and I’m sure they changed a few things. Can you share any more pointers on what the error is exactly?

Leave a Reply

Your email address will not be published. Required fields are marked *