Well, the table tbl_service in the nagiosql database has a field called "config_name" which stores the flat file name. You would probably need to match the config name to the host name, or pick an arbitrary name as long as it is consistent. Observe:
Grab id, flat file name, and service description
Code: Select all
mysql> select id,config_name,service_description from tbl_service;
+----+---------------+-------------------------+
| id | config_name | service_description |
+----+---------------+-------------------------+
| 1 | localhost | PING |
| 2 | localhost | Root Partition |
| 3 | localhost | Current Users |
| 4 | localhost | Total Processes |
| 5 | localhost | Current Load |
| 6 | localhost | Swap Usage |
| 7 | localhost | SSH |
| 8 | localhost | HTTP |
| 10 | localhost | Always Fails |
| 14 | 192.168.4.163 | Ping |
| 15 | 192.168.4.163 | Weblogic Heap |
| 16 | 192.168.4.163 | Weblogic Thread Pool |
| 17 | 192.168.4.163 | Weblogic Transactions |
| 18 | 192.168.4.163 | Weblogic Connections |
| 19 | 192.168.4.163 | Weblogic Queue |
| 71 | Arduino | Security Alert - Window |
+----+---------------+-------------------------+
16 rows in set (0.00 sec)
Layout of table matching services to hosts
Code: Select all
mysql> describe tbl_lnkServiceToHost;
+----------+---------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------+---------+------+-----+---------+-------+
| idMaster | int(11) | NO | PRI | NULL | |
| idSlave | int(11) | NO | PRI | NULL | |
+----------+---------+------+-----+---------+-------+
2 rows in set (0.00 sec)
Grab all service<->host associations (service is Master, host is Slave)
Code: Select all
mysql> select * from tbl_lnkServiceToHost;
+----------+---------+
| idMaster | idSlave |
+----------+---------+
| 1 | 1 |
| 2 | 1 |
| 3 | 1 |
| 4 | 1 |
| 5 | 1 |
| 6 | 1 |
| 7 | 1 |
| 8 | 1 |
| 10 | 1 |
| 14 | 4 |
| 15 | 4 |
| 16 | 4 |
| 17 | 4 |
| 18 | 4 |
| 19 | 4 |
| 71 | 6 |
+----------+---------+
16 rows in set (0.00 sec)
Grab all host ids and names
Code: Select all
mysql> select id,host_name from tbl_host;
+----+-----------+
| id | host_name |
+----+-----------+
| 1 | localhost |
| 4 | WebLogic |
| 6 | Arduino |
+----+-----------+
3 rows in set (0.00 sec)
Now you can see which services match to which hosts, and start coming up with names. There is a better way to do this with joins but that is a bit more tricky and I'd like to save those big guns for if you can't script this out.