Page 1 of 1

Custom Variables Storage

Posted: Wed Oct 07, 2015 2:49 am
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

Re: Custom Variables Storage

Posted: Wed Oct 07, 2015 10:18 am
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.

Re: Custom Variables Storage

Posted: Wed Oct 07, 2015 10:23 am
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?

Re: Custom Variables Storage

Posted: Wed Oct 07, 2015 3:07 pm
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.

Re: Custom Variables Storage

Posted: Wed Oct 07, 2015 6:38 pm
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.

Re: Custom Variables Storage

Posted: Wed Oct 07, 2015 6:39 pm
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.

Re: Custom Variables Storage

Posted: Wed Oct 07, 2015 6:41 pm
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.

Re: Custom Variables Storage

Posted: Wed Oct 07, 2015 7:20 pm
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.