Page 1 of 1

Nagios XI 5.4.0 Rest API

Posted: Wed Jan 11, 2017 3:40 pm
by bennyboy
Hi,

I try to use the API to create couple host and use template for Notification setting. When I try to create it I have error: missing required variables.

Do you have a workaround to force that type of usage please.

Code: Select all

curl -XPOST "http://slpmon0034/nagiosxi/api/v1/config/host?apikey=APIKEY&pretty=1" -d "host_name=sldlog0398&address=172.26.14.7&use=xiwizard_linuxserver_host&max_check_attempts=5&check_intervalcheck_interval=5&retry_interval=1&check_period=xi_timeperiod_24x7&icon_imageicon_image=redhat.pngredhat.png&statusmap_image=redhat.png&_xiwizard=linux-server&&applyconfig=1"
{
    "error": "Missing required variables",
    "missing": [
        "notification_interval",
        "notification_period",
        "contacts OR contact_groups"
    ]
}
Thank you!!

Re: Nagios XI 5.4.0 Rest API

Posted: Wed Jan 11, 2017 3:54 pm
by rkennedy
Take a look at the attachment for a document I wrote that's really helpful in regards to the API.
Nagios-Automating-with-Nagios-XI.zip
What version of XI are you running?

The template xiwizard_linuxserver_host does NOT have any notification information set, but the template assigned to it does - what happens if you use the direct xiwizard_generic_host?

Re: Nagios XI 5.4.0 Rest API

Posted: Wed Jan 11, 2017 6:39 pm
by bennyboy
XI 5.4.0

Code: Select all

curl -XPOST "http://slpmon0034/nagiosxi/api/v1/config/host?apikey=APIKEY&pretty=1" -d "host_name=sldlog0398&address=172.26.14.7&use=xiwizard_generic_host&max_check_attempts=5&check_intervalcheck_interval=5&retry_interval=1&check_period=xi_timeperiod_24x7&icon_imageicon_image=redhat.pngredhat.png&statusmap_image=redhat.png&_xiwizard=linux-server&applyconfig=1"
{
    "error": "Missing required variables",
    "missing": [
        "notification_interval",
        "notification_period",
        "contacts OR contact_groups"
    ]
}
Same error

Re: Nagios XI 5.4.0 Rest API

Posted: Wed Jan 11, 2017 6:47 pm
by SteveBeauchemin
You need to add...

Code: Select all

&force=1
To the curl statement if you are not supplying all the parameters.

I use templates heavily and do not use all the required parameters either. They are in a template and centrally controlled.

Good Luck!

Steve B

Re: Nagios XI 5.4.0 Rest API

Posted: Wed Jan 11, 2017 7:02 pm
by bennyboy
Thank you!!! It's working now :)
SteveBeauchemin wrote:You need to add...

Code: Select all

&force=1
To the curl statement if you are not supplying all the parameters.

I use templates heavily and do not use all the required parameters either. They are in a template and centrally controlled.

Good Luck!

Steve B

Re: Nagios XI 5.4.0 Rest API

Posted: Thu Jan 12, 2017 10:19 am
by rkennedy
SteveBeauchemin wrote:You need to add...

Code: Select all

&force=1
To the curl statement if you are not supplying all the parameters.

I use templates heavily and do not use all the required parameters either. They are in a template and centrally controlled.

Good Luck!

Steve B
Thanks Steve!

@bennyboy - are we good to mark this one resolved?

Re: Nagios XI 5.4.0 Rest API

Posted: Fri Jan 13, 2017 10:28 am
by bennyboy
rkennedy wrote:
@bennyboy - are we good to mark this one resolved?
Yes!!!