SQL Queries to DB Nagios

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
FCC_Nagios_Support
Posts: 161
Joined: Tue Mar 10, 2020 11:07 am

SQL Queries to DB Nagios

Post by FCC_Nagios_Support »

Hello,
What is the query to obtain hosts in a determinate hostgroup.
Thanks
User avatar
cdienger
Support Tech
Posts: 5045
Joined: Tue Feb 07, 2017 11:26 am

Re: SQL Queries to DB Nagios

Post by cdienger »

You can get this information from the API. To find the command you can go to Help > API Docs > Objects Reference > Group Members > objects/hostgroupmembers. The command would look something like:

Code: Select all

curl -XGET "http://XI_ADDRESS/nagiosxi/api/v1/objects/hostgroupmembers?apikey=<API_KEY>&pretty=1&hostgroup_name=HOSTGROUPNAME"
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
FCC_Nagios_Support
Posts: 161
Joined: Tue Mar 10, 2020 11:07 am

Re: SQL Queries to DB Nagios

Post by FCC_Nagios_Support »

Many Thanks Sir.
But do you now de SQL Query?

Thanks again
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: SQL Queries to DB Nagios

Post by ssax »

WARNING: We do not recommend that you interact directly with the nagios databases. If you write to the DB directly and it causes issues it will not be supported. You should use the API whenever possible.

You can look in this file:

Code: Select all

/usr/local/nagiosxi/html/db/queries.inc.php
Search for this and you'll see the query it uses:

Code: Select all

// HOSTGROUP MEMBERS
Locked