Changing NSClient++ configurations in bulk

At work, we started using Nagios to monitor the hosts and their services for any issues, so we can, proactively, take actions when we see trouble coming (hard disk that fills up rapidly, restarting services, etc).

Recently we change the Nagios host to another IP address and found ourselves having to change a few dozen NSClient.ini files on the server. Even though we use DNS names as monitoring host (only nsclient access on port 12489/tcp is allowed from a certain host), NSClient by default caches the IP address (Using cache_allowed_hosts, which is set to “1” by default) so we were bound to change quite some files.

To do this, we have to do the following:

  • stop the nsclient service
  • overwrite the nsclient.ini file
  • start the nsclient service

For reasons i cannot disclose, this could not be done using any group policies. So we went the ghetto batch way:


@psexec \\%1 "C:\Program Files\NSClient++\NSclient++.exe" -uninstall
@xcopy /Y C:\tool\nagios\nsclient\* "\\%1\c$\program files\nsclient++\"
@psexec \\%1 "C:\Program Files\NSClient++\NSclient++.exe" -install
@psexec \\%1 "C:\Program Files\NSClient++\NSclient++.exe" -start
@echo Finished %1

This assumes you have nsclient++ already, which is an awesome piece of software that you can grab from nsclient.org, and that you have psexec installed to execute commands.

Using this script, you can just run C:\tool\nagios\update_nsc.bat server_name to have the server monitored again.

Thank you,
Michael


Posted

in

by

Comments

One response to “Changing NSClient++ configurations in bulk”

  1. Michael Smith Avatar
    Michael Smith

    “…monitor the hosts and their services for any issues, so we can, proactively, take actions when we see trouble coming…”
    – does it monitor imminent debt deficits as well? 😀

Leave a Reply

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