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
How to add a Service to a HostGroup using NagiosXI rest-API
Re: How to add a Service to a HostGroup using NagiosXI rest-
You can run something like this:
where you substitute "myhostgroup" with the actual name of your hostgroup.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"
Be sure to check out our Knowledgebase for helpful articles and solutions!
Re: How to add a Service to a HostGroup using NagiosXI rest-
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.
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-
@imadc Do you have any more questions or it is ok to lock this topic?
Be sure to check out our Knowledgebase for helpful articles and solutions!