set inheritance default option

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
mon-team
Posts: 171
Joined: Thu Jun 28, 2012 9:22 am

set inheritance default option

Post 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
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: set inheritance default option

Post 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
}
Be sure to check out our Knowledgebase for helpful articles and solutions!
mon-team
Posts: 171
Joined: Thu Jun 28, 2012 9:22 am

Re: set inheritance default option

Post 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.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: set inheritance default option

Post 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
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
mon-team
Posts: 171
Joined: Thu Jun 28, 2012 9:22 am

Re: set inheritance default option

Post by mon-team »

Yes Scott.
it's true, in this way it works.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: set inheritance default option

Post by scottwilkerson »

mon-team wrote:Yes Scott.
it's true, in this way it works.
Great!
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
Locked