In this post I provide instructions on setting up the database plugin, NDOutils, for Nagios. The instructions were written for CentOS but most of it should easily carry over to another distro.
First things, elevate yourself to root.
su root
- Install GCC and update MySQL
yum install gcc
yum update mysql
yum install mysql-server
yum install mysql-devel
- Start mysql & Add mysql as Startup service
/etc/init.d/mysqld start
chkconfig –add mysqld
- Create MySQL Database
mysql
create database nagios;
GRANT ALL ON nagios.* TO nagios@localhost IDENTIFIED BY “nagios”;
FLUSH PRIVILEGES;
quit
- Download and untar the latest release of NDOutils – http://sourceforge.net/projects/nagios/files/ndoutils-1.x/
- Copy to /tmp/
- Change directory to /tmp/
cd /tmp/
tar zxfv ndoutils-1.4b9.tar.gz
- Compile NDOutils
cd /ndoutils-1.4b9/
./configure
make
- Make /var/run/nagios folder & Change the ownership to nagios user
mkdir /var/run/nagios
chown nagios:nagios /var/run/nagios
chmod 755 /var/run/nagios
- Copy appropriate ndo2db.o & ndomod.o /usr/bin and set permissions
“ndo2db-2x.o” & “ndomod-2x.o” for Nagios 2.x
“ndo2db-3x.o” & “ndomod-3x.o” for Nagios 3.x
cp /tmp/ndoutils-1.4b9/src/ndo2db-3x.o /usr/bin/ndo2db
cp /tmp/ndoutils-1.4b9/src/ndomod-3x.o /usr/bin/ndomod
chmod 755 /usr/bin/ndo2db
chmod 755 /usr/bin/ndomod
- Create NDO database
cd /tmp/ndoutils-1.4b9/src/db
./installdb -u nagios -p nagios -h localhost -d nagios
- Copy configuration files
cp /tmp/ndoutils-1.4b9/config/ndo2db.cfg /etc/nagios
cp /tmp/ndoutils-1.4b9/config/ndomod.cfg /etc/nagios
- Modify /etc/nagios/ndo2b.cfg
nano /etc/nagios/ndo2db.cfg
- Set lock_file=/var/run/nagios/ndo2db.lock
- Set ndo2dbuser=nagio and ndo2dbgroup=nagios
- Set socket_name=/var/run/nagios/ndo.sock
- Set db_host=localhost , db_name=nagios , db_prefix=nagios_ , dp_user=nagios , dp_pass=nagios
- Set debug_file=/var/run/nagios/ndo2db.debug
- Set time intervals to store data
- Modify /etc/nagios/ndomod.cfg
nano /etc/nagios/ndomod.cfg
- Set output=/var/run/nagios/ndo.sock
- Set buffer_file=/var/run/nagios/ndomod.tmp
- Modify /etc/nagios/nagios.cfg
- Add the follow line: broker_module=/usr/bin/ndomod config_file=/etc/nagios/ndomod.cfg
- Change ownership and permissions on config files
chown nagios:nagios /etc/nagios/ndo2db.cfg
chown nagios:nagios /etc/nagios/ndomod.cfg
chmod 664 /etc/nagios/ndo2db.cfg
chmod 664 /etc/nagios/ndomod.cfg
- Start NDO2DB
/usr/bin/ndo2db -c /etc/nagios/ndo2db.cfg
- Restart Nagios
/etc/init.d/nagios restart
You misspelled mysql, bro.
@ step 10 typo error
./installdb -u nagios -p nadios
Thanks for letting me know. I’ve corrected it.
Hi Joe,
Brilliant tutorial. Thanks mate. I run omdistro with check_mk. So when i connect to the nagiosdb and run a query i get a empty result. Which file directory should i be looking for in my setup?