0

In Nagios Core, it is possible to turn off notifications for a specific service or host through the web interface. This is a simple web request, which we can also construct in a command line script/tool.

This CGI connector is ideal in cases where we need to turn off notifications for hosts that are being manually rebooted, where services are being updated or code redeployed by automated scripts, and so on.

Recently we've been looking into moving to Icinga 2. From its web interface (aptly named Icinga Web), it is possible to do the same thing. There is just one problem; since Icinga has CSRF mitigation, it is not possible to do this in a straightforward manner by emulating Icinga Web requests.

Is there a way of doing this via some sort of API (REST or otherwise)? So far my searches have turned up nothing other than the specifications for the old CGI interface, which doesn't seem to be available on the new Icinga Web, reference: http://docs.icinga.org/latest/en/extcommands2.html

EDIT: After actually reading the provided link carefully, I noticed this provides us with a command file, allowing command insertion as a line-based medium. This still presents us with some problems though (concurrency being one of them).

2 Answers 2

1

Apparently Icinga2 has a feature called "Livestatus" which allows the user to send extcommands (http://docs.icinga.org/latest/en/extcommands2.html) through a TCP connection. All you need to do is prefix the command with COMMAND.

0

You can use Icinga2 API to modify Icinga 2 configuration and send actions to Icinga2 core. In fact current icingaweb2 (Icinga 2.8.1) prefers the API.

For example to disable notifications on service icinga.example!ping4, use:

curl -k -s -XPOST -u root:icinga \
   'https://localhost:5665/v1/objects/services/icinga.example!ping4' \
   -d '{"attrs": {"enable_notifications": false}}' \
   -H 'Accept: application/json' | python -m json.tool

Where root:icinga is your ApiUser name and password.

{"results": [{
        "code": 200.0,
        "name": "icinga.example!ping4",
        "status": "Attributes updated.",
        "type": "Service"
    }]
}   

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .