The Nagios XI REST API: Harness This Dynamic Feature

Picture of Shamas Demoret
Shamas Demoret
Technical Content Manager
A futuristic neon diagram of an API with the Nagios logo in the center.

Nagios XI has a robust REST API (Representational State Transfer Application Programming Interface) that can programmatically read, write, delete, and update object and system settings and data. The API can be accessed via a web browser or interacted with from the command line via cURL commands. In this article, we’ll explore some key benefits and use cases of this powerful feature. Comprehensive details and example URLs and cURL requests can be found in the Help > API Guide section of the XI interface:

A screenshot of the Nagios XI 'API Docs' menu, showing various REST API endpoints.
The Nagios XI REST API in-interface guide.

Benefits

1. Automation and Integration

The REST API enables integration between Nagios XI and third-party tools like CMDB systems, ticketing platforms, or configuration management tools. This helps reduce manual work, speed up response times, and ensure tool consistency.

2. Status and System Data Access

The API gives you direct access to monitoring data, host and service statuses, XI server and application data, and performance data returned as JSON. Whether you’re building custom dashboards, feeding data into a business intelligence platform, or simply tracking trends in your own system, the API provides access to up-to-date information.

3. Programmatic Provisioning and Decommissioning

You can create, update, or delete host, service, user, and group configurations and apply configuration via the API. This means you can automate the onboarding of new systems and remove decommissioned ones without ever touching the web interface.

4. Custom Alerting & Response Automation

With current status data at your fingertips, you can customize alerting pipelines — for example, sending alerts to ticketing of chat platforms or triggering automatic remediation workflows in your orchestration tool.

REST API Use Cases and Examples

1. Automated Host and Service Management

When new servers or applications are provisioned, you can use the API to automatically add them to monitoring. This works especially well in dynamic environments such as cloud infrastructure or containerized environments, where systems are constantly spun up and down.

Example Workflow:

  • New server instance created in AWS.
  • Configuration management (like Ansible) applies baseline configs to the instance.
  • Ansible calls the Nagios XI API via a cURL POST command to register the host and services and applies configuration.
  • Monitoring and alerting start immediately, without manual intervention.

You can learn more about automation via Ansible using the Nagios XI REST API here:

Nagios XI Ansible Tutorial

Nagios XI supports POST, PUT, and DELETE commands to create, modify, and delete host and service objects, as well as a GET commands, which you can use to review their existing settings. See the Config Reference section of the in-interface guide for examples:

A screenshot of the Config Reference endpoints section of the Nagios XI in-interface REST API guide.
The endpoints are in the Config Reference section.

2. Object Control

The API enables you to not just create new objects and modify them but also control the Nagios monitoring engine’s interactions with them. Below are some common examples. Note that you will need to replace things like <XI.Server.IP> and <your-API-key> with your Nagios XI server’s info (conveniently, these two fields are automatically populated correctly in the example commands in the Help >API Docs section of the interface). You’ll also need to replace the data in arguments such as start=1741116177&end=1741123377 with details specific to your request, in this case, with the correct Unix timestamps for the desired time period.

Note that all of the following are single long commands.

  • Managing Downtime

To view items in downtime, you can use the GET objects/downtime endpoint:

curl -XGET "http://<XI.Server.IP>/nagiosxi/api/v1/objects/downtime?apikey=<your-API-key>&pretty=1"


To schedule downtime for a host, you can use the POST system/scheduleddowntime endpoint. :

curl -XPOST "http://<XI.Server.IP>/nagiosxi/api/v1/system/scheduleddowntime?apikey=<your-API-key>&pretty=1" -d "comment=Test downtime creation&start=1741116177&end=1741123377&hosts[]=<hostname1>&hosts[]=<hostname2>"

To take a host out of downtime, you’ll need the internal_downtime_id of the host you wish to remove from downtime, which can be found by running the GET objects/downtime command noted above, then run a command like the following, replacing the number 10 after /scheduleddowntime/10 with the correct ID.

curl -XDELETE "http://<XI.Server.IP>/nagiosxi/api/v1/system/scheduleddowntime/10?apikey=<your-API-key>&pretty=1"
  • Make objects Active or Inactive

Inactive objects remain visible in the Nagios XI Core Config Manager but are removed from the Nagios Core monitoring engine configs until reactivated, thus ceasing monitoring. Simply switch the objects back to active and apply the configuration to resume monitoring.

Here, a value of 0 for register=0 makes the service inactive, while a value of 1 makes it active:

curl -XPUT "http://<XI.Server.IP>/nagiosxi/api/v1/config/service/<host name>/<service description>?apikey=<your-API-key>&pretty=1&register=0&applyconfig=1"
  • Schedule a Mass Immediate Check

To schedule an immediate check for hosts, services, or groups, you can use the POST system/massimmediatecheck endpoint:

curl -XPOST "http://<XI.Server.IP>/nagiosxi/api/v1/system/massimmediatecheck?apikey=<your-API-key>&pretty=1" -d "hosts[]=<hostname1>"


More information can be found in the System Reference section of the in-interface API guide:

A screenshot of the System Reference endpoints in the Nagios XI in-interface REST API guide.
The System Reference endpoints.

Conclusion

The Nagios XI REST API provides comprehensive insight into and control of your monitoring system. Although the GUI-driven options like monitoring wizards, the Core Config Manager, and the many event management tools make the power of Nagios XI accessible to a broad spectrum of users, the API is an invaluable feature for more advanced users and deeper requirements.

You can find more details and API usage examples in the Accessing and Using the XI REST API doc.

Share: