hosttemplates overview from database

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
sltn_support
Posts: 20
Joined: Thu Dec 07, 2017 10:12 am

hosttemplates overview from database

Post by sltn_support »

Hi,

Is there a to create a list from the Nagios database where the hosts show the used templates.
In CCM I can view the host with templates used but I would like to know how this is done in sql.

Regards, Patrick.
User avatar
cdienger
Support Tech
Posts: 5045
Joined: Tue Feb 07, 2017 11:26 am

Re: hosttemplates overview from database

Post by cdienger »

echo "select * from tbl_lnkHosttemplateToHost;" | mysql -uroot -pnagiosxi -Dnagiosql
echo "select * from tbl_lnkHostToHosttemplate;" | mysql -uroot -pnagiosxi -Dnagios


The above will show you links between hosts and hosttemplate ids. The ids can then be linked to ids found in tbl_host and tbl_hosttemplate.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
sltn_support
Posts: 20
Joined: Thu Dec 07, 2017 10:12 am

Re: hosttemplates overview from database

Post by sltn_support »

cdienger wrote:echo "select * from tbl_lnkHosttemplateToHost;" | mysql -uroot -pnagiosxi -Dnagiosql
echo "select * from tbl_lnkHostToHosttemplate;" | mysql -uroot -pnagiosxi -Dnagios


The above will show you links between hosts and hosttemplate ids. The ids can then be linked to ids found in tbl_host and tbl_hosttemplate.
Hi,

with the first line I get 0 results and with the second one I get 2878 rows.
In the ccm I can see the assigned templates; this has to be a sql statement, right?
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: hosttemplates overview from database

Post by mcapra »

As mentioned by @cdienger, you'll need to join the results of those queries to their respective object tables.

There is indeed logic within the Nagios XI code that resolves this, but I don't believe it's a simple static SQL command that you could copy+paste and have it work. It's a generic set of functions that joins objects with linking tables; Having hard-coded queries do this wouldn't be very efficient.

If you're interested in exactly how that works, the NagiosQL source code is publicly available.
Former Nagios employee
https://www.mcapra.com/
User avatar
cdienger
Support Tech
Posts: 5045
Joined: Tue Feb 07, 2017 11:26 am

Re: hosttemplates overview from database

Post by cdienger »

Thanks for the clarification and link, @mcapra!
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Locked