Changes to nagiosql DB not appearing in CCM
Posted: Wed Jan 06, 2016 2:41 pm
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!
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!