Changes to nagiosql DB not appearing in CCM

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
CWSI
Posts: 30
Joined: Tue Oct 28, 2014 7:41 am

Changes to nagiosql DB not appearing in CCM

Post by CWSI »

Hey,

I know this is surely not a supported way of doing what I'm trying to achieve, but having wrestled with it all day out of curiosity I'd love to hear what I'm missing if anybody can help.

So I wanted to add a custom variable to all of my hosts that would store the IP address I would expect the host's address to resolve to, so I can then do a DNS IP Match check. Problem is there are ~100 hosts so creating the custom variables from CCM didn't seem like it would be too enjoyable.

I'm pretty familiar with MySQL so thought I'd try and create a script that would pull all the hosts, lookup their current IP, then create a custom variable and store the IP there. At first I did this against the database NAGIOS, built a beautiful little script that INSERTed and UPDATEd as appropriate into the nagios_customvariables table, all worked perfectly but no sign of the IPs in CCM and doing an Apply Configuration wiped out all my IPs.

Then I found the NAGIOSQL database and figured I'd just got the wrong database, maybe NAGIOS is populated by NAGIOSQL. Quick re-work of the scipt to INSERT/UPDATE into the tbl_variabledefinition and tbl_lnkHostToVariabledefinition tables instead, again working and I can see the updates in the table, look perfect when comparing to existing custom variables added in the past. However again nothing shows up in CCM for these hosts.

Anybody any idea what I'm missing? I assume Nagios Core ultimately uses the .cfg files in /usr/local/nagios/etc/hosts/ to do its magic, but what happens between changes made in CCM through the GUI and these .cfg files getting created. Assuming I am happy to take the risk, how do I get XI to accept my new entries?


Cheers!
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: Changes to nagiosql DB not appearing in CCM

Post by tgriep »

You are correct, we don't support this.
The nagiosql database are where the tables that hold the configurations are held but without seeing how / where the data was inserted, we can't help much.
Try adding a custom variable using the CCM and search the MYSQL database for it so you could get an idea on the tables the data is inserted to.
Be sure to check out our Knowledgebase for helpful articles and solutions!
CWSI
Posts: 30
Joined: Tue Oct 28, 2014 7:41 am

Re: Changes to nagiosql DB not appearing in CCM

Post by CWSI »

Hey thanks for replying!

Did a mysqldump of the nagiosql table and variables added through CCM only appear in the same tables I am inserting into, but then there could be references to IDs elsewhere that are more difficult to search for like this unfortunately.

In short what I've done is -

Code: Select all

1. INSERT INTO tbl_variabledefinition (name, value, last_modified) VALUES ('_EXPECTEDIPADDRESS', '1.2.3.4', now());
2. INSERT INTO tbl_lnkHostToVariabledefinition (idMaster, idSlave) VALUES (687,310);
(Where 687 is a tbl_host.id I looked up earlier in the code, and 310 is the tbl_variabledefinition.id of the newly added row in SQL command 1 above)

Looking at these two tables after I run these SQL commands they are definitely going in correctly and aligning with other rows/columns, so I can only assume I'm either missing another table I need to update or this database is not the place I need to be working :).

Again any help/tips appreciated but do fully understand this is not supported so no obligation!
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: Changes to nagiosql DB not appearing in CCM

Post by tgriep »

I would guess that they are linked by the ID number.
One thing to try is to restart the nagios process or run the reconfigure_nagios.sh script after adding your entries so it will reload the information from the MYSQL database. That might be the key.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked