Nagios XI MySQL export query help

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
highness
Posts: 192
Joined: Thu May 01, 2014 4:25 pm

Nagios XI MySQL export query help

Post by highness »

Had a business unit request a CSV export of all of our hosts, their respective services as well as the command arguments in MySQL. The query works well and looks like this:

Code: Select all

select a.alias, b.display_name, b.check_command_args from nagios.nagios_hosts a, nagios.nagios_services b where ((a.host_object_id = b.host_object_id)) order by a.alias INTO OUTFILE "/tmp/hosts_n_services.csv" fields terminated by ',' enclosed by '"' lines terminated by '\n';
I just got another request to add the host group that each host is assigned to this query - after poking around for a bit, I'm not seeing an easy way to include that. Is there any MySQL gurus who could give me an assist on this query?
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Nagios XI MySQL export query help

Post by tmcdonald »

This is a bit out of scope for standard support, but look into the tbl_lnkHostToHostgroup table in the nagiosql database. That is what maintains the relations in the CCM between a host and the hostgroups it is in. There is also tbl_lnkHostgroupToHost in case the host was added from the hostgroup edit page. There are also templates to consider, which is why this is such a weird query to write.
Former Nagios employee
highness
Posts: 192
Joined: Thu May 01, 2014 4:25 pm

Re: Nagios XI MySQL export query help

Post by highness »

Understood that this isn't a normal support question, but I am *VERY* appreciative for the assist, Trevor.

Please feel free to lock this topic.
Locked