I have NSClient++ installed on some distributed windows servers that I am using Icinga to monitor. I also have a UPS attached to each server that can execute a custom command before scheduling a shutdown. I would like to create a batch script that calls the NSCA client to notify my central server that the host is running on battery power. It seems from the nsc.ini that it is only possible for NSCAClient to periodically check a local command/service and submit the results to the central server. Is it possible to do what I want and if so, how?
Yes it is.
You can use NSCA and NRPE from command line (if you have a newer version of NSClient++) which means you can submit data at whim. This will work with 0.4.2 and 0.4.3 (and possibly 0.4.1)
nscp nsca --command wicked_command --result WARNING --message "Wh000t I am wicked" --host 127.0.0.1 --log debug --source-host MyHost
For some more options run:
nscp nsca -- --help # <0.4.2 nscp nsca --help # >0.4.3
If you want to test this you can use the following config:
[/modules] SimpleFileWriter = enabled NSCAServer = enabled [/settings/default] allowed hosts = 127.0.0.1 [/settings/NSCA/server] inbox = FILE
And then start nsclient++ (in test mode) and issuing the above command and a file output.txt will be written to for each command you send to NSCA (using the above command).
The NSClient++ docs are quite thorough, so you might want to start there.