REST api required variables

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
User avatar
WillemDH
Posts: 2320
Joined: Wed Mar 20, 2013 5:49 am
Location: Ghent
Contact:

REST api required variables

Post by WillemDH »

Hello,

I'm wondering why the nagiosxi/api/v1/config/service config rest api requires certain variables to be set. More specific I'm speaking about:

Code: Select all

"json": {
        "error": "Missing required variables",
        "missing": [
            "max_check_attempts",
            "check_interval",
            "retry_interval",
            "notification_interval"
        ]
    },
As we use service templates which hold these values, forcing us to set these variables with the rest api kind of obsoletes the service template?

Grtz

Willem
Nagios XI 5.8.1
https://outsideit.net
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: REST api required variables

Post by lmiltchev »

Without these variables, configuration would fail. The REST API wouldn't know if all of these are inherited from a template... Having said that, if you are sure your configuration is OK, you could force the command, and still use templates.

Example:

Code: Select all

# curl -XPOST "http://x.x.x.x/nagiosxi/api/v1/config/service?apikey=xxx&pretty=1" -d "host_name=testapihost&service_description=PING&use=xiwizard_linuxserver_ping_service&force=1&applyconfig=1"
{
    "success": "Successfully added testapihost :: PING to the system. Config applied, Nagios Core was restarted."
}
Here's the config of the new PING service that was added:

Code: Select all

define service {
    host_name              testapihost
    service_description    PING
    use                    xiwizard_linuxserver_ping_service
    register               1
}
Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked