Custom Variables Storage

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
rajasegar
Posts: 1018
Joined: Sun Mar 30, 2014 10:49 pm

Custom Variables Storage

Post by rajasegar »

Can you update where is the custom variables stored for hosts & services?
We need to update about 4000 hosts and need to automate it.

Thanks
5 x Nagios 5.6.9 Enterprise Edition
RHEL 6 & 7
rrdcached & ramdisk optimisation
jdalrymple
Skynet Drone
Posts: 2620
Joined: Wed Feb 11, 2015 1:56 pm

Re: Custom Variables Storage

Post by jdalrymple »

Do you mean where in the database? I believe it's in the table tbl_variabledefinition.

Of course this information comes with the disclaimer that we NEVER recommend directly manipulating the database, and if you do go against that recommendation do verify your backups are working beforehand.
User avatar
WillemDH
Posts: 2320
Joined: Wed Mar 20, 2013 5:49 am
Location: Ghent
Contact:

Re: Custom Variables Storage

Post by WillemDH »

Make a script to update to retrieve the host config file, add the required free variables and put it in the import folder. Then loop through all your hosts and do the same?
Nagios XI 5.8.1
https://outsideit.net
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Custom Variables Storage

Post by tmcdonald »

jdalrymple wrote:Do you mean where in the database? I believe it's in the table tbl_variabledefinition.
This is correct.
jdalrymple wrote:Of course this information comes with the disclaimer that we NEVER recommend directly manipulating the database, and if you do go against that recommendation do verify your backups are working beforehand.
This is very true. Not only is it something we can't recommend, but anything that might break as a result would not be covered by our support contract. This is not always clear to end users, and admittedly we don't always make it so because we tell people how to do just the sort of thing we don't want them to. My stance is that anyone who is going to manipulate the DB directly is going to do so regardless of what we say, so I'd rather give them the correct information and a stern reminder, than have them not know ahead of time and end up with a broken system.
Former Nagios employee
rajasegar
Posts: 1018
Joined: Sun Mar 30, 2014 10:49 pm

Re: Custom Variables Storage

Post by rajasegar »

tmcdonald wrote:
jdalrymple wrote:Do you mean where in the database? I believe it's in the table tbl_variabledefinition.
This is correct.
jdalrymple wrote:Of course this information comes with the disclaimer that we NEVER recommend directly manipulating the database, and if you do go against that recommendation do verify your backups are working beforehand.
This is very true. Not only is it something we can't recommend, but anything that might break as a result would not be covered by our support contract. This is not always clear to end users, and admittedly we don't always make it so because we tell people how to do just the sort of thing we don't want them to. My stance is that anyone who is going to manipulate the DB directly is going to do so regardless of what we say, so I'd rather give them the correct information and a stern reminder, than have them not know ahead of time and end up with a broken system.
Noted. You guys said the same when I asked about the Notes component storage.
Going through the UI for 4000 times and adding variables is simply not practical.
We will test this out in dev and take it from there.

Thanks for the info.
5 x Nagios 5.6.9 Enterprise Edition
RHEL 6 & 7
rrdcached & ramdisk optimisation
rajasegar
Posts: 1018
Joined: Sun Mar 30, 2014 10:49 pm

Re: Custom Variables Storage

Post by rajasegar »

jdalrymple wrote:Do you mean where in the database? I believe it's in the table tbl_variabledefinition.

Of course this information comes with the disclaimer that we NEVER recommend directly manipulating the database, and if you do go against that recommendation do verify your backups are working beforehand.
Thanks for the info.
5 x Nagios 5.6.9 Enterprise Edition
RHEL 6 & 7
rrdcached & ramdisk optimisation
rajasegar
Posts: 1018
Joined: Sun Mar 30, 2014 10:49 pm

Re: Custom Variables Storage

Post by rajasegar »

WillemDH wrote:Make a script to update to retrieve the host config file, add the required free variables and put it in the import folder. Then loop through all your hosts and do the same?
This will work but updating the DB is a lot easier.
Thanks anyway.
5 x Nagios 5.6.9 Enterprise Edition
RHEL 6 & 7
rrdcached & ramdisk optimisation
rajasegar
Posts: 1018
Joined: Sun Mar 30, 2014 10:49 pm

Re: Custom Variables Storage

Post by rajasegar »

FYI.

Connect to DB
mysql --user=nagiosql--password=nagiosql --database=nagiosql --host=MyDBIP
User ID & PWD stored in /usr/local/nagiosxi/html/config.inc.php

List all tables
mysql> show tables;

Show table definition
mysql> desc tbl_variabledefinition;

Show all variables in host definition;
SELECT a.id, a.host_name, b.idSlave, c.id, c.name, c.value
FROM tbl_host a, tbl_lnkHostToVariabledefinition b, tbl_variabledefinition c
WHERE a.id = b.idMaster
AND b.idSlave = c.id
ORDER BY a.id, b.idSlave, c.id;

To show variables defined in other places, replace tbl_host & tbl_lnkHostToVariabledefinition with any of the following master & link tables
tbl_lnkContactToVariabledefinition
tbl_lnkContacttemplateToVariabledefinition
tbl_lnkHostToVariabledefinition
tbl_lnkHosttemplateToVariabledefinition
tbl_lnkServiceToVariabledefinition
tbl_lnkServicetemplateToVariabledefinition

Hope this info helps.

Please close this ticket.
Thanks.
5 x Nagios 5.6.9 Enterprise Edition
RHEL 6 & 7
rrdcached & ramdisk optimisation
Locked