Repairing The Nagios Xi Databases

1685793731
ADVERTISEMENT
Repairing the nagios xi databases

File Name: Repairing_The_Nagios_XI_Database.pdf

File Size: 236.98 KB

File Type: Application/pdf

Last Modified: 5 years

Status: Available

Last checked: 2 days ago!

This Document Has Been Certified by a Professional

100% customizable

Language: English

We recommend downloading this file onto your computer

Summary

The Industry Standard In Infrastructure Monitoring
Nagios XI Repairing The Nagios XI Databases
Purpose
This document describes how to repair the databases used by Nagios XI

Target Audience
This document is intended for use by Nagios XI Administrators

Additional Documents
Nagios administrators are urged to read the following document related to the Nagios XI database:
• Nagios XI Database Optimization
◦ https://assets.nagios.com/downloads/nagiosxi/docs/Nagios-XI-Database-Optimization.pdf
Problem Symptoms
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. The steps outlined
below allow you to repair the MySQL database tables used by Nagios XI

Important Information
Historically MySQL has been the database used by Nagios XI, however in RHEL/CentOS 7.x onwards
MariaDB is used instead of MySQL. MariaDB is simply a fork of the MySQL database, the commands used
are the same however some of the output differs slightly

Separate to this, Nagios XI versions before 5.x used a PostgreSQL database for storing the Nagios XI
preferences. In Nagios XI 5.x this was moved over to the MySQL database

1295 Bandana Blvd N, St. Paul, MN 55108 [email protected] US: 1-888-624-4671 INTL: 1-651-204-9102
www.nagios.com
© 2017 Nagios Enterprises, LLC. All rights reserved. Nagios, the Nagios logo, and Nagios graphics are the servicemarks, trademarks, or
registered trademarks owned by Nagios Enterprises. All other servicemarks and trademarks are the property of their respective owner. Page 1 / 7
Updated – July, 2017
The Industry Standard In Infrastructure Monitoring
Nagios XI Repairing The Nagios XI Databases
The following applies:
• Fresh installations of Nagios XI will no longer use PostgreSQL
• Upgrading a previous version of Nagios XI will continue to use the PostgreSQL database
This is highlighted where necessary in the steps below. If you are unsure, execute the following command on
your Nagios XI server:
awk '/"nagiosxi" => array\(/{getline;print}' /usr/local/nagiosxi/html/config.inc.php
Which should output one of the following:
"dbtype" => 'pgsql',
or
"dbtype" => 'mysql',
Database Backups
Before attempting to repair database tables, you should ensure that you have recent backups of the database
in case of catastrophic failure in the recovery process. Nagios XI includes a MySQL backup script that places
database backups in the /store/backups/mysql/ directory of the Nagios XI server. Verify that this
directory contains recent and valid backups before continuing with the repair process

The following documentation explains in detail the backup and restore steps in Nagios XI:
https://assets.nagios.com/downloads/nagiosxi/docs/Backing-Up-And-Restoring-Nagios-XI.pdf
1295 Bandana Blvd N, St. Paul, MN 55108 [email protected] US: 1-888-624-4671 INTL: 1-651-204-9102
www.nagios.com
© 2017 Nagios Enterprises, LLC. All rights reserved. Nagios, the Nagios logo, and Nagios graphics are the servicemarks, trademarks, or
registered trademarks owned by Nagios Enterprises. All other servicemarks and trademarks are the property of their respective owner. Page 2 / 7
Updated – July, 2017
The Industry Standard In Infrastructure Monitoring
Nagios XI Repairing The Nagios XI Databases
Repairing MySQL Tables
Establish a terminal session to your Nagios XI server as the root user

Versions Of Nagios XI 2014 Onwards
Execute the following command:
/usr/local/nagiosxi/scripts/repair_databases.sh
This script which will automatically repair all databases (nagios, nagiosql) (nagiosxi in XI 5.x). Once the
script has completed, please review all of the output generated for any errors. For any errors please refer to
the troubleshooting section in this document

Versions Of Nagios XI BEFORE 2014
Stop the MySQL database server with the following command:
service mysqld stop
Run the Nagios XI database repair script with the following command:
/usr/local/nagiosxi/scripts/repairmysql.sh nagios
The script will check and repair all tables in the nagios MySQL database. This process may take several
minutes to complete, depending on the size of your database. You can re-run the repair script on the
nagiosql database. Once the script has completed, please review all of the output generated for any errors

For any errors please refer to the troubleshooting section in this document

Once the script has completed, start the MySQL database server with the following command:
service mysqld start
1295 Bandana Blvd N, St. Paul, MN 55108 [email protected] US: 1-888-624-4671 INTL: 1-651-204-9102
www.nagios.com
© 2017 Nagios Enterprises, LLC. All rights reserved. Nagios, the Nagios logo, and Nagios graphics are the servicemarks, trademarks, or
registered trademarks owned by Nagios Enterprises. All other servicemarks and trademarks are the property of their respective owner. Page 3 / 7
Updated – July, 2017
The Industry Standard In Infrastructure Monitoring
Nagios XI Repairing The Nagios XI Databases
Troubleshooting
If you receive an error, similar to this one:
SQL: DELETE FROM nagios_logentries WHERE logentry_time < FROM_UNIXTIME(1293570334)
SQL: SQL Error [ndoutils] : Table './nagios/nagios_logentries' is marked as
crashed and last (automatic?) repair failedCLEANING ndoutils TABLE 'notifications'..

You may need to run a force repair on the tables:
service mysqld stop
cd /var/lib/mysql/nagios
myisamchk -r -f nagios_
service mysqld start
rm -f /usr/local/nagiosxi/var/dbmaint.lock
php /usr/local/nagiosxi/cron/dbmaint.php
If you receive an error, similar to this one:
Error : Incorrect file format 'nagios_systemcommands'
error : Corrupt
You will need to execute the following command to fix the table:
service mysqld start
echo 'repair table nagios_systemcommands use_frm;' | mysql -t -u root -pnagiosxi nagios
service mysqld restart
Then check the log file for errors:
1295 Bandana Blvd N, St. Paul, MN 55108 [email protected] US: 1-888-624-4671 INTL: 1-651-204-9102
www.nagios.com
© 2017 Nagios Enterprises, LLC. All rights reserved. Nagios, the Nagios logo, and Nagios graphics are the servicemarks, trademarks, or
registered trademarks owned by Nagios Enterprises. All other servicemarks and trademarks are the property of their respective owner. Page 4 / 7
Updated – July, 2017
The Industry Standard In Infrastructure Monitoring
Nagios XI Repairing The Nagios XI Databases
MySQL
tail -n 20 /var/log/mysqld.log
MariaDB
tail -n 20 /var/log/mariadb/mariadb.log
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 logentries and notifications tables in the nagios
MySQL database:
mysql -u ndoutils [email protected] nagios -e 'TRUNCATE TABLE nagios_logentries'
mysql -u ndoutils [email protected] nagios -e 'TRUNCATE TABLE nagios_notifications'
After you truncate tables, you should repeat the repair process outlines in the previous section

If you receive this error:
myisamchk: error: 'nagios_commenthistory.MYI' is not a MyISAM-table
This means that the MYSQL tables are in the wrong format and they need to be converted. Before you
convert them, do a full backup of the server in case there are any issues. To convert all InnoDB Tables to
MyISAM (all databases) follow these steps:
Execute the following command to enter the mysql command interface (nagiosxi is the default root
MySQL/MariaDB password):
mysql -u root -p'nagiosxi'
1295 Bandana Blvd N, St. Paul, MN 55108 [email protected] US: 1-888-624-4671 INTL: 1-651-204-9102
www.nagios.com
© 2017 Nagios Enterprises, LLC. All rights reserved. Nagios, the Nagios logo, and Nagios graphics are the servicemarks, trademarks, or
registered trademarks owned by Nagios Enterprises. All other servicemarks and trademarks are the property of their respective owner. Page 5 / 7
Updated – July, 2017
The Industry Standard In Infrastructure Monitoring
Nagios XI Repairing The Nagios XI Databases
You are now logged into the mysql command interface, this is indicated by the mysql> OR MariaDB
[(none0]> prompt

Run the following command to convert all of the tables (this is one long command that is wrapped over two
lines):
SELECT CONCAT('ALTER TABLE ', TABLE_SCHEMA, '.', TABLE_NAME, '
engine=MyISAM;') FROM information_schema.TABLES WHERE ENGINE = 'InnoDB';
Now you can exit the mysql command interface:
quit
After this, you can run the following to repair the MYSQL databases

mysqlcheck -f -r -u root -pnagiosxi --all-databases
Once the command has completed, please review all of the output generated for any errors

1295 Bandana Blvd N, St. Paul, MN 55108 [email protected] US: 1-888-624-4671 INTL: 1-651-204-9102
www.nagios.com
© 2017 Nagios Enterprises, LLC. All rights reserved. Nagios, the Nagios logo, and Nagios graphics are the servicemarks, trademarks, or
registered trademarks owned by Nagios Enterprises. All other servicemarks and trademarks are the property of their respective owner. Page 6 / 7
Updated – July, 2017
The Industry Standard In Infrastructure Monitoring
Nagios XI Repairing The Nagios XI Databases
If you have run out of disk space on your Nagios XI server, the following KB article can provide solutions to
resolving this issue:
https://support.nagios.com/kb/article.php?id=26
Once you've resolved the disk space issue you should run the repair database script again

Finishing Up
This completes the documentation on repairing the Nagios XI databases

If you have additional questions or other support related questions, please visit us at our Nagios Support
Forums:
https://support.nagios.com/forum
The Nagios Support Knowledgebase is also a great support resource:
https://support.nagios.com/kb
1295 Bandana Blvd N, St. Paul, MN 55108 [email protected] US: 1-888-624-4671 INTL: 1-651-204-9102
www.nagios.com
© 2017 Nagios Enterprises, LLC. All rights reserved. Nagios, the Nagios logo, and Nagios graphics are the servicemarks, trademarks, or
registered trademarks owned by Nagios Enterprises. All other servicemarks and trademarks are the property of their respective owner. Page 7 / 7
Updated – July, 2017

Error : Corrupt You will need to execute the following command to fix the table: service mysqld start echo 'repair table nagios_systemcommands use_frm;' mysql -t -u root -pnagiosxi …

Download Now

Documemt Updated

ADVERTISEMENT

Popular Download

ADVERTISEMENT

Frequently Asked Questions

How do i repair my nagios database?

Establish a terminal session to your Nagios XI server as the root user. This script which will automatically repair all databases (nagios, nagiosql) (nagiosxi in XI 5.x +). Once the script has completed, please review all of the output generated for any errors.

What database does nagios xi use?

Historically MySQL has been the database used by Nagios XI, however in RHEL/CentOS 7.x onwards MariaDB is used instead of MySQL. MariaDB is simply a fork of the MySQL database, the commands used are the same however some of the output differs slightly.

What should i do before attempting to repair a database table?

Before attempting to repair database tables, you should ensure that you have recent backups of the databasein case of catastrophic failure in the recovery process. Nagios XI includes a MySQL backup script that places database backups in the /store/backups/mysql/ directory of the Nagios XI server. Verify that this.