Page 1 of 1
extract info template
Posted: Mon Sep 20, 2021 7:52 am
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
Re: extract info template
Posted: Mon Sep 20, 2021 4:18 pm
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
Re: extract info template
Posted: Tue Sep 21, 2021 1:57 am
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
Re: extract info template
Posted: Tue Sep 21, 2021 12:55 pm
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