Wednesday, December 29, 2010

NDOUtils installation on CentOS for Nagios

NDOUtils installation on CentOS

NDOUtils Requirements

  • GCC-C++
  • MySQL
  • MySQL-Devel
  • MySQL-Server

Installing MySQL

# yum -y install mysql mysql-devel mysql-server gcc-c++

# /etc/init.d/mysqld start

# chkconfig --add mysqld

-> make sure it's running

# ps -ef | grep mysql

-> Creating MySQL DB

mysql -u root

(no password

#Now, inside MySQL shell

mysql>create database nagios;

Query OK, 1 row affected (0.00 sec)

mysql>show databases;


| Database |


| database |

| mysql |

| nagios |

| test |


4 rows in set (0.01 sec)


Create a username/password that has at least the following privileges for the database: SELECT, INSERT, UPDATE, DELETE"

mysql> GRANT ALL ON nagios.* TO nagios@localhost IDENTIFIED BY "example";

Query OK, 0 rows affected (0.00 sec)


Query OK, 0 rows affected (0.00 sec)

mysql> quit

-> NDOUtils Install

Download and untar

# cd /usr/local/nagios/var/

# wget

# tar zxfv ndoutils-1.4b9.tar.gz

-> Compiling

# cd ndoutils-1.4b9

# ./configure

# make

Look through config.log for problems.

# less config.log

(If problems, run "make clean" to blow away bad binaries)

-> Copying Binaries


There are two different versions of the NDOMOD module that get compiled, so make sure you use the module that matches the version of Nagios you are running, and adjust the directions given below to fit the name of the module version you're using.

ndomod-2x.o = NDOMOD module for Nagios 2.x ndomod-3x.o = NDOMOD module for Nagios 3.x (unstable)

In our CentOS example, we use the stable 2.x version

# /usr/local/nagios/var/ndoutils-1.4b9/src/ndomod-2x.o

Copy the compiled NDOMOD module to your Nagios installation:

# cp /usr/local/nagios/var/ndoutils-1.4b9/src/ndomod-3x.o /usr/local/nagios/bin/ndomod.o


There are two different versions of the NDO2DB daemon that get compiled, so make sure you use the daemon that matches the version of Nagios you are running, and adjust the directions given below to fit the name of the daemon you're using.

ndo2db-2x.o = NDO2DB daemon for Nagios 2.x ndo2db-3x.o = NDO2DB daemon for Nagios 3.x (unstable)

Copy the compiled NDO2DB daemon to your Nagios installation:

# cp /usr/local/nagios/var/ndoutils-1.4b9/src/ndo2db-2x /usr/local/nagios/bin/ndo2db

-> Creating NDO database

It's time now to create the NDO MySql database Run the DB installation script in the /tmp/ndoutils-1.4b9/db/ subdirectory of the NDO distribution to create the necessary tables in the database.

(-u = user; -p = password; -h = name of computer; -d = MySQL DB)

# cd /usr/local/nagios/var/ndoutils-1.4b9/db

# ./installdb -u nagios -p password -h localhost -d nagios

DBD::mysql::db do failed: Table 'nagios.nagios_dbversion' doesn't exist at ./installdb line 51.

** Creating tables for version 1.4b9

Using mysql.sql for installation...

** Updating table nagios_dbversion


We'll need to later make sure that the database name, prefix, and username/password we created and setup match the variable specified in our NDO2DB config file (which will ultimately live in /etc/nagios/)

CFG File Changes for CentOS-MySQL Environment


# cp //usr/local/nagios/var/ndoutils-1.4b9/config/ndo2db.cfg /usr/local/nagios/etc/

->in ndo2db.cfg


# This option determines what type of socket the daemon will create

# an accept connections from.

# Value:

# unix = Unix domain socket (default)

# tcp = TCP socket



. . .


# This option determines the name and path of the UNIX domain

# socket that the daemon will create and accept connections from.

# This option is only valid if the socket type specified above

# is "unix".



. . .


# This is the username/password that will be used to authenticate to the DB.

# The user needs at least SELECT, INSERT, UPDATE, and DELETE privileges on

# the database.






Copy the sample NDOMOD config file to your Nagios installation

Note: this config is not ready yet; we will need to modify it later to our environment.

# cp //usr/local/nagios/var/ndoutils-1.4b9/config/ndomod.cfg /usr/local/nagios/etc/

Add a line similiar to the following to the *main* Nagios config file (usually /usr/local/nagios/etc/nagios.cfg):

nagios.cfg file (all one one line, this cfg_file!=confg_file variable)

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

The config directive above will cause Nagios to load the NDOMOD event broker the next time it starts. Of course, this requres that you compiled Nagios with support for the event broker in the first place, which is not a problem if we installed via package (via RPMforge repository).

Make sure you have a line similar to the following in the *main* Nagios config file (usually /usr/local/nagios/etc/nagios.cfg):


That directive will cause the Nagios daemon to send data to the NDOMOD module. Without that option, NDOMOD won't get any information. Finaly make sure that output parameter in ndomod.cfg is set up to


It's very important that output parameter has exactly the same value as socket_name parameter in ndo2db.cfg file. If not, you will get this message when starting nagios daemon.

[1192222122] ndomod: Error writing to data sink! Some output may get lost...

Start NDO2DB daemon

# /usr/local/nagios/bin/ndo2db -c /usr/local/Nagios/etc/nagios/ndo2db.cfg

[root@localhost nagios]# ps -ef | grep ndo2db

nagios 26516 1 0 19:36 ? 00:00:00 ndo2db -c /etc/nagios/ndo2db.cfg

root 26536 26460 0 19:40 pts/0 00:00:00 grep ndo

[root@localhost nagios]#

restart Nagios

# /etc/init.d/nagios restart

Proof it's working:

# tail /var/log/nagios/nagios.log

[1192222138] ndomod: Successfully reconnected to data sink! 0 items lost, 68 queued items to flush.

[1192222138] ndomod: Successfully flushed 68 queued items to data sink.

No comments: