Bobcares

Install NDOUtils in CentOS/RHEL and fix a common error

by | Mar 27, 2021

Need help to install NDOUtils in CentOS? We can help you.

We make sure to install the latest version of NDOUtils as Nagios Core will not start if we use an incompatible version.

As part of our Server Management Services, we assist our customers with several CentOS queries.

Today, let us see how to install NDOUtils in a Linux server.

 

Install NDOUtils in CentOS

In order to begin, our Support Techs suggest installing MySQL or MariaDB.

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

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

CentOS 7.x|RHEL 7.x

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

 

Start and Configure MySQL/MariaDB

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

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

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

Configure it 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

 

Define MySQL/MariaDB Root Password

We define the password as ‘mypassword’. Our Support Techs suggest you have 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’.

 

Create Database

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

 

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.

 

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

 

Compile NDOUtils

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

 

Install Binaries

# make install

 

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.

 

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:

/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.

/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

 

Install Service/Daemon

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

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

# make install-init

CentOS7.x|RHEL 7.x

# make install-init
# systemctl enable ndo2db.service
  • Start Service/Daemon

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

CentOS5.x|RHEL 5.x

# service ndo2db start

CentOS6.x|RHEL 6.x

# start ndo2db

CentOS7.x|RHEL 7.x

# systemctl start ndo2db.service

 

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

 

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.

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

# service nagios restart
# service nagios status

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

 

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.

CentOS 5.x|RHEL 5.x

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

CentOS6.x|RHEL 6.x

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

CentOS 7.x|RHEL 7.x

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

 

Common error

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 the error? We’d be happy to assist]

 

Conclusion

To conclude, today we saw how our Support Techs install NDOUtils in CentOS.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

var google_conversion_label = "owonCMyG5nEQ0aD71QM";

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Never again lose customers to poor
server speed! Let us help you.