This is a cache of https://support.nagios.com/kb/article/nagios-xi-crashed-database-tables-24.html. It is a snapshot of the page at 2025-05-14T00:01:21.595+0000.
Nagios <strong>xi</strong> - Crashed Database Tables
Home » Categories » Products » Nagios xi » Troubleshooting » Common Problems

Nagios xi - Crashed Database Tables

Crashed Database Tables

If you experience high load on your Nagios xi server and the MySQL process (mysqld) appears to be consuming large amounts of CPU, it may be a symptom of one or more crashed tables. In order to find out if you have crashed database tables or any other errors, you can check the mysqld.log:

tail /var/log/mysqld.log

 

You may see entries similar to this one:

150110  9:05:01 [ERROR] /usr/libexec/mysqld: Table './nagios/nagios_logentries' is marked as crashed and last (automatic?) repair failed    

 

 

Possible Causes

Database corruption is usually caused by power outages, running out of disk space or improper shutting down the Nagios xi server. Nagios is constantly reading from and writing to the mysql database, so killing the mysqld process (i.e. with "kill -9" or "killall mysqld") will lead to crashed tables.

Many time users would right-click on the Nagios xi VM in VMWare Workstation/ESxi/Vsphere and select "Power Off". This is wrong - it is like pulling off the power cord. The correct way for shutting down the Nagios xi server would be to issue the following command in the command line:

shutdown -h now

 

If the Nagios xi machine has insufficient disk space then you may see errors like this when the repair database script is run:

/usr/local/nagiosxi/scripts/repairmysql.sh: line 59: 11735 Segmentation fault (core dumped) $cmd $t --sort_buffer_size=256M
Timeout error occurred trying to start MySQL Daemon.
Starting mysqld: [FAILED]

 

 

Possible Solutions

You can repair the nagios and nagiosql databases by running the following commands in the command line as the root user:

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

 

Alternatively, if you are running Nagios xi 2014 onwards, you can use:

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

which will actually repair both databases (nagios and nagiosql) (and nagiosxi in xi 5.x).

If you receive an error, 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 failed CLEANING ndoutils TABLE 'notifications'...

 

You may need to run a force repair on the tables using commands below:

 

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

RHEL 8/9 | CentOS Stream 8/9 | Oracle Linux 8/9 | Debian 10+

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

 

Ubuntu 18/20/22

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

 

In certain instances, it may be necessary to truncate (empty) one or more tables. The following commands provide examples of how to truncate both the nagios_logentries and nagios_notifications tables in the nagios MySQL database:

mysql -u ndoutils -pn@gweb nagios -e 'TRUNCATE TABLE nagios_logentries'
mysql -u ndoutils -pn@gweb nagios -e 'TRUNCATE TABLE nagios_notifications'

 

Important: Running these commands will clear all entries from the affected tables. After you truncate tables, you should repeat the repair process outlined above.

Further information: Repairing The Nagios xi Database

 

If you have run out of disk space on your Nagios xi server, the following KB article can provide solutions to resolving this issue:

Running Out Of Disk Space On The Nagios xi VM

Once you've resolved the disk space issue you should run the repair database script again.

 

 

Final Thoughts

For any support related questions please visit the Nagios Support Forums at:

http://support.nagios.com/forum/



Special Offer For Knowledgebase Visitors! Get a huge discount on Nagios Log Server by clicking below.

Get 60% Off Nagios Log Server!

Did you know? Nagios provides complete monitoring of: Windows, Linux, UNIX, Servers, Websites, SNMP, DHCP, DNS, Email, Storage, Files, Apache, IIS, EC2, and more!

5 (3)
Article Rating (3 Votes)
Rate this article
  • Icon PDFExport to PDF
  • Icon MS-WordExport to MS Word
Attachments Attachments
There are no attachments for this article.
Related Articles RSS Feed
Slack Notifications Stopped Working
Viewed 4992 times since Wed, Mar 18, 2020
PHPMailer - Troubleshooting Using Debug Logging
Viewed 37173 times since Tue, Aug 14, 2018
Nagios xi - Empty Screen for Wizard, Component, Dashlet
Viewed 8075 times since Wed, Jan 27, 2016
Nagios xi - Login Screen Keeps Redirecting To Itself
Viewed 7412 times since Wed, Jan 27, 2016
Nagios xi - Event Data Is Stale
Viewed 5983 times since Wed, Jan 27, 2016
Nagios xi - Host Still Visible After Deletion (Ghost Hosts)
Viewed 12372 times since Tue, Jan 27, 2015
Nagios xi - SourceGuardian Errors 2009R1.2C
Viewed 4782 times since Tue, Feb 2, 2016
Installation errors on customized corporate builds of CentOS or RHEL
Viewed 13355 times since Tue, Jan 26, 2016
Nagios xi - MRTG Reports SNMP_Session Errors
Viewed 5874 times since Wed, Jul 27, 2016
Nagios xi - Last Check Time Not Updating
Viewed 20701 times since Tue, Jan 6, 2015