Page 1 of 1
How to add a Service to a HostGroup using NagiosXI rest-API
Posted: Thu Jul 27, 2017 2:04 pm
by imadc
Hello Team
With Nagios XI 5.4.7
I would like to add Services to host-groups using rest API of NagiosXI
Is there a way to do that?
I was able to import services and add service templates but didnt see an option for host groups
Thanks
Re: How to add a Service to a HostGroup using NagiosXI rest-
Posted: Thu Jul 27, 2017 3:11 pm
by lmiltchev
You can run something like this:
curl -XPOST "
http://x.x.x.x/nagiosxi/api/v1/config/s ... 7&pretty=1" -d "host_name=localhost&service_description=PING
&hostgroup_name=myhostgroup&check_command=check_ping\!3000,80%\!5000,100%&check_interval=5&retry_interval=5&max_check_attempts=2&check_period=24x7&contacts=nagiosadmin¬ification_interval=5¬ification_period=24x7&applyconfig=1"
where you substitute "myhostgroup" with the actual name of your hostgroup.
Re: How to add a Service to a HostGroup using NagiosXI rest-
Posted: Wed Dec 13, 2017 11:17 am
by krutaw
NICE! And for anyone who runs a Nagios server that doesn't link services directly to hosts but instead links to hostgroups, you can use the &force=1 command to force a service check to link directly to the hostgroup without defining a host.
Example:
curl -XPOST "
https://YOURNAGIOSSERVERHERE/nagiosxi/a ... E&pretty=1" -d "hostgroup_name=test&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¬ification_interval=5
¬ification_period=24x7&applyconfig=1&force=1"
Note: the config name in core config will be listed as the hostgroup name.
Sorry, had to break apart the command in order to make it all show up.

Re: How to add a Service to a HostGroup using NagiosXI rest-
Posted: Wed Dec 13, 2017 11:39 am
by lmiltchev
@imadc Do you have any more questions or it is ok to lock this topic?