Bulk Change "config name"

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
User avatar
BanditBBS
Posts: 2474
Joined: Tue May 31, 2011 12:57 pm
Location: Scio, OH
Contact:

Bulk Change "config name"

Post by BanditBBS »

I want to rename a bunch of services that are currently named "_multiple_hosts" from when I imported them, Bulk renaming tool doesn't cover the config name change, only the service name. Is there a way to do this in bulk, like a mysql update command, will that hurt anything? If that will work, anyone want to write the command out for me so I don't have to spend an hour figuring out the proper context :)
2 of XI5.6.14 Prod/DR/DEV - Nagios LogServer 2 Nodes
See my projects on the Exchange at BanditBBS - Also check out my Nagios stuff on my personal page at Bandit's Home and at github
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Bulk Change "config name"

Post by lmiltchev »

When you rename a host via the Bulk Renaming Tools, it would rename the config file name for the services as well. All configs will be renamed in "/usr/local/nagios/etc/hosts" and "/usr/local/nagios/etc/services".
Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
BanditBBS
Posts: 2474
Joined: Tue May 31, 2011 12:57 pm
Location: Scio, OH
Contact:

Re: Bulk Change "config name"

Post by BanditBBS »

This isn't for any host. This is the "config name" field on a bunch of services that have hostgroups assigned to them. I want to change "_multiple_hosts" to something that describes the services better.
Capture.JPG
You do not have the required permissions to view the files attached to this post.
2 of XI5.6.14 Prod/DR/DEV - Nagios LogServer 2 Nodes
See my projects on the Exchange at BanditBBS - Also check out my Nagios stuff on my personal page at Bandit's Home and at github
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Bulk Change "config name"

Post by tmcdonald »

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.
Former Nagios employee
Locked