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.
hosttemplates overview from database
Re: hosttemplates overview from database
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.
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
Hi,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.
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?
Re: hosttemplates overview from database
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.
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/
https://www.mcapra.com/
Re: hosttemplates overview from database
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.