Page 1 of 1

Service list not belonging to any group

Posted: Fri Oct 04, 2019 10:21 am
by nms
Hi,

We have several monitors assigned to service groups and host groups.
2019-10-04_1718.png
Is there a way to obtain (maybe via api or mysql) the list of all services which do not belong to any of these groups?

Rgds,

Re: Service list not belonging to any group

Posted: Fri Oct 04, 2019 12:19 pm
by benjaminsmith
Hello @nms,

That wouldn't be available in the standard reports. Try following sql query on the nagios database. This would be any host not belonging to a hostgroup.

To log into mysql:

Code: Select all

mysql -u root -p nagiosxi
use nagios;
SQL:

Code: Select all

 SELECT nagios_hosts.display_name FROM nagios_hosts LEFT OUTER JOIN nagios_hostgroup_members ON nagios_hosts.host_object_id = nagios_hostgroup_members.host_object_id WHERE nagios_hostgroup_members.host_object_id is NULL;

Re: Service list not belonging to any group

Posted: Mon Oct 07, 2019 3:04 am
by nms
Hi,

Thank you for this. How can this be done for services that do not belong in any group?

Rgds,

Re: Service list not belonging to any group

Posted: Mon Oct 07, 2019 10:31 am
by benjaminsmith
Hello,

Here's an example. Similar but using the nagios_services and nagios_servicegroup_members tables. Added the host ID, but you'll need to look that up if that's needed.

Code: Select all

SELECT nagios_services.display_name, nagios_services.host_object_id FROM nagios_services LEFT OUTER JOIN nagios_servicegroup_members ON nagios_services.service_object_id = nagios_servicegroup_members.service_object_id WHERE nagios_servicegroup_members.service_object_id is NULL;

Re: Service list not belonging to any group

Posted: Mon Oct 07, 2019 11:33 am
by nms
Thanks!

You may kindly close/lock this thread.

Re: Service list not belonging to any group

Posted: Mon Oct 07, 2019 11:36 am
by benjaminsmith
Thanks!
You may kindly close/lock this thread.
Sounds good. Will close this out. Thank you for using Nagios.