How to fix Event Data getting Stale in Nagios

 

In some Nagios version, our clients using Nagios reported a bug relating to event data. However, this bug has been patched and will be available in releases later. If you still experiencing the error and /or the Nagios services taking a long time to start that may be due to corruption in the MySQL table.

Our technical team support will fix event data getting stale in Nagios under our server management plan. You can also take assistance from our technical team support 24/7 will handle similar issues or any sort of installation and migration.

Fixing the event data getting Stale in Nagios.

To fix the issue there are two types of steps to be followed.

Repair MySQL database: By running the command in the command line as root user, now you can repair the Nagios and Nagiosql databases.

# /usr/local/nagiosxi/scripts/repairmysql.sh nagios
# /usr/local/nagiosxi/scripts/repairmysql.sh nagiosql
# /usr/local/nagiosxi/scripts/repairmysql.sh nagiosxi

Alternatively, you can also run the following command for Nagios XI 2014 and further versions:

# cd /usr/local/nagiosxi/scripts/
# ./repair_databases.sh

This repair both databases.

If you still experience an error which has shown below.

SQL: DELETE FROM nagios_logentries WHERE logentry_time < FROM_UNIXTIME(1293570334)

SQL: SQL Error [ndoutils] :</b> Table ‘./nagios/nagios_logentries’ is marked as crashed and last (automatic?) repair failed CLEANING ndoutils TABLE ‘notifications’…

You need to run the force repair on the tables by using the following commands.

RHEL 7|CentOS 7|Oracle Linux 7|Debian 9

# systemctl stop mariadb.service
# cd /var/lib/mysql/nagios
# myisamchk -r -f nagios_<corrupted_table>
# systemctl start mariadb.service
# rm -f /usr/local/nagiosxi/var/dbmaint.lock
# php /usr/local/nagiosxi/cron/dbmaint.php

Debian 8|Ubuntu 16/18

# systemctl stop mysql.service
# cd /var/lib/mysql/nagios
# myisamchk -r -f nagios_<corrupted_table>
# systemctl start mysql.service
# rm -f /usr/local/nagiosxi/var/dbmaint.lock
# php /usr/local/nagiosxi/cron/dbmaint.php

Repair MySQL tables

Stop following the services.

# service nagios stop
# service ndo2db stop
# service mysqld stop

Later, run the following repair script for MySQL tables.

# /usr/local/nagiosxi/scripts/repairmysql.sh nagios

Later copy and unzip the dbmaint file to

/usr/local/nagiosxi/cron/. This will overwrite the previous version.

# cd /tmp
# wget 
http://assets.nagios.com/downloads/nagiosxi/patches/dbmaint.zip
# unzip dbmaint.zip
# chmod +x dbmaint.php
# cp dbmaint.php /usr/local/nagiosxi/cron

Run the command

# service mysqld start
# rm -f /usr/local/nagiosxi/var/dbmaint.lock
# /usr/local/nagiosxi/cron/dbmaint.php

Start running the services after the script.

# service ndo2db start
# service Nagios start

However, if we see any error output from this script, similar to this one:

SQL: DELETE FROM nagios_logentries WHERE logentry_time < FROM_UNIXTIME(1293570334)

SQL: SQL Error [ndoutils] :</b> Table ‘./nagios/nagios_logentries’ is marked as crashed and last (automatic?) repair failedCLEANING ndoutils TABLE ‘notifications’…

Run the following force repair on the tables

# service mysqld stop
# cd /var/lib/mysql/nagios
# myisamchk -r -f nagios_<corrupted_table>
# service mysqld start
# rm -f /usr/local/nagiosxi/var/dbmaint.lock
/usr/local/nagiosxi/cron/dbmaint.php

Conclusion

In brief, you will get an apparent view of the cause for event data getting stale along with the stale in Nagios. You can also take our technical team support for any assistance.

Liked!! Share the post.

Share on facebook
Share on twitter
Share on linkedin
Share on reddit

FREE SERVER AUDITING

Get Auditing Report of Your Server for FREE!!

GET THIS ISSUE FIXED !!

$30/month

Server Management