The error, 'mysql_error out of range value for column' appears in the /var/log/messages file on the Nagios XI server.
It occurs when trying to offload the databases to an external server using a MySQL / MariaDB custom installation.
This error generally happens when MySQL / MariaDB server have the SQL Mode set to STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION.
Here at Ibmi Media, as part of our Server Management Services, we regularly help our Customers to perform several Nagios queries.
In this context, we shall look into how to fix this Nagios error.
The error in the /var/log/messages file on the Nagios XI server looks like this:
Apr 23 23:30:03 centosxx ndo2db: Error: mysql_query() failed for ‘INSERT INTO nagios_scheduleddowntime SET instance_id='1', downtime_type='1',
object_id='830', entry_time=FROM_UNIXTIME(1517155261), author_name='nagios_user', comment_data='AUTO: Standby Server', internal_downtime_id='804',
triggered_by_id='0', is_fixed='1', duration='31536000', scheduled_start_time=FROM_UNIXTIME(1517239800),
scheduled_end_time=FROM_UNIXTIME(1548775800) ON DUPLICATE KEY UPDATE instance_id='1', downtime_type='1', object_id='830',
entry_time=FROM_UNIXTIME(1517155261), author_name='nagios_user', comment_data='AUTO: Standby Server', internal_downtime_id='804', triggered_by_id='0',
is_fixed='1', duration='31536000', scheduled_start_time=FROM_UNIXTIME(1517239800), scheduled_end_time=FROM_UNIXTIME(1548775800)'
Apr 23 23:30:03 centosxx ndo2db: mysql_error: 'Out of range value for column 'duration' at row 1'
The error above may not be identical.
However, it usually follows the 'Out of range value for column message'.
It is the result of the MySQL/MariaDB server having the SQL Mode set to STRICT_TRANS_TABLES, NO_ENGINE_SUBSTITUTION.
Generally, this problem arises when we attempt to offload the databases to an external server using a MySQL/MariaDB custom installation.
With the following steps, we can identify what the SQL Mode is currently configured for.
Initially, we establish a terminal session to MySQL/MariaDB server hosting the Nagios XI databases.
Then we execute the following command:
mysql -u root -p’nagiosxi’ -e “SELECT @@GLOBAL.sql_mode;”
Replace the password of Nagios xi with the password of the root user on the database server.
The output shows us the SQL Mode has been defined:
+——————————————–+
| @@GLOBAL.sql_mode |
+——————————————–+
| STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION |
+——————————————–+
Output that shows that NO SQL Mode has been defined:
+——————-+
| @@GLOBAL.sql_mode |
+——————-+
| |
+——————-+
To resolve this issue, we need to define the SQL Mode in the MySQL/MariaDB my.cnf configuration file.
Initially, we have to stop the required services on the Nagios XI server:
On RHEL 7/8|CentOS 7/8|Debian|Ubuntu 16/18,
$ systemctl stop nagios.service
$ systemctl stop ndo2db.service
Then we have to edit the my.cnf configuration file on MySQL/MariaDB database server.
On RHEL 8|CentOS 8
vi /etc/my.cnf.d/mysql-server.cnf
On RHEL 6/7| CentOS 6/7
vi /etc/my.cnf
On Ubuntu 16/18
vi /etc/mysql/mysql.conf.d/mysqld.cnf
On Debian 9
vi /etc/mysql/mariadb.conf.d/50-server.cnf
Eventually, locate the [mysqld] section and check to see if there exists a sql_mode:
[mysqld]
# Recommended in standard MySQL setup
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
If it does, we need to replace it with the following.
If it does not exist, we need to add the following:
[mysqld]
sql_mode=””
Then we save and close the file.
Later, we need to restart the database service:
On RHEL 7|CentOS 7|Debian 9
$ systemctl restart mariadb.service
On Debian 8|Ubuntu 16/18
$ systemctl restart mysql.service
Once done, execute the following command to ensure the SQL Mode is no longer set:
mysql -u root -p’nagiosxi’ -e “SELECT @@GLOBAL.sql_mode;”
Replace the password of Nagios xi with that of the root user on the database server.
A successful output with NO SQL Mode looks like this:
+——————-+
| @@GLOBAL.sql_mode |
+——————-+
| |
+——————-+
If it is correct, we can start the services on Nagios XI:
RHEL 7|CentOS 7|Debian|Ubuntu 16/18
$ systemctl start ndo2db.service
$ systemctl start nagios.service
Then we check the /var/log/messages file to ensure the error messages no longer appear.
This article covers Nagios error, mysql_error out of range value for column which is evident in the /var/log/messages file on the Nagios XI server.
To resolve this issue you will need to define the SQL Mode in the MySQL / MariaDB my.cnf configuration file:
1. Locate the [mysqld] section and check to see if there is an sql_mode already defined:
[mysqld]
# Recommended in standard MySQL setup
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
2. If the sql_mode= line already exists you will need to replace it with the following.
If the line does not exist you will need to add the following line:
[mysqld]
sql_mode=""