Page 1 of 1
Query Mysql for Information?
Posted: Tue Sep 10, 2013 12:35 pm
by matt.uebel
I am interested in scripting out various queries, so that I can gain information from my Nagios XI installation. For instance, all members of some particular hostgroup.
What would be a good starting point for this? I have looked at the exchange, but the plugins seem to be more involved with checking the health of mysql DB, rather than querying it.
Re: Query Mysql for Information?
Posted: Tue Sep 10, 2013 12:50 pm
by abrist
You can do direct queries, bu that will require a decent amount of sql knowledge. XI does feature a backend api that exports XML:
http://assets.nagios.com/downloads/nagi ... nd_API.pdf
http://exchange.nagios.org/directory/Do ... de/details
For example, the following url:
http://<nagios server ip>/nagiosxi/backend/?cmd=gethoststatus&hostgroup=<hostgroup>&brevity=3
(replace <nagios server ip> and <hostgroup> with the proper values)
Will output xml resembling:
Code: Select all
<hoststatus id="44653">
<instance_id>1</instance_id>
<host_id>294</host_id>
<name>ipv6 centy test</name>
<display_name>ipv6 centy test</display_name>
<alias>yep</alias>
<status_update_time>2013-09-10 10:45:49</status_update_time>
<status_text>/bin/ping6 -n -U -w 10 -c 5 fe80:0000:0000:0000:20c:29ff:fe84:58ed</status_text>
<status_text_long>CRITICAL - Could not interpret output from ping command\n</status_text_long>
<current_state>1</current_state>
</hoststatus>
etc . . .
Essentially, the url above will output a list of hosts in the hostgroup using brevity=3 which just reduces the amount of information reported about each host.
Add a ticket number from the document above and you can call this xml through ajax (among other methods) from another system.
Just let me know if you have any further questions . . .