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
Using this script, you can just run C:\tool\nagios\update_nsc.bat server_name to have the server monitored again.