nagiosql_delete_service.php doesn't work after offloading DB

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
thur686
Posts: 66
Joined: Mon Jan 12, 2015 2:33 pm

nagiosql_delete_service.php doesn't work after offloading DB

Post by thur686 »

Hello,

I have many, many services and hosts to remove. Far too many to remove in the CCM. I have followed the 'Automated_Host_Management.pdf' in the past to use 'nagiosql_delete_service.php' and 'nagiosql_delete_host.php' to remove hosts in bulk.

However these scripts no longer work on a Nagios server with an offloaded database. In the past, before offloading the DB, I could use:

Code: Select all

./nagiosql_delete_service.php –-config=LOC_MASShost_1
Now not much happens, aside from simply returning the following:

Code: Select all

URL: https://localhost/nagiosxi/includes/components/ccm/
Usage: ./nagiosql_delete_service.php [--id=<service id>] [--config=<config_name>]
We are currently on Nagios XI 5.4.6
User avatar
lmiltchev
Former Nagios Staff
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: nagiosql_delete_service.php doesn't work after offloadin

Post by lmiltchev »

Is "LOC_MASShost_1" a valid config name? When you go to the CCM > Services, do you see "LOC_MASShost_1" under the "Config Name" column? Can you verify that you haven't skipped/missed a step while following the document below?

https://assets.nagios.com/downloads/nag ... Server.pdf
Be sure to check out our Knowledgebase for helpful articles and solutions!
thur686
Posts: 66
Joined: Mon Jan 12, 2015 2:33 pm

Re: nagiosql_delete_service.php doesn't work after offloadin

Post by thur686 »

Sorry, "LOC_MASShost_1" is just an example. I actually copied it from the DOC https://assets.nagios.com/downloads/nag ... gement.pdf.

Our service configurations are actually formatted as "computername.domain_service".
User avatar
lmiltchev
Former Nagios Staff
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: nagiosql_delete_service.php doesn't work after offloadin

Post by lmiltchev »

So, when you go to the CCM > Services, do you see the config name that you are passing to the command (--config=<config_name>) under the "Config Name" column?

As far as I know, the function that is used to connect to the DB grabs the dbserver/user/pwd values from the "/usr/local/nagiosxi/html/config.inc.php" file. If you followed the doc for offloading mysql, these values should be set. It is strange that it is not working for you... I haven't been able to recreate the issue in house but I believe it is possible that you are not passing a valid config name.
Be sure to check out our Knowledgebase for helpful articles and solutions!
thur686
Posts: 66
Joined: Mon Jan 12, 2015 2:33 pm

Re: nagiosql_delete_service.php doesn't work after offloadin

Post by thur686 »

Yes, the config names are there in the CCM, but the delete scripts cannot find them in the 'nagiosql' database.

I looked at "/usr/local/nagiosxi/html/config.inc.php" and I can see our DB info added to the ndoutils & the nagiosql sections. The dbserver, user and pwd values are all correct.

I even just tried the 'nagiosql_delete_host.php' script with the same result, "...Unable find host in nagiosql database".
User avatar
lmiltchev
Former Nagios Staff
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: nagiosql_delete_service.php doesn't work after offloadin

Post by lmiltchev »

When you are passing the config name, you are NOT including the ".cfg" extension, do you?

For example, if you had a config called "test.cfg", you would run:

Code: Select all

./nagiosql_delete_service.php --config=test
If you used "--config=test.cfg" instead, you would get an error.

BTW, can you connect to the nagiosql db on the remote box from the Nagios XI server?

Example:

Code: Select all

echo 'show tables;' | mysql -t -unagiosql -pnagiosql nagiosql -h x.x.x.x
+--------------------------------------------+
| Tables_in_nagiosql                         |
+--------------------------------------------+
| tbl_command                                |
| tbl_contact                                |
| tbl_contactgroup                           |
| tbl_contacttemplate                        |
| tbl_domain                                 |
| tbl_host                                   |
| tbl_hostdependency                         |
| tbl_hostescalation                         |
| tbl_hostextinfo                            |
| tbl_hostgroup                              |
| tbl_hosttemplate                           |
| tbl_info                                   |
| tbl_lnkContactToCommandHost                |
| tbl_lnkContactToCommandService             |
| tbl_lnkContactToContactgroup               |
| tbl_lnkContactToContacttemplate            |
| tbl_lnkContactToVariabledefinition         |
| tbl_lnkContactgroupToContact               |
| tbl_lnkContactgroupToContactgroup          |
| tbl_lnkContacttemplateToCommandHost        |
| tbl_lnkContacttemplateToCommandService     |
| tbl_lnkContacttemplateToContactgroup       |
| tbl_lnkContacttemplateToContacttemplate    |
| tbl_lnkContacttemplateToVariabledefinition |
| tbl_lnkHostToContact                       |
| tbl_lnkHostToContactgroup                  |
| tbl_lnkHostToHost                          |
| tbl_lnkHostToHostgroup                     |
| tbl_lnkHostToHosttemplate                  |
| tbl_lnkHostToVariabledefinition            |
| tbl_lnkHostdependencyToHost_DH             |
| tbl_lnkHostdependencyToHost_H              |
| tbl_lnkHostdependencyToHostgroup_DH        |
| tbl_lnkHostdependencyToHostgroup_H         |
| tbl_lnkHostescalationToContact             |
| tbl_lnkHostescalationToContactgroup        |
| tbl_lnkHostescalationToHost                |
| tbl_lnkHostescalationToHostgroup           |
| tbl_lnkHostgroupToHost                     |
| tbl_lnkHostgroupToHostgroup                |
| tbl_lnkHosttemplateToContact               |
| tbl_lnkHosttemplateToContactgroup          |
| tbl_lnkHosttemplateToHost                  |
| tbl_lnkHosttemplateToHostgroup             |
| tbl_lnkHosttemplateToHosttemplate          |
| tbl_lnkHosttemplateToVariabledefinition    |
| tbl_lnkServiceToContact                    |
| tbl_lnkServiceToContactgroup               |
| tbl_lnkServiceToHost                       |
| tbl_lnkServiceToHostgroup                  |
| tbl_lnkServiceToServicegroup               |
| tbl_lnkServiceToServicetemplate            |
| tbl_lnkServiceToVariabledefinition         |
| tbl_lnkServicedependencyToHost_DH          |
| tbl_lnkServicedependencyToHost_H           |
| tbl_lnkServicedependencyToHostgroup_DH     |
| tbl_lnkServicedependencyToHostgroup_H      |
| tbl_lnkServicedependencyToService_DS       |
| tbl_lnkServicedependencyToService_S        |
| tbl_lnkServiceescalationToContact          |
| tbl_lnkServiceescalationToContactgroup     |
| tbl_lnkServiceescalationToHost             |
| tbl_lnkServiceescalationToHostgroup        |
| tbl_lnkServiceescalationToService          |
| tbl_lnkServicegroupToService               |
| tbl_lnkServicegroupToServicegroup          |
| tbl_lnkServicetemplateToContact            |
| tbl_lnkServicetemplateToContactgroup       |
| tbl_lnkServicetemplateToHost               |
| tbl_lnkServicetemplateToHostgroup          |
| tbl_lnkServicetemplateToServicegroup       |
| tbl_lnkServicetemplateToServicetemplate    |
| tbl_lnkServicetemplateToVariabledefinition |
| tbl_lnkTimeperiodToTimeperiod              |
| tbl_logbook                                |
| tbl_mainmenu                               |
| tbl_service                                |
| tbl_servicedependency                      |
| tbl_serviceescalation                      |
| tbl_serviceextinfo                         |
| tbl_servicegroup                           |
| tbl_servicetemplate                        |
| tbl_session                                |
| tbl_session_locks                          |
| tbl_settings                               |
| tbl_submenu                                |
| tbl_timedefinition                         |
| tbl_timeperiod                             |
| tbl_user                                   |
| tbl_variabledefinition                     |
+--------------------------------------------+
Be sure to check out our Knowledgebase for helpful articles and solutions!
thur686
Posts: 66
Joined: Mon Jan 12, 2015 2:33 pm

Re: nagiosql_delete_service.php doesn't work after offloadin

Post by thur686 »

Thanks lmiltchev. We are not passing the .cfg when using the service and host delete scripts.

I can also connect to the remote DB from the Nagios server and show tables. I compared the tables to the example and they match up.
User avatar
lmiltchev
Former Nagios Staff
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: nagiosql_delete_service.php doesn't work after offloadin

Post by lmiltchev »

Try restarting the services:

Code: Select all

service nagios stop
service ndo2db restart
service nagios start
then deleting the service in question:

Code: Select all

cd /usr/local/nagiosxi/scripts
./nagiosql_delete_service.php --config=<config name>
If this doesn't work, try finding the service ID by running:

Code: Select all

echo "select id from tbl_service where config_name='<config name>' and service_description='<service description>';" | mysql -t -u<username> -p<password> nagiosql -h <ip address of the remote mysql server>
Next, try deleting the service via the id:

Code: Select all

./nagiosql_delete_service.php --id=<ID>
Did this work?
Be sure to check out our Knowledgebase for helpful articles and solutions!
thur686
Posts: 66
Joined: Mon Jan 12, 2015 2:33 pm

Re: nagiosql_delete_service.php doesn't work after offloadin

Post by thur686 »

I can query the database to find the ID using the code below, but the delete script still cannot delete it, even by ID.

I tried services and hosts with the same result.

I can manually delete services and hosts in the CCM without a problem. It's just taking forever and a working script would be ideal.
dwhitfield
Former Nagios Staff
Posts: 4583
Joined: Wed Sep 21, 2016 10:29 am
Location: NoLo, Minneapolis, MN
Contact:

Re: nagiosql_delete_service.php doesn't work after offloadin

Post by dwhitfield »

What version of XI are you running? There were recently some improvements to offline dbs. You might try upgrading.

Either way, can you PM me your Profile? You can download it by going to Admin > System Config > System Profile and click the ***Download Profile*** button towards the top. If for whatever reason you *cannot* download the profile, please put the output of View System Info (5.3.4+, Show Profile if older) in the thread (that will at least get us some info). This will give us access to many of the logs we would otherwise ask for individually. If security is a concern, you can unzip the profile take out what you like, and then zip it up again. We may end up needing something you remove, but we can ask for that specifically.

After you PM the profile, please update this thread. Updating this thread is the only way for it to show back up on our dashboard.
Locked