Database structure

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
chrisfritz
Posts: 23
Joined: Thu Dec 09, 2010 11:53 am

Database structure

Post by chrisfritz »

Thank you for the information. Is there any detailed information on the table structure of the hosts. What I need to do is write a perl or php script to pull certain information from the database. On the nagios MySQL database the nagios_objects table displays the object_id, instance_id, objecttype_id, name1, name2, is_active fields. What I am trying to do is display the snmp name, ip address and whether it is up or down on a seperate web page for public viewing. I want to pull the snmp name and display that to the external page due to the possibilty of the name being changed and would like it to always reflect the snmp value. Any detailed information on the database structure would be appreciated. We have received the quote and I am currently working on a PO to purchase the software. Thank you.
tonyyarusso
Posts: 1128
Joined: Wed Mar 03, 2010 12:38 pm
Location: St. Paul, MN, USA
Contact:

Re: Database structure

Post by tonyyarusso »

There isn't much in the way of documentation on this, but hopefully I can get you started. The following query will let you get the current status of hosts:

Code: Select all

[root@demo ~]# mysql -u root -pnagiosxi nagios -e "SELECT nagios_hosts.display_name, nagios_hosts.address, nagios_hoststatus.current_state, nagios_hoststatus.status_update_time, nagios_hoststatus.output FROM nagios_hosts LEFT JOIN nagios_hoststatus ON nagios_hosts.host_object_id=nagios_hoststatus.host_object_id;"
+----------------------+----------------------+---------------+---------------------+-----------------------------------------------------------------------+
| display_name         | address              | current_state | status_update_time  | output                                                                |
+----------------------+----------------------+---------------+---------------------+-----------------------------------------------------------------------+
| www.oreilly.com      | www.oreilly.com      |             0 | 2010-12-23 10:53:13 | HTTP OK - HTTP/1.1 301 Moved Permanently - 0.421 second response time | 
| www.nagios.com       | www.nagios.com       |             0 | 2010-12-23 10:51:02 | HTTP OK HTTP/1.1 200 OK - 35149 bytes in 0.812 seconds                | 
| support.nagios.com   | support.nagios.com   |             0 | 2010-12-23 10:54:22 | HTTP OK HTTP/1.1 200 OK - 20736 bytes in 0.562 seconds                | 
| nagios.org           | nagios.org           |             0 | 2010-12-23 10:53:22 | HTTP OK HTTP/1.1 200 OK - 42712 bytes in 0.939 seconds                | 
| localhost            | 127.0.0.1            |             0 | 2010-12-23 10:54:02 | OK - 127.0.0.1: rta 0.039ms, lost 0%                                  | 
| Ubuntu Desktop       | 192.168.5.89         |             0 | 2010-12-23 10:52:22 | OK - 192.168.5.89: rta 19.958ms, lost 0%                              | 
| library.nagios.com   | library.nagios.com   |             0 | 2010-12-23 10:55:52 | HTTP OK HTTP/1.1 200 OK - 29122 bytes in 1.716 seconds                | 
| community.nagios.org | community.nagios.org |             0 | 2010-12-23 10:55:12 | HTTP OK HTTP/1.1 200 OK - 46986 bytes in 1.116 seconds                | 
| Tony Desktop         | 192.168.5.9          |             0 | 2010-12-23 10:51:52 | OK - 192.168.5.9: rta 0.977ms, lost 0%                                | 
| Cube switch          | 192.168.5.42         |             0 | 2010-12-23 10:51:02 | OK - 192.168.5.42: rta 2.356ms, lost 0%                               | 
| ESX Server           | 192.168.5.32         |             0 | 2010-12-23 10:51:22 | OK - 192.168.5.32: rta 0.071ms, lost 0%                               | 
| Server Room          | 192.168.5.254        |             0 | 2010-12-23 10:53:22 | OK - 192.168.5.254: rta 1.318ms, lost 0%                              | 
+----------------------+----------------------+---------------+---------------------+-----------------------------------------------------------------------+
The name defined and made available through SNMP can be acquired by passing the results for 'address' to the PHP snmpget function, requesting the 'SNMPv2-MIB::sysName.0' object_id.
Tony Yarusso
Technical Services
___
TIES
Web: http://ties.k12.mn.us/
chrisfritz
Posts: 23
Joined: Thu Dec 09, 2010 11:53 am

Re: Database structure

Post by chrisfritz »

Thank you very much, that is a great help and very much appreciated.
tonyyarusso
Posts: 1128
Joined: Wed Mar 03, 2010 12:38 pm
Location: St. Paul, MN, USA
Contact:

Re: Database structure

Post by tonyyarusso »

No problem.
Tony Yarusso
Technical Services
___
TIES
Web: http://ties.k12.mn.us/
Locked