Nagios-api provides a simple REST-like interface to Nagios. Run it on Nagios host and sit back and enjoy a much easier, more straightforward way to accomplish things with Nagios. You can use the bundled nagios-cli, but you may find it easier to write your own application to interface with this API.
The installation is pretty easy. Checkout its source code, and install its dependencies,
$ git clone https://github.com/zorkian/nagios-api.git $ cd nagios-api $ sudo pip install -r requirements.txt
Its usage is pretty easy. Start the service with corresponding parameters,
$ sudo nagios-api -p 8181 -c /var/lib/nagios3/rw/nagios.cmd -s /var/cache/nagios3/status.dat -l /var/log/nagios3/nagios.log
Use Nagios-cli to communicate with API service
When the service is up and running, we can use nagios-cli to talk to it. Nagios-cli uses the JSON Nagios API to issue commands to Nagios.
Nagios-cli doesn’t have many dependencies, so you can copy it to any other servers as you need, and use it in command line to talk to Nagios. Here are some examples,
$ type nagios-cli nagios-cli is aliased to `nagios-cli —host=nagios.admon.org --port=8181’ $ nagios-cli services WebUI01 TCP_stats SNMP_uptime HP_health Linux_procs SMTP_queue ... $ nagios-cli schedule-downtime WebUI01 Linux_procs 600
Please note that this test is based on Nagios version 3, I’m not sure whether it’s workable on the new Nagios version 4.
Finally big thanks to Mark Smith for this nice tool. Really appreciated 🙂