Page 1 of 1

List services without notes

Posted: Tue Aug 06, 2019 10:59 am
by vmesquita
Hello!

We use the field "Notes" in Nagios Services to keep important information. Some services are lacking this field and we would like to know which. Do you know how we could do that? If it's not possible via the interface, a database query could also be used.

Re: List services without notes

Posted: Tue Aug 06, 2019 11:24 am
by mbellerue
A quick way to do this if you don't mind hopping into the database would be to run this query (assuming MySQL/MariaDB),

Code: Select all

connect nagios;
select host_object_id, display_name, notes from nagios_services where notes = "" or notes is null;
You should only need display_name and notes, but I added host_object_id in case it makes it easier to tie down the service check to the host.

Re: List services without notes

Posted: Tue Aug 06, 2019 1:04 pm
by vmesquita
This was almost what I wanted, however finding hosts by ID is really hard. Would there be a way to get a similar output but with a "Host Name" Field?

Re: List services without notes

Posted: Tue Aug 06, 2019 2:32 pm
by mbellerue
Sure, I should have made it this way to begin with. The original query is only viable in very small environments.

Code: Select all

select h.display_name, s.display_name, s.notes
from nagios_services as s
left join nagios_hosts as h
on s.host_object_id = h.host_object_id
where s.notes = ""
or s.notes is null
order by h.display_name;
This should do what you need it to do.

Re: List services without notes

Posted: Thu Aug 08, 2019 10:41 am
by vmesquita
Perfect! That's exactly what I needed.

Re: List services without notes

Posted: Thu Aug 08, 2019 10:45 am
by mbellerue
Excellent, glad we could help! Closing thread.