How to Install NDOUtils in CentOS / RHEL and fix related error ?









Need urgent help to install NDOUtils in CentOS? 

This guide will help you.


Nagios Core will not start if we use an incompatible version. Therefore, it is important to install the latest version of NDOUtils.

NDOUtils allows you to export current and historical data from one or more Nagios instances to a MySQL database. Several community addons use this as one of their data sources. NDOUtils consists of a standalone daemon, a Nagios event broker, and several helper utilities.

Here at Ibmi Media, as part of our Server Management Services, we regularly help our Customers to perform CentOS queries.

In this context, we shall look into how to install NDOUtils in a Linux server.


Install NDOUtils in CentOS - Step by Step process to perform it ?

1. Begin by installing MySQL or MariaDB.

On CentOS 5.x/6.x|RHEL 5.x/6.x:

# yum install -y mysql mysql-server mysql-devel

On CentOS 7.x|RHEL 7.x:

# yum install -y mariadb mariadb-server mariadb-devel


2. Start and Configure MySQL/MariaDB

Before configuring MySQL/MariaDB, we must start the service and configure it to boot on startup.

On CentOS 5.x/6.x|RHEL 5.x/6.x

# service mysqld start

In order to check the status, we run:

# ps x | grep mysql | grep -v grep

The output will be similar to:

1969 pts/0 S 0:00 /bin/sh /usr/bin/mysqld_safe –datadir=/var/lib/mysql –socket=/var/lib/mysql/mysql.sock –pid-file=/var/run/mysqld/mysqld.pid –basedir=/usr –user=mysql

Then we configure it to start when the system boots:

# chkconfig –add mysqld
# chkconfig mysqld on

On CentOS 7.x|RHEL 7.x

# systemctl start mariadb.service

Ensure the status:

# ps ax | grep mysql | grep -v grep
2781 ? Ss 0:00 /bin/sh /usr/bin/mysqld_safe –basedir=/usr
2938 ? Sl 0:00 /usr/libexec/mysqld –basedir=/usr –datadir=/var/lib/mysql –plugin-dir=/usr/lib64/mysql/plugin –log-error=/var/log/mariadb/mariadb.log –pid-file=/var/run/mariadb/mariadb.pid –socket=/var/lib/mysql/mysql.sock

To Configure MariaDB to enable when the system boots:

# systemctl enable mariadb.service

Check the status:

# ps ax | grep mysql | grep -v grep
1292 ? Ss 0:00 /bin/sh /usr/bin/mysqld_safe
1760 ? Sl 0:00 /usr/sbin/mysqld –basedir=/usr –datadir=/var/lib/mysql –plugin-dir=/usr/lib64/mysql/plugin –log-error=/var/log/mysqld.log –pid-file=/var/run/mysqld/mysqld.pid –socket=/var/lib/mysql/mysql.sock

Then configure it to start when the system boots:

# systemctl enable mysqld.service


3. Define MySQL/MariaDB Root Password

Here, We define the password as 'mypassword'. We recommend using a strong password instead.

We use the 'single quotes' to define the boundaries of the password. This is extremely important when the password contains a space or special characters.

# /usr/bin/mysqladmin -u root password ‘mypassword’

Password Note:

Looking forward, we will see the password is provided using the -p argument like follows:

# mysql -u root -p'mypassword'

Make sure to NOT put a space between the -p and the 'mypassword'.


4. Create Database for Nagios

NDOUtils requires a Nagios database.

It will also have a dedicated user account, ndoutils with the password ndoutils_password.

The storage location of the database will be the default location that MySQL/MariaDB uses. We can change it if required.

To connect to the local MySQL/MariaDB database engine interface, we run:

# mysql -u root -p’mypassword’

Then we execute four commands (press Enter after each command):

CREATE DATABASE nagios DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
CREATE USER ‘ndoutils’@’localhost’ IDENTIFIED BY ‘ndoutils_password’;
GRANT USAGE ON *.* TO ‘ndoutils’@’localhost’ IDENTIFIED BY ‘ndoutils_password’ WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0;
GRANT ALL PRIVILEGES ON nagios.* TO ‘ndoutils’@’localhost’ WITH GRANT OPTION;

Later, exit the local MySQL/MariaDB database engine interface.

\q

To ensure the creation of the database, we run:

echo ‘show databases;’ | mysql -u ndoutils -p’ndoutils_password’ -h localhost
Database
information_schema
nagios
test


5. Linux Kernel Settings

NDOUtils uses the kernel message queue to transfer data from Nagios to NDOUtils.

In order to operate optimally, we will increase the default values the Kernel boots with.

Initially, create a backup copy of the /etc/sysctl.conf file:

# cp /etc/sysctl.conf /etc/sysctl.conf_backup

Then make the changes:

# sed -i ‘/msgmnb/d’ /etc/sysctl.conf
# sed -i ‘/msgmax/d’ /etc/sysctl.conf
# sed -i ‘/shmmax/d’ /etc/sysctl.conf
# sed -i ‘/shmall/d’ /etc/sysctl.conf
# printf “\n\nkernel.msgmnb = 131072000\n” >> /etc/sysctl.conf
# printf “kernel.msgmax = 131072000\n” >> /etc/sysctl.conf
# printf “kernel.shmmax = 4294967295\n” >> /etc/sysctl.conf
# printf “kernel.shmall = 268435456\n” >> /etc/sysctl.conf
# sysctl -e -p /etc/sysctl.conf
net.ipv4.ip_forward = 0
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.default.accept_source_route = 0
kernel.sysrq = 0
kernel.core_uses_pid = 1
net.ipv4.tcp_syncookies = 1
kernel.msgmnb = 131072000
kernel.msgmax = 131072000
kernel.shmmax = 4294967295
kernel.shmall = 268435456

This does not require a reboot, the last command ensures the new settings are active in the kernel.


6. Download NDOUtils Source

# cd /tmp
# wget -O ndoutils.tar.gz https://github.com/NagiosEnterprises/ndoutils/releases/download/ndoutils-2.1.3/ndoutils-2.1.3.tar.gz
# tar xzf ndoutils.tar.gz


7. Compile NDOUtils

# cd /tmp/ndoutils-2.1.3/
# ./configure
# make all


8. Install Binaries

# make install


9. Initialize Database

This prepares the database for NDOUtils:

# cd db/
# ./installdb -u ‘ndoutils’ -p ‘ndoutils_password’ -h ‘localhost’ -d nagios
# cd ..
DBD::mysql::db do failed: Table ‘nagios.nagios_dbversion’ doesn’t exist at ./installdb line 52.
** Creating tables for version 2.0.1
Using mysql.sql for installation…
** Updating table nagios_dbversion
Done!

Here, the first line says failed: Table ‘nagios.nagios_dbversion’ doesn’t exist. It is testing to make sure the database has not already been initialized.


10. Install Configuration Files

This installs the config files as well as configuring the MySQL/MariaDB credentials, so NDOUtils can connect to the database.

The two config files are:

i. /usr/local/nagios/etc/ndo2db.cfg

We define the following lines in this file:

db_user=ndoutils
db_pass=ndoutils_password

We should make sure the username and password are correct.


ii. /usr/local/nagios/etc/ndomod.cfg

There is no need for changes in this file.

Using the default username and password the following commands install the configuration files and make the changes.

# make install-config
# mv /usr/local/nagios/etc/ndo2db.cfg-sample /usr/local/nagios/etc/ndo2db.cfg
# sed -i ‘s/^db_user=.*/db_user=ndoutils/g’ /usr/local/nagios/etc/ndo2db.cfg
# sed -i ‘s/^db_pass=.*/db_pass=ndoutils_password/g’ /usr/local/nagios/etc/ndo2db.cfg
# mv /usr/local/nagios/etc/ndomod.cfg-sample /usr/local/nagios/etc/ndomod.cfg


11. Install Service/Daemon

This installs the service or daemon files and configures them to start on boot.


On CentOS 5.x/6.x|RHEL 5.x/6.x

# make install-init

On CentOS7.x|RHEL 7.x

# make install-init
# systemctl enable ndo2db.service


To Start Service/Daemon:

Different Linux distributions have different methods of starting the ndo2db service.


On CentOS5.x|RHEL 5.x

# service ndo2db start

On CentOS6.x|RHEL 6.x

# start ndo2db

On CentOS7.x|RHEL 7.x

# systemctl start ndo2db.service


12. Update Nagios to use NDO Broker Module

Here, we just need to add the following line to the nagios.cfg file:

broker_module=/usr/local/nagios/bin/ndomod.o config_file=/usr/local/nagios/etc/ndomod.cfg

The following commands will add it as well as an extra line that explains what the module is for:

# 3printf “\n\n# NDOUtils Broker Module\n” >> /usr/local/nagios/etc/nagios.cfg
# printf “broker_module=/usr/local/nagios/bin/ndomod.o config_file=/usr/local/nagios/etc/ndomod.cfg\n” >> /usr/local/nagios/etc/nagios.cfg


13. Restart Nagios

Moving ahead, we need to restart Nagios to use the NDO broker module.

Generally, different Linux distributions have different methods of restarting Nagios Core.

In addition, we will check the status of the Nagios service to ensure it is running after these changes.


On CentOS 5.x/6.x|RHEL 5.x/6.x

# service nagios restart
# service nagios status

On CentOS 7.x|RHEL 7.x

# systemctl restart nagios.service
# systemctl status nagios.service

Outputs:

CentOS 5.x/6.x|RHEL 5.x/6.x

nagios (pid 5345) is running…
CentOS 7.x|RHEL 7.x
● nagios.service – LSB: Starts and stops the Nagios monitoring server
Loaded: loaded (/etc/rc.d/init.d/nagios)
Active: active (running) since Fri 2021-03-26 12:31:00 AEDT; 22s ago


14. Check NDOUtils Is Working

There are a couple of different ways to ensure NDO2DB is working.

This command shows us Nagios is successfully loaded the NDO module:

# grep ndo /usr/local/nagios/var/nagios.log
[1475544660] ndomod: NDOMOD 2.1.1 (26-03-2021) Copyright (c) 2009 Nagios Core Development Team and Community Contributors
[1475544660] ndomod: Successfully connected to data sink. 0 queued items to flush.
[1475544660] ndomod registered for process data
[1475544660] ndomod registered for timed event data
[1475544660] ndomod registered for log data’
[1475544660] ndomod registered for system command data’
[1475544660] ndomod registered for event handler data’
[1475544660] ndomod registered for notification data’
[1475544660] ndomod registered for service check data’
[1475544660] ndomod registered for host check data’
[1475544660] ndomod registered for comment data’
[1475544660] ndomod registered for downtime data’
[1475544660] ndomod registered for flapping data’
[1475544660] ndomod registered for program status data’
[1475544660] ndomod registered for host status data’
[1475544660] ndomod registered for service status data’
[1475544660] ndomod registered for adaptive program data’
[1475544660] ndomod registered for adaptive host data’
[1475544660] ndomod registered for adaptive service data’
[1475544660] ndomod registered for external command data’
[1475544660] ndomod registered for aggregated status data’
[1475544660] ndomod registered for retention data’
[1475544660] ndomod registered for contact data’
[1475544660] ndomod registered for contact notification data’
[1475544660] ndomod registered for acknowledgement data’
[1475544660] ndomod registered for state change data’
[1475544660] ndomod registered for contact status data’
[1475544660] ndomod registered for adaptive contact data’
[1475544660] Event broker module ‘/usr/local/nagios/bin/ndomod.o’ initialized successfully.

Then this command shows us the database with populated data:

# echo ‘select * from nagios.nagios_logentries;’ | mysql -u ndoutils -p’ndoutils_password’
logentry_id instance_id logentry_time entry_time entry_time_usec logentry_type logentry_data realtime_data inferred_data_extracted
1 1 2021-03-26 12:31:00 2021-03-26 12:31:00 868450 262144 ndomod registered for log data’ 1 1
2 1 2021-03-26 12:31:00 2021-03-26 12:31:00 868462 262144 ndomod registered for system command data’ 1 1
3 1 2021-03-26 12:31:00 2021-03-26 12:31:00 868467 262144 ndomod registered for event handler data’ 1 1
4 1 2021-03-26 12:31:00 2021-03-26 12:31:00 868472 262144 ndomod registered for notification data’ 1 1
5 1 2021-03-26 12:31:00 2021-03-26 12:31:00 868479 262144 ndomod registered for service check data’ 1 1
6 1 2021-03-26 12:31:00 2021-03-26 12:31:00 868486 262144 ndomod registered for host check data’ 1 1
7 1 2021-03-26 12:31:00 2021-03-26 12:31:00 868491 262144 ndomod registered for comment data’ 11
8 1 2021-03-26 12:31:00 2021-03-26 12:31:00 868496 262144 ndomod registered for downtime data’11
9 1 2021-03-26 12:31:00 2021-03-26 12:31:00 869866 262144 ndomod registered for flapping data’11
10 1 2021-03-26 12:31:00 2021-03-26 12:31:00 869878 262144 ndomod registered for program status data’ 1 1
11 1 2021-03-26 12:31:00 2021-03-26 12:31:00 869884 262144 ndomod registered for host status data’ 1 1
12 1 2021-03-26 12:31:00 2021-03-26 12:31:00 869888 262144 ndomod registered for service status data’ 1 1
13 1 2021-03-26 12:31:00 2021-03-26 12:31:00 869893 262144 ndomod registered for adaptive program data’ 1 1
14 1 2021-03-26 12:31:00 2021-03-26 12:31:00 869897 262144 ndomod registered for adaptive host data’ 1 1
15 1 2021-03-26 12:31:00 2021-03-26 12:31:00 869902 262144 ndomod registered for adaptive service data’ 1 1
16 1 2021-03-26 12:31:00 2021-03-26 12:31:00 869906 262144 ndomod registered for external command data’ 1 1
17 1 2021-03-26 12:31:00 2021-03-26 12:31:00 869911 262144 ndomod registered for aggregated status data’ 1 1
18 1 2021-03-26 12:31:00 2021-03-26 12:31:00 869915 262144 ndomod registered for retention data’1 1
19 1 2021-03-26 12:31:00 2021-03-26 12:31:00 869920 262144 ndomod registered for contact data’ 11
20 1 2021-03-26 12:31:00 2021-03-26 12:31:00 871043 262144 ndomod registered for contact notification data’ 1 1
21 1 2021-03-26 12:31:00 2021-03-26 12:31:00 871055 262144 ndomod registered for acknowledgement data’ 1 1
22 1 2021-03-26 12:31:00 2021-03-26 12:31:00 871062 262144 ndomod registered for state change data’ 1 1
23 1 2021-03-26 12:31:00 2021-03-26 12:31:00 871067 262144 ndomod registered for contact status data’ 1 1
24 1 2021-03-26 12:31:00 2021-03-26 12:31:00 871072 262144 ndomod registered for adaptive contact data’ 1 1
25 1 2021-03-26 12:31:00 2021-03-26 12:31:00 871077 262144 Event broker module ‘/usr/local/nagios/bin/ndomod.o’ initialized successfully. 1 1
26 1 2021-03-26 12:31:00 2021-03-26 12:31:00 874858 262144 Successfully launched command file worker with pid 6026 1 1


Service Commands

Different Linux distributions have different methods of starting/stopping/ restarting/status ndo2db.


On CentOS 5.x|RHEL 5.x

# service ndo2db start
# service ndo2db stop
# service ndo2db restart
# service ndo2db status

On CentOS6.x|RHEL 6.x

# start ndo2db
# stop ndo2db
# restart ndo2db
# status ndo2db

On CentOS 7.x|RHEL 7.x

# systemctl start ndo2db.service
# systemctl stop ndo2db.service
# systemctl restart ndo2db.service
# systemctl status ndo2db.service


Method to resolve Common error encountered while installing NDOUtils in CentOS ?

Recently one of our customers installed ndoutils in a 64-bit CentOS server. However, when he start the service ndoutils, it shows:

Starting ndo2db:Support for the specified database server is either not yet supported, or was not found on your system.

The cause of this can be NDOUtils not getting the required MYSQL libraries.


In order to solve this, we need to ensure that the database is created properly.

We can compile ndoutils after installing mysql libraries. To do so, run the commands given below:

# yum whatprovides libmysqlclient*
1:mariadb-libs-5.5.56-2.el7.i686 : The shared libraries required for
: MariaDB/MySQL clients
Repo : base
Matched from:
Provides : libmysqlclient.so.18
Provides : libmysqlclient.so.18(libmysqlclient_16)
Provides : libmysqlclient.so.18(libmysqlclient_18)
# yum install mariadb-libs-5.5.56-2.el7.i686
# ./configure –prefix=$NAGIOS_HOME –enable-mysql –with-mysql-lib=/usr/lib64/mysql

1. If nagios home directory is /usr/local/nagios, then set NAGIOS_HOME to it, or set it as per the environment.

2. In CentOS, the requisite libraries are located at /usr/lib64/mysql.


To find out where it is in our system:

# ldconfig -v | grep mysql

Finally, rebuild ndoutils:

# make


[Stuck with Ubuntu errors? We'd be happy to assist. ]

Conclusion

This article covers how to install NDOUtils in CentOS. NDOUtils is an addon for Nagios Core that allows you to export current and historical data from one or more Nagios Core instances to a MySQL database. NDOUtils is included with Nagios XI. A source in Nagios Network Analyzer is the data collector. Outside of Nagios Network Analyzer a source is the location where data is originating from.


NDOUtils uses the kernel message queue for transferring the data from Nagios to NDOUtils. We are going to increase the default values the Kernel boots with to ensure it operates optimally.

1. Downloading NDOUtils Source

cd /tmp

wget -O ndoutils.tar.gz https://github.com/NagiosEnterprises/ndoutils/releases/download/ndoutils-2.1.3/ndoutils-2.1.3.tar.gz

tar xzf ndoutils.tar.gz

2. Compile NDOUtils

cd /tmp/ndoutils-2.1.3/

./configure

make all

3. Install Binaries

This step installs the binary files.

make install

4. Initialize Database

This prepares the database for NDOUtils.

cd db/

./installdb -u 'ndoutils' -p 'ndoutils_password' -h 'localhost' -d nagios

cd .. 




Keep In Touch

We hope to hear from you.

Accept File Type: jpg,jpeg,png,txt,pdf,doc,docx