non-critical - SQL query assistance requested

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
SteveBeauchemin
Posts: 524
Joined: Mon Oct 14, 2013 7:19 pm

non-critical - SQL query assistance requested

Post 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
XI 5.7.3 / Core 4.4.6 / NagVis 1.9.8 / LiveStatus 1.5.0p11 / RRDCached 1.7.0 / Redis 3.2.8 /
SNMPTT / Gearman 0.33-7 / Mod_Gearman 3.0.7 / NLS 2.0.8 / NNA 2.3.1 /
NSClient 0.5.0 / NRPE Solaris 3.2.1 Linux 3.2.1 HPUX 3.2.1
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: non-critical - SQL query assistance requested

Post 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';
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
SteveBeauchemin
Posts: 524
Joined: Mon Oct 14, 2013 7:19 pm

Re: non-critical - SQL query assistance requested

Post by SteveBeauchemin »

Thank you.

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

Please close...

Steve B
XI 5.7.3 / Core 4.4.6 / NagVis 1.9.8 / LiveStatus 1.5.0p11 / RRDCached 1.7.0 / Redis 3.2.8 /
SNMPTT / Gearman 0.33-7 / Mod_Gearman 3.0.7 / NLS 2.0.8 / NNA 2.3.1 /
NSClient 0.5.0 / NRPE Solaris 3.2.1 Linux 3.2.1 HPUX 3.2.1
Locked