Bulk service deletion using api very slow ?

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
vishfx
Posts: 134
Joined: Tue Apr 24, 2018 12:30 pm

Bulk service deletion using api very slow ?

Post by vishfx »

Hi,

NagiosXI 5.5.5 ( installed from nagiosxi repo)
OS: RHEL 7.5

Am doing bulk deletion of 2000+ services using parallel excecution nagiosxi api ( http://localhost/nagiosxi/api/v1/config/service )
It works, but the process seems to be extremely slow ( 20+ mins approx )

I do see sequential execution of the below script in the back-end :

Code: Select all

nagios   15937  0.0  0.0 113172  1200 ?        S    09:29   0:00 sh -c cd /usr/local/nagiosxi/scripts && ./ccm_delete_object.php -t service -i 8066
nagios   15938 31.0  0.4 438072 32260 ?        S    09:29   0:00 /usr/bin/php -q ./ccm_delete_object.php -t service -i 8066
Is there a way to speed this up ?

Please advise.

Regards,
Vish.
User avatar
cdienger
Support Tech
Posts: 5045
Joined: Tue Feb 07, 2017 11:26 am

Re: Bulk service deletion using api very slow ?

Post by cdienger »

Can you share the commands you're running against the API? Do they have the &applyconfig=1 option? This could be causing it to be slow if it is set for each command. It would be best to run most of the DELETE commands without this option and then run the final command with this option. Doing it this way removes the object and then applies the config once afterwards.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
vishfx
Posts: 134
Joined: Tue Apr 24, 2018 12:30 pm

Re: Bulk service deletion using api very slow ?

Post by vishfx »

Hi,

Below is logic used:

Code: Select all


# loop run thru deletion of 2000  services

loop for i = 1 to 2000
      curl -XDELETE  http://localhost/nagiosxi/api/v1/config/service?apikey=NAGIOSXI_APIKEY&host_name=service[i]&service_description=host[i]&force=1&pretty=1
loop ends

# runs applyconfig after services deletion
curl -XPOST   http://localhost/nagiosxi/api/v1/system/applyconfig?apikey=NAGIOSXI_APIKEY&pretty=1

Also, while performing this bulk removal noticed the below in the NagiosXI UI :

Code: Select all

Warning: mysqli_real_connect(): (HY000/1040): Too many connections in /usr/local/nagiosxi/html/db/adodb/drivers/adodb-mysqli.inc.php on line 125

Warning: mysqli_real_connect(): (HY000/1040): Too many connections in /usr/local/nagiosxi/html/db/adodb/drivers/adodb-mysqli.inc.php on line 125

Warning: mysqli_real_connect(): (08004/1040): Too many connections in /usr/local/nagiosxi/html/db/adodb/drivers/adodb-mysqli.inc.php on line 125
Databse Error
A database connection error has been detected, please follow the repair prompt below. If the issue persists, please contact Nagios support.
Run the following from the CLI as root to attempt to repair the DB:

/usr/local/nagiosxi/scripts/repair_databases.sh
Regards,
Vish.
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Bulk service deletion using api very slow ?

Post by lmiltchev »

Warning: mysqli_real_connect(): (HY000/1040): Too many connections in /usr/local/nagiosxi/html/db/adodb/drivers/adodb-mysqli.inc.php on line 125
I would recommend that you increase the max_connections value in the /etc/my.cnf file to a higher number. This should speed up your Nagios XI server (and the REST API commands). For more information, see our KB article on the topic:

https://support.nagios.com/kb/article/n ... s-513.html
Be sure to check out our Knowledgebase for helpful articles and solutions!
vishfx
Posts: 134
Joined: Tue Apr 24, 2018 12:30 pm

Re: Bulk service deletion using api very slow ?

Post by vishfx »

I followed the document.

But am getting the below error:

Code: Select all

mysql -uroot -pnagiosxi -e "show variables like 'max_connections';"
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Bulk service deletion using api very slow ?

Post by lmiltchev »

Did you change the root mysql password from the "default" (nagiosxi)? If you did, you would need to use the new password in the command.
Be sure to check out our Knowledgebase for helpful articles and solutions!
vishfx
Posts: 134
Joined: Tue Apr 24, 2018 12:30 pm

Re: Bulk service deletion using api very slow ?

Post by vishfx »

yes I managed to reset the mysql root password.

Have done the steps as per documents.

Still testing , will update shortly.
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Bulk service deletion using api very slow ?

Post by lmiltchev »

Sure, we will keep the thread open for the time being.
Be sure to check out our Knowledgebase for helpful articles and solutions!
vishfx
Posts: 134
Joined: Tue Apr 24, 2018 12:30 pm

Re: Bulk service deletion using api very slow ?

Post by vishfx »

Post changes from https://support.nagios.com/kb/article/n ... s-513.html

I no longer see the "Too many connections" error.

However, deletion of 2000+ services still takes a very long time.

Now I see the below:

Code: Select all

+-----------------+-------+
| Variable_name   | Value |
+-----------------+-------+
| max_connections | 818   |
+-----------------+-------+
+----------------------+-------+
| Variable_name        | Value |
+----------------------+-------+
| Max_used_connections | 819   |
+----------------------+-------+
Regards,
Vish.
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Bulk service deletion using api very slow ?

Post by lmiltchev »

How many users log in the Nagios XI server at the same time? This value (819) is quite high... You may need to increase the max_connections value in the /etc/my.cnf even more if you are reaching this number.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked