Often, get reports that Nagios core is not working due to an outdated version of NDOUtils
From this blog, you will get an apparent view regarding the installation and configuration of NDOUtils in Ubuntu as a part of our server management plan. You can also take assistance from our technical team support 24/7 for further Migration and configuration.
Follow the steps to install NDOUtils in Ubuntu
Steps to install NDOUtils in Ubuntu
First is installing the MySQL by following the below command.
$ sudo apt-get update
$ sudo apt-get install -y mysql-server libmysqlclient-dev libdbd-mysql-perl
Provide the root password if it prompts.
For checking: if MySQL is running well then use the following:
$ ps ax | grep mysql | grep -v grep
Output
8142 ? Ssl 0:01 /usr/sbin/mysqld
Creating Database
NDOUtils requires creating a database known as Nagios.
Create a user account called ndoutils with the password ndoutils_password.
The storage location of the database will be the default location that MySQL uses.
Run the command that will connect the local MySQL database engine interface.
$ mysql -u root -p'mypassword'
Later, execute the four commands one by one.
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 ;
Exit from the local MySQL database engine interface.
Try to ensure that the database has created by running the following command.
$ echo 'show databases;' | mysql -u ndoutils -p'ndoutils_password' -h localhost
Output:
Database
information_schema
nagios
test
Modifying Linux Kernel Settings
Transferring the data from the Nagios to the NDOUtils by using the kernal message queue.
Here we will increase the default values the Kernel boots with to ensure it operates optimally.
Create a backup of /etc/sysctl.conf file:
$ sudo cp /etc/sysctl.conf /etc/sysctl.conf_backup
Execute the following commands
$ sudo sed -i '/msgmnb/d' /etc/sysctl.conf
$ sudo sed -i '/msgmax/d' /etc/sysctl.conf
$ sudo sed -i '/shmmax/d' /etc/sysctl.conf
$ sudo sed -i '/shmall/d' /etc/sysctl.conf
$ sudo sh -c 'printf "\n\nkernel.msgmnb = 131072000\n" >> /etc/sysctl.conf'
$ sudo sh -c 'printf "kernel.msgmax = 131072000\n" >> /etc/sysctl.conf'
$ sudo sh -c 'printf "kernel.shmmax = 4294967295\n" >> /etc/sysctl.conf'
$ sudo sh -c 'printf "kernel.shmall = 268435456\n" >> /etc/sysctl.conf'
$ sudo sysctl -e -p /etc/sysctl.conf
It’s not required to reboot the system as the last command displayed on the screen shows that the new settings are active in the kernel.
Downloading NDOUtils Source
Run the command for downloading NDOUtils
$ cd /tmp
$ wget -O ndoutils.tar.gz
https://github.com/NagiosEnterprises/ndoutils/archive/ndoutils-2.1.3.tar.gz
$ tar xzf ndoutils.tar.gz
Compiling NDOUtils
Run the command for Compiling NDOUtils.
$ cd /tmp/ndoutils-ndoutils-2.1.3/
$ sudo ./configure
$ sudo make all
Installing Binaries
Run the command to install the Binaries
$ sudo make install
Initializing Database
This prepares the database for NDOUtils.
$ cd db/
$ sudo ./installdb -u 'ndoutils' -p 'ndoutils_password' -h 'localhost' -d nagios
$ cd ..
Output
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!
Installing Configuration Files
The two config files are:
1./usr/local/nagios/etc/ndo2db.cfg
The following lines are defined in this file:
db_user=ndoutils
db_pass=ndoutils_password
Ensure that username and password are correct.
2. /usr/local/nagios/etc/ndomod.cfg
No changes are required in the file.
Use the default username and the password,run the command to install the configuration files.
$ sudo make install-config
$ sudo mv /usr/local/nagios/etc/ndo2db.cfg-sample /usr/local/nagios/etc/ndo2db.cfg
$ sudo sh -c 'sed -i 's/^db_user=.*/db_user=ndoutils/g' /usr/local/nagios/etc/ndo2db.cfg'
$ sudo sh -c 'sed -i 's/^db_pass=.*/db_pass=ndoutils_password/g' /usr/local/nagios/etc/ndo2db.cfg'
$ sudo mv /usr/local/nagios/etc/ndomod.cfg-sample /usr/local/nagios/etc/ndomod.cfg
Install Service/Daemon
For Ubuntu 13.x/14.x
$ sudo make install-init
For Ubuntu 15.x/16.x/17.x
$ sudo make install-init
$ sudo systemctl enable ndo2db.service
Start Service/Daemon
Different Linux distributions have different methods of starting the ndo2db service.
For Ubuntu 13.x/14.x
$ sudo service ndo2db start
For Ubuntu 15.x/16.x/17.x
$ sudo systemctl start ndo2db.service
Updating Nagios To Use NDO Broker Module
Direct the Nagios to use the broker module
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 that line as well as an extra line that explains what the module is for.
$ sudo sh -c 'printf "\n\n# NDOUtils Broker Module\n" >> /usr/local/nagios/etc/nagios.cfg'
$ sudo sh -c 'printf "broker_module=/usr/local/nagios/bin/ndomod.o config_file=/usr/local/nagios/etc/ndomod.cfg\n" >> /usr/local/nagios/etc/nagios.cfg'
Restarting Nagios
In order to use the NDO broker module >> restart Nagios.
Different methods are used by the different Linux distributed to restart the Nagios core.
Check the status of the Nagios service to ensure it is running after these changes.
Ubuntu 13.x/14.x
$ sudo service nagios restart
$ sudo service nagios status
Ubuntu 15.x/16.x/17.x
$ sudo systemctl restart nagios.service
$ sudo systemctl status nagios.service
The last command should show Nagios running:
Ubuntu 13.x/14.x
nagios (pid 5345) is running…
Ubuntu 15.x/16.x/17.x
● nagios.service – LSB: Starts and stops the Nagios monitoring server
Loaded: loaded (/etc/rc.d/init.d/nagios)
Active: active (running) since Tue 2021-03-30 12:31:00 AEDT; 22s ago
Check NDOUtils Is Working
Different types of method are used to check the NDO2DB is working well or not.
Run the command, to see the Nagios whether the NDO module is loaded successfully.
$ grep ndo /usr/local/nagios/var/nagios.log
Output
[1475544660] ndomod: NDOMOD 2.1.1 (09-06-2016) 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.
Service Commands for NDOUtils in Ubuntu
The different Linux distributed uses different methods starting/stopping/restarting/status ndo2db following are some service commands:
Ubuntu 13.x/14.x
$ sudo start ndo2db
$ sudo stop ndo2db
$ sudo restart ndo2db
$ sudo status ndo2db
Ubuntu 15.x/16.x/17.x
$ sudo systemctl start ndo2db.service
$ sudo systemctl stop ndo2db.service
$ sudo systemctl restart ndo2db.service
$ sudo systemctl status ndo2db.service
How to fix ndo2db not running
Steps to fix this issue:
Use the command and check whether ndo2db is working or not.
# service ndo2db status
ndo2db is not running
Stop the Nagios service
# service nagios stop
Run the ‘ls’ command for output
# ls -l /usr/local/nagios/var/ndo*
-rw-r--r-- 1 nagios nagios 0 Oct 18 09:02 /usr/local/nagios/var/ndo2db.debug
-rw-r--r-- 1 nagios nagios 6 Oct 23 10:13 /usr/local/nagios/var/ndo2db.lock
-rw-r--r-- 1 nagios nagios 0 Nov 12 12:43 /usr/local/nagios/var/ndomod.tmp
srwxr-xr-x 1 nagios nagios 0 Oct 23 10:13 /usr/local/nagios/var/ndo.sock
Run the command to rename /move two files.
# mv /usr/local/nagios/var/ndo2db.lock /usr/local/nagios/var/ndo2db.lock.bak
# mv /usr/local/nagios/var/ndo.sock /usr/local/nagios/var/ndo.sock.bak
By using the following command,now you can restart the Nagios service and also the ndo2db service.
# service nagios start
# service ndo2db start
Run the service status command, in order to verify whether the service is running or not.
# service ndo2db status
ndo2db (pid 3047) is running...
Conclusion
From this article, you will get an apparent view of installing NDOUtils in Ubuntu. Follow the instruction to install if you get any sort of error you can consult with our technical team support for any assistance.