Search Exchange

Search All Sites

Nagios Live Webinars

Let our experts show you how Nagios can help your organization.

Contact Us

Phone: 1-888-NAGIOS-1
Email: sales@nagios.com

Login

Remember Me

Directory Tree

Ajax CGI

Current Version
1.0
Last Release Date
2013-10-20
Compatible With
  • Nagios 3.x
License
GPL
Hits
36465
Files:
FileDescription
ajax.cgi.txtajax.cgi.txt
Nagios CSP

Meet The New Nagios Core Services Platform

Built on over 25 years of monitoring experience, the Nagios Core Services Platform provides insightful monitoring dashboards, time-saving monitoring wizards, and unmatched ease of use. Use it for free indefinitely.

Monitoring Made Magically Better

  • Nagios Core on Overdrive
  • Powerful Monitoring Dashboards
  • Time-Saving Configuration Wizards
  • Open Source Powered Monitoring On Steroids
  • And So Much More!
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.
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