Bulk Modification Tool. It doesn't remove free variables.

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
jmsanesteban.sgre
Posts: 51
Joined: Thu Apr 23, 2020 6:46 am

Bulk Modification Tool. It doesn't remove free variables.

Post by jmsanesteban.sgre »

Hello community!

We are trying to use that bulk modification tool to delete two free variables: _SNMP_PORT and _SNMP_VERSION. Both free variables appear in the list, after we select the one we want to remove and search for its relationships, all the assets appear correctly. The next step is to check all and click "save" button. we receive a message: "Updates saved successfully!!" but nothing happens.

Based on the code /usr/local/nagiosxi/html/includes/components/bulkmodifications/bulkmodifications.inc.php this process should remove free variables and add lines in audit log, however after the process there is no new entries in audit log and the free variables are still linked with their assets.

Thanks in advance.

BR,
Juanma.
jmsanesteban.sgre
Posts: 51
Joined: Thu Apr 23, 2020 6:46 am

Re: Bulk Modification Tool. It doesn't remove free variables

Post by jmsanesteban.sgre »

Apart from reporting that problem, in order to delete those free variables, if I run a SQL delete command to remove the nagiosql.tbl_lnkHostToVariabledefinition entry should be enough, shouldn't it?

Should I delete also the information of the free variable in nagiosql.tbl_variabledefinition?

Thanks in advance.

BR,
Juanma.
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: Bulk Modification Tool. It doesn't remove free variables

Post by tgriep »

Is the server running the latest version of XI?

There was a fix added to the latest version for removing the Free Variables from the configurations.
- Fixed bulk modifications issue when trying to remove Free Variables [TPS#15653] -JO
If the server is not at the latest version, upgrade to XI version 5.8.7 and try to remove the Variables again.

Thank you.
Be sure to check out our Knowledgebase for helpful articles and solutions!
jmsanesteban.sgre
Posts: 51
Joined: Thu Apr 23, 2020 6:46 am

Re: Bulk Modification Tool. It doesn't remove free variables

Post by jmsanesteban.sgre »

Hi,

Yes, we've updated the server some weeks ago and it is on the lastest version.

After running the bulk modification tool a bunch of times, now it seems to work "properly". However the situation is a bit weird because the BMT is still showing those free variables in the list even when they are not linked to any host. There is no message notifying that no more host has that variable configured, it simply shows the relastionship button without any kind of message or notification, so you have to check it reviewing logs or tables in the database.

Thanks in advance.

BR,
Juanma.
jmsanesteban.sgre
Posts: 51
Joined: Thu Apr 23, 2020 6:46 am

Re: Bulk Modification Tool. It doesn't remove free variables

Post by jmsanesteban.sgre »

Hi all,

Code: Select all

# customvariablestatus_id, instance_id, object_id, status_update_time, has_been_modified, varname, varvalue
'8', '1', '988', '2022-03-08 13:08:56', '0', 'SNMP_PORT', '161'
'24', '1', '10705', '2022-03-08 13:08:56', '0', 'SNMP_PORT', '161'
'30', '1', '2112', '2022-03-08 13:08:56', '0', 'SNMP_PORT', '161'
'36', '1', '2119', '2022-03-08 14:19:35', '0', 'SNMP_PORT', '161'
'42', '1', '10714', '2022-03-08 13:08:56', '0', 'SNMP_PORT', '161'
'48', '1', '10718', '2022-03-08 13:08:56', '0', 'SNMP_PORT', '161'
'73', '1', '1003', '2022-03-08 13:08:56', '0', 'SNMP_PORT', '161'
'83', '1', '1027', '2022-03-08 13:08:56', '0', 'SNMP_PORT', '161'
In theory those entries shouldn't appear in the dabase or at least they must be out of date, those are the ones we "remove" using BMT.

BR,
Juanma.
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: Bulk Modification Tool. It doesn't remove free variables

Post by tgriep »

I did a bit of checking and when a variable is removed using the BMT tool, it is removing the variable from the nagiosql database, not from the nagios database.

When using the BMT tool, and the change is saved, and the Apply Configuration is ran, the variable is removed form the nagios_customvariablestatus which is the nagios database by the NDO-3 broker.
The NDO-3 broker is what is removing it from the nagios_customvariablestatus table when the Apply Configuration is ran, not the BMT tool.

There could be a configuration issue that is rolling back the change so make sure there is not a configuration error when the apply config is ran.

Or if your system is using the older NDOUTILS broker, I do not think that one removed it from the nagios database.

In the BMT tool, when you select one of the deleted variable and click on the fine relationship, does it show something?

Thank you.
Be sure to check out our Knowledgebase for helpful articles and solutions!
jmsanesteban.sgre
Posts: 51
Joined: Thu Apr 23, 2020 6:46 am

Re: Bulk Modification Tool. It doesn't remove free variables

Post by jmsanesteban.sgre »

Hi all,

Firstly thanks for your response. Understood.

There is a weird situation with the configuration, there is no problems with the configuration. The CCM snapshots look ok, however if I verify the files (CCM -> Tools -> Config File Management -> Verify files) a problem appears (Error: Cannot open config file '/usr/local/nagios/dell/config/templates/dell_contacts.cfg' for reading: Permission denied), even it has the correct permissions (getfacl):

Code: Select all

	# l /usr/local/nagios/dell/config/templates/dell_contacts.cfg
	4.0K -rw-rw----+ 1 nagios nagios 2.4K Nov 11  2020 /usr/local/nagios/dell/config/templates/dell_contacts.cfg

	# getfacl /usr/local/nagios/dell/config/templates/dell_contacts.cfg
	getfacl: Removing leading '/' from absolute path names
	# file: usr/local/nagios/dell/config/templates/dell_contacts.cfg
	# owner: nagios
	# group: nagios
	user::rw-
	user:nagios:rw-
	group::---
	mask::rw-
	other::---
I've checked the snapshots involved in the macros modifications, I can see the differences applied and there are some mistakes. During last days I've been removing hostmacros like: _snmp_port, _snmp_version and _os. The code below is extracted from the _os snapshot, as you can see the change was the macro _creation_date. The other wrong thing is that that snapshots was generated after deleting the other two macros (snmp_port and snmp_version) and applying the configuration, and those macros are still there.

Code: Select all

@@ -3,7 +3,7 @@
3	  # Hosts configuration file
4	  #
5	  # Created by: Nagios CCM 3.1.5
6	- # Date:       2022-03-09 15:40:44
7	  # Version:    Nagios Core 4.x
8	  #
9	  # --- DO NOT EDIT THIS FILE BY HAND --- 
@@ -29,7 +29,6 @@ define host {
29	      notifications_enabled    0
30	      icon_image               router.png
31	      statusmap_image          router.png
32	-     _creation_date           2021-02-03
33	      _snmp_community          *
34	      _snmp_port               161
35	      _snmp_version            2c 
3	  # Hosts configuration file
4	  #
5	  # Created by: Nagios CCM 3.1.5
6	+ # Date:       2022-03-09 16:04:56
7	  # Version:    Nagios Core 4.x
8	  #
9	  # --- DO NOT EDIT THIS FILE BY HAND --- 
29	      notifications_enabled    0
30	      icon_image               router.png
31	      statusmap_image          router.png
   
32	      _snmp_community          *
33	      _snmp_port               161
34	      _snmp_version            2c
In the BMT tool, when you select one of the deleted variable and click on the fine relationship, does it show something?
Now if I go to BMT and filter by '_os', '_snmp_port' or '_snmp_version', there is no result. I can filter using another field and the response takes a few seconds to show the objects with that macros.


If ndo2 is not updating correctly those tables, should I remove those macros manually from the database?

Edited to add some database count values to confirm what you've said:

select count(*) from nagios.nagios_customvariables where varname like '%SNMP_PORT%' or varname like '%SNMP_VERS%';
3849
SELECT count(*) FROM nagiosql.tbl_variabledefinition where name like '_SNMP_PORT%' or name like '_SNMP_VERS%';
4527

Thanks in advance.

BR,
Juanma.
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: Bulk Modification Tool. It doesn't remove free variables

Post by tgriep »

Your system has the Dell component installed on it and that adds the /usr/local/nagios/dell files and folders. It is not part of the Standard XI install.
Make sure all of the permissions for the folders / sub-folders are set to the apache user and nagios group can read and write to the files and folders.
The CCM uses the Apache user to update files so that is why the Apache user has to be the owner but the Dell files are not in the CCM and are considered static files.
The CCM has no issues with the files in the /usr/local/nagios/etc folder but the static Dell files / folders is causing the verify to fail.

Now if the verification fails, XI reverts the CCM to the last known snapshot and rolls back the changes so the verify has to be fixed.

Get the permissions fixed and then check to see if the objects get deleted from the nagios database and from the nagiosql database after checking the verify can run and the Apply Configuration fully runs.

Most systems use the NDO-3 broker so it should be updating the nagios database. I only brought up the ndoutils broker in case your server is running it.

Thank you.
Be sure to check out our Knowledgebase for helpful articles and solutions!
jmsanesteban.sgre
Posts: 51
Joined: Thu Apr 23, 2020 6:46 am

Re: Bulk Modification Tool. It doesn't remove free variables

Post by jmsanesteban.sgre »

Ok, I didn't know that for checking file permissions Nagios uses apache user.

Once I changed the permissions for that directory, the check permissions process worked perfectly, however, before the change, I didn't see any failed snapshot and once I commited the change some permission errors appeared. It it is strange because the group nagios has permissions so I can't understand that behavior, on top of that, there are extended permissions for nagios user.

Anyways, it seems not to be the problem, in order to get back the focus I will quote myself after the output from "applying the changes".


Before:

Code: Select all

Nagios Core 4.4.6
Copyright (c) 2009-present Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 2020-04-28
License: GPL

Website: https://www.nagios.org
Reading configuration data...
   Read main config file okay...
   Read object config files okay...

Running pre-flight check on configuration data...

Checking objects...
	Checked 4863 services.
	Checked 3233 hosts.
	Checked 958 host groups.
	Checked 7 service groups.
	Checked 107 contacts.
	Checked 9 contact groups.
	Checked 190 commands.
	Checked 117 time periods.
	Checked 0 host escalations.
	Checked 0 service escalations.
Checking for circular paths...
	Checked 3233 hosts
	Checked 0 service dependencies
	Checked 0 host dependencies
	Checked 117 timeperiods
Checking global event handlers...
Checking obsessive compulsive processor commands...
Checking misc settings...

Total Warnings: 0
Total Errors:   0

Things look okay - No serious problems were detected during the pre-flight check

After

Code: Select all

Nagios Core 4.4.6
Copyright (c) 2009-present Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 2020-04-28
License: GPL

Website: https://www.nagios.org
Reading configuration data...
   Read main config file okay...
Error: Could not open config directory '/usr/local/nagios/dell/config' for reading.
   Error processing object config files!


***> One or more problems was encountered while processing the config files...

     Check your configuration file(s) to ensure that they contain valid
     directives and data definitions.  If you are upgrading from a previous
     version of Nagios, you should be aware that some variables/definitions
     may have been removed or modified in this version.  Make sure to read
     the HTML documentation regarding the config files, as well as the
     'Whats New' section to find out what has changed.
Now if I go to BMT and filter by '_os', '_snmp_port' or '_snmp_version', there is no result. I can filter using another field and the response takes a few seconds to show the objects with that macros.


If ndo2 is not updating correctly those tables, should I remove those macros manually from the database?

Edited to add some database count values to confirm what you've said:

select count(*) from nagios.nagios_customvariables where varname like '%SNMP_PORT%' or varname like '%SNMP_VERS%';
3849
SELECT count(*) FROM nagiosql.tbl_variabledefinition where name like '_SNMP_PORT%' or name like '_SNMP_VERS%';
4527
Regarding NDO3, we've opened another thread about it because we've updated nagios to the latest version but that component was not updated: https://support.nagios.com/forum/viewto ... 16&t=64675

Meanwhile should I add some queries to delete customvariables from the database? becasue as far as I understand, that problem won't be fixed due to the new ndo version, will it?

Thanks in advance.

BR,
Juanma.
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: Bulk Modification Tool. It doesn't remove free variables

Post by tgriep »

Are you using the Dell tool in Nagios?

Can you provide more details about the extended permissions for nagios user.

Could you post or PM me your Nagios XI System Profile so we can review it?
To get your system profile. Login to the Nagios XI GUI using a web browser.
Click the "Admin" > "System Profile" Menu
Click the "Download Profile" button
Save the profile.zip file and upload it to the ticket by clicking the "choose item" link at the bottom of the menu.

Also, run the following as root and post or PM me the /tmp/info.txt file.

Code: Select all

chage -l nagios >/tmp/info.txt
grep nag /etc/group >>/tmp/info.txt
ls -alR /usr/local/nagios >>/tmp/info.txt
Open a root shell to the Nagios server, run the following command and upload the /tmp/nagiosql.sql to the ticket so I can see the setting in the CCM.

Code: Select all

mysqldump nagiosql -u root -pnagiosxi >/tmp/nagiosql.sql
About removing the data from the database. We do not support or suggest doing any data manipulation of the database.
If there are any errors, data loss, that could render the system unstable.

Thank you.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked