Page 1 of 1

set inheritance default option

Posted: Fri Dec 20, 2019 9:30 am
by mon-team
Hello Support,
i wrote a post some months ago but now it's locked and i cannot edit it. My question indeed is still open :-)
I'd like to know if is it possible to set the default servicegroups and contactgroup inheritance value...currently (i use Nagios XI 5.6) it's set to 'Standard' while i'd like to set to '+' this option by default.

Infact, when i create service manually from the CCM i can change the value by myself.
But when i use the API to create a new service (config/service) i'm unable to set this option to the desired value. Also using the config/import endpoint i'm unable to do this..i can only set a service template using with inheritance option set to '+' but i cannot set the option relative to the service.

I hope to have been clear enough, if you need further details let me know.
regards
Francesco

Re: set inheritance default option

Posted: Fri Dec 20, 2019 12:27 pm
by lmiltchev
OK, I tried "triple-encoding" the plus sign ("%2B%2B%2B"), which worked for me.

Example REST API call:

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&check_command=check_ping\!3000,80%\!5000,100%&check_interval=5&retry_interval=5&max_check_attempts=2&check_period=24x7&contacts=nagiosadmin&notification_interval=5&notification_period=24x7&servicegroups=%2B%2B%2BPing&contact_groups=%2B%2B%2Badmins&applyconfig=1"
{
    "success": "Added testapihost :: PING to the system. Config applied, Nagios Core was restarted."
}

The service config that was generated:

Code: Select all

define service {
    host_name                testapihost
    service_description      PING
    servicegroups            +Ping
    check_command            check_ping!3000,80%!5000,100%
    max_check_attempts       2
    check_interval           5
    retry_interval           5
    check_period             24x7
    notification_interval    5
    notification_period      24x7
    contacts                 nagiosadmin
    contact_groups           +admins
    register                 1
}

Re: set inheritance default option

Posted: Mon Dec 23, 2019 6:10 am
by mon-team
I've seen your answer,
in this way it works but you are setting a Service Group for the service directly.
Instead, i set the service group inside a Service Template and i apply the Service Template to the service... in this way i cannot set the '+' option to the service.

The workaround is to use a fake servicegroup to apply on all services passing the '+' option but it's not very clean.

Re: set inheritance default option

Posted: Mon Dec 23, 2019 8:28 am
by scottwilkerson
mon-team wrote:I've seen your answer,
in this way it works but you are setting a Service Group for the service directly.
Instead, i set the service group inside a Service Template and i apply the Service Template to the service... in this way i cannot set the '+' option to the service.

The workaround is to use a fake servicegroup to apply on all services passing the '+' option but it's not very clean.
If you set it in the template already you do not need to add the the servicegroups directive at all unless you are adding another servicegroup in which case the above should work

Re: set inheritance default option

Posted: Mon Dec 23, 2019 8:43 am
by mon-team
Yes Scott.
it's true, in this way it works.

Re: set inheritance default option

Posted: Mon Dec 23, 2019 4:16 pm
by scottwilkerson
mon-team wrote:Yes Scott.
it's true, in this way it works.
Great!