Page 1 of 1

non-critical - SQL query assistance requested

Posted: Mon Oct 07, 2019 2:46 pm
by SteveBeauchemin
I am looking for something simple. Nothing is broken. I just require an assist figuring out a select statement.

I am trying to grab a metric from the Nagios DB.

I would like to be able to get a host count total if I provide a Host Group name. (or hg alias).

All I am looking for is a number to be returned.

Please advise.

Thank you

Steve B

Re: non-critical - SQL query assistance requested

Posted: Mon Oct 07, 2019 3:44 pm
by scottwilkerson
Here you go in the nagios DB, replace HOSTGROUP_NAME with yours

Code: Select all

SELECT count(*) from nagios_hostgroup_members,nagios_objects,nagios_hostgroups 
WHERE nagios_hostgroups.hostgroup_id=nagios_hostgroup_members.hostgroup_id 
AND nagios_hostgroups.hostgroup_object_id=nagios_objects.object_id 
AND name1='HOSTGROUP_NAME';

Re: non-critical - SQL query assistance requested

Posted: Mon Oct 07, 2019 3:59 pm
by SteveBeauchemin
Thank you.

Management metrics request drives this question. Now I can automate the data for them.

Please close...

Steve B