APIs

Ajax CGI

Description:

This script will parse the Nagios status cache file and return
the requested data as Nagios Config, XML or JSON encoded data via HTTP
or STDOUT.

Current Version

1.0

Last Release Date

2013-10-20

Compatible With

  • Nagios 3.x

License

GPL


Project Files
Project Notes
This script will reparse the source files with each request so please be mindful of impact to disk IO and CPU load in larger environments. For best performance, move your Nagios data to a shared memory location such as /dev/shm. Copy or link this script to <nagios_path>/sbin and access it via: http://<nagios_url>/nagios/cgi-bin/ajax.cgi For web access, pass arguments as follows: http://<nagios_url>/nagios/cgi-bin/ajax.cgi?<arg1>=<val1>&<arg2>=<arg2>... For shell/STDOUT, pass arguments as follows: ./ajax.cgi <arg1>=<val1> <arg2>=<val2>... If no arguments are passed, the script will parse and return all status data. The location of the Nagios status file can be set below in STATUS_FILE or as a command argument with: status_file=<status_file> Multiple formats are available including plain text (in Nagios config format), XML and JSON. The default for all web requests is JSON while the default for STDOUT is plain text. Specify the desired format with: format=<xml|json|text> To filter the return data, simply provide the Nagios field name and value for the desired data. Pseudo field 'type' is provided for filtering object types. Example: - The following example will return all 'servicestatus' objects for 'host1.example.com': http://<nagios_url>/nagios/cgi-bin/ajax.cgi?type=servicestatus&host_name=host1.example.com You can also filter which fields are returned for each object by providing a comma separated list in the 'fields' argument. Example: - The following example will only return the 'host_name', 'service_desciption', 'current_state' and 'type' fields for all services ('type' is always returned): http://.../ajax.cgi?type=servicestatus&fields=host_name,service_description,current_state For additional performance benefit, you can limit the number of results returned with: result_limit=n
Reviews (0) Add a Review
Add a Review

You must be logged in to submit a review.

Thank you for your review!

Your review has been submitted and is pending approval.

Recommend

To:


From:


Thank you for your recommendation!

Your recommendation has been sent.

Project Stats
Rating
0 (0)
Favorites
0
Views
36,399