nook24 / statusengine

New PHP based MySQL Backend for Naemon and Nagios 4 + responsive web frontend
https://statusengine.org/
GNU General Public License v2.0
16 stars 8 forks source link

Gab in servicestatus_id due to MySQL behavior #40

Closed nook24 closed 7 years ago

nook24 commented 7 years ago

MySQL increases the value of auto increment by every single ON DUPLICATE KEY UPDATEor REPLACE query. Due to this, you can easily hit the auto increment max value.

So, i would recommend to truncate the prefix_hoststatus and prefix_servicestatus tables on every restart of the monitoring core, inside of the FINISH_OBJECT_DUMP event handler...

See: https://www.percona.com/blog/2011/11/29/avoiding-auto-increment-holes-on-innodb-with-insert-ignore/

This is an example of a system with 60 services. example

Patch

--- cakephp/app/Console/Command/StatusengineLegacyShell.php
+++ cakephp/app/Console/Command/StatusengineLegacyShell.php
@@ -549,9 +549,15 @@ class StatusengineLegacyShell extends AppShell{
                                $this->activateObjects($this->dumpIds);

                                //Remove deprecated status records
-                               CakeLog::info('Delete deprecated status records');
-                               $this->removeDeprecatedHoststatusRecords($this->dumpIds);
-                               $this->removeDeprecatedServicestatusRecords($this->dumpIds);
+                               //Removed due to: https://www.percona.com/blog/2011/11/29/avoiding-auto-increment-holes-on-innodb-with-insert-ignore/
+                               //CakeLog::info('Delete deprecated status records');
+                               //$this->removeDeprecatedHoststatusRecords($this->dumpIds);
+                               //$this->removeDeprecatedServicestatusRecords($this->dumpIds);
+
+                               CakeLog::info('Truncate table hoststatus');
+                               $this->Hoststatus->truncate();
+                               CakeLog::info('Truncate table servicestatus');
+                               $this->Servicestatus->truncate();

                                $this->dumpIds = [];