extract info template

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
Support_Talea
Posts: 73
Joined: Wed Oct 04, 2017 7:12 am

extract info template

Post by Support_Talea »

Hi,

I would like to ask you if it is possible to receive the list of mysql tables / views to be able to extrapolate the following data.

I need to create a list of hosts / services by querying the template hosts and template services.
The goal is to figure out how many hosts / services depend on a particular template object.

I would also like to insert the description during the select.

Best regards,
-Fede
User avatar
pbroste
Posts: 1288
Joined: Tue Jun 01, 2021 1:27 pm

Re: extract info template

Post by pbroste »

Hello @Support_Talea

Thanks for reaching out. Could you provide an example of the sorting that you are striving to accomplish with template objects? If you want you can use the web ui or '/usr/local/nagios/etc/...cfg's.

Thanks,
Perry
Support_Talea
Posts: 73
Joined: Wed Oct 04, 2017 7:12 am

Re: extract info template

Post by Support_Talea »

Hi Perry,

I would like to extrapolate this data from the dashboard through a select.

I would like to associate service with servicetemplate and hosts
I would like to associate hosts with hosttemplate and services.

Regards,
-Fede
You do not have the required permissions to view the files attached to this post.
User avatar
pbroste
Posts: 1288
Joined: Tue Jun 01, 2021 1:27 pm

Re: extract info template

Post by pbroste »

Hello @Support_Talea

A simple method of pulling from the CCM configs:

Get a list from the host and service templates:

Code: Select all

cat /usr/local/nagios/etc/servicetemplates.cfg | grep -Ei 'name' | awk '{print $2}' > servicenames.txt
And the host templates:

Code: Select all

cat /usr/local/nagios/etc/hosttemplates.cfg | grep -Ei 'name' | awk '{print $2}' > hostservicenames.txt
For example, grep 'local-service' to get a list of service_descriptions:

Code: Select all

grep -Eir 'local-service' /usr/local/nagios/etc/ -A 5 -B 5 | grep -Ei 'service_description' | awk '{print $3 $4 $5 $6 $7}'
Then loop the 'hostservicenames.txt' and 'servicenames.txt' would look something like this:

Code: Select all

cat servicenames.txt | while read LINE; do 'find /usr/local/nagios/etc/ -name "*.cfg" -type f exec grep -E '$LINE' {} \; | grep -Ei 'service_description' | awk '{print $3 $4 $5 $6 $7 $8}''; done
The option to | to 'wc -l' for the count

Others on the community forum might have a better workaround so please let us know.

Thanks,
Perry
Locked