nagios and centron

Example Logins:
Account roleLoginPassword
MySQL root accesrootmysqlcentaccess03
Nagiosnagiosnagaccess03
User accountactivlanremoteaccess03
Mysql accountcentreonmysqlcentreon03
Web Nagiosnagiosadminnagwebaccess03
Web Centreonadminactwebaccess03
==SKIP System update Once it’s installed, proceed to a system update
sudo aptitude update
sudo aptitude full-upgrade -y
Switch to fixed IP address
sudo nano /etc/network/interfaces
Please verify that you are working with fixed IP address. If not, please change your settings. You should see something like this at the end of the file (the value should be different for you):
auto eth0
iface eth0 inet static
address 192.168.1.100
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1
REBOOT ==/SKIP If you didnt have em get headers and buid essentials
sudo aptitude install build-essential -y
sudo aptitude install linux-headers-$(uname -r) -y
mysql, system, web and php
sudo aptitude install mysql-server libmysqlclient-dev -y
sudo aptitude install rrdtool librrds-perl -y
sudo aptitude install apache2 apache2-mpm-prefork libapache2-mod-php5 -y
sudo aptitude install php5 php5-mysql -y
sudo aptitude install php-pear php5-ldap php5-snmp php5-gd -y
==SKIP we builded latest frrom source RRDTool
sudo aptitude install rrdtool librrds-perl -y
==/skip Perl, snmp, GD and other dependancies:
sudo aptitude install libconfig-inifiles-perl libcrypt-des-perl libdigest-hmac-perl libdigest-sha1-perl libgd-gd2-perl -y
sudo aptitude install snmp snmpd libnet-snmp-perl libsnmp-perl -y
sudo aptitude install libgd2-xpm libgd2-xpm-dev libpng12-dev -y
sudo aptitude install libldap2-dev libssl-dev libsnmp-dev -y
User Setup for example pass use: nagaccess03
sudo useradd -m -s /bin/bash nagios
sudo passwd nagios
sudo groupadd nagcmd
sudo usermod -G nagios,nagcmd nagios
sudo usermod -a -G nagios,nagcmd www-data
Nagios Core
cd /usr/local/src
sudo wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-3.3.1.tar.gz
sudo tar xvzf nagios-3.3.1.tar.gz
cd nagios
sudo ./configure --prefix=/usr/local/nagios --with-nagios-user=nagios --with-nagios-group=nagios --with-command-group=nagcmd --enable-nanosleep --enable-event-broker
sudo make all
sudo make install
sudo make install-init
sudo make install-commandmode
sudo make install-config
sudo update-rc.d -f nagios defaults
cd ..
Nagios Plugins 1.4.15
sudo wget http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.15.tar.gz
sudo tar xvfz nagios-plugins-1.4.15.tar.gz
cd nagios-plugins-1.4.15
sudo ./configure --prefix=/usr/local/nagios --with-nagios-user=nagios --with-nagios-group=nagios
sudo make
sudo make install
cd ..
Ndoutils 1.4b9
sudo wget http://prdownloads.sourceforge.net/sourceforge/nagios/ndoutils-1.4b9.tar.gz
sudo tar xvfz ndoutils-1.4b9.tar.gz
cd ndoutils-1.4b9
sudo ./configure --prefix=/usr/local/nagios/ --enable-mysql --disable-pgsql --with-ndo2db-user=nagios --with-ndo2db-group=nagios
sudo make
sudo cp ./config/ndo2db.cfg-sample /usr/local/nagios/etc/ndo2db.cfg
sudo cp ./config/ndomod.cfg-sample /usr/local/nagios/etc/ndomod.cfg
cd ..
Patch NDO grab latest from SVN (if you dont have svn do apt-get install subversion)
svn co http://svn.centreon.com/trunk/Patch-NDOutils/ Patch-NDOutils
cd Patch-NDOutils
sudo bash ./configure --prefix=/usr/local/nagios/ --enable-mysql --disable-pgsql --with-ndo2db-user=nagios --with-ndo2db-group=nagios
sudo make
sudo cp src/ndomod-3x.o /usr/local/nagios/bin/ndomod.o
sudo cp src/ndo2db-3x /usr/local/nagios/bin/ndo2db
sudo chmod 775 /usr/local/nagios/bin/ndo2db
sudo chmod 755 /usr/local/nagios/bin/ndomod.o
sudo chown nagios:nagios /usr/local/nagios/bin/ndo2db
sudo chown nagios:nagios /usr/local/nagios/bin/ndomod.o
Nagios web interface I also recommend installing Nagios web interface as it could help you comparing your centreon checks and nagios exported configuration. Use “nagwebaccess03” as password
cd /usr/local/src/nagios
sudo make install-webconf
sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
SNMP settings edit /etc/default/snmpd
sudo nano /etc/default/snmpd
and change these sections:
#SNMPDOPTS='-Lsd -Lf /dev/null -u snmp -I -smux -p /var/run/snmpd.pid 127.0.0.1'
SNMPDOPTS='-Lsd -Lf /dev/null -u snmp -I -smux -p /var/run/snmpd.pid 127.0.0.1 192.168.0.148'
Replace 192.168.0.148 by your IP address.
#TRAPDRUN=no
TRAPDRUN=yes
Edit snmpd configuration file: sudo nano /etc/snmp/snmpd.conf and change this section:
#       sec.name  source          community
#com2sec paranoid  default         public
com2sec readonly  default         public
com2sec readonly  127.0.0.1         public
com2sec readonly  192.168.0.0/24         public
#com2sec readwrite default         private
NDO database configuration Create your database
mysql -u root -p
mysql> create database ndo;
mysql> grant all on ndo.* to 'ndouser'@localhost identified by 'ndopassword';
mysql> flush privileges;
mysql> exit
get ndodb up
cd /usr/local/src/ndoutils-1.4b9/db
./installdb -u ndouser -p ndopassword -h localhost -d ndo
ignore the create table error. edit ndomod:
sudo nano /usr/local/nagios/etc/ndomod.cfg
find and replace these sections:
#instance_name=default
instance_name=Central
view sourceprint?
output_type=tcpsocket
#output_type=unixsocket
output=127.0.0.1
#output=/usr/local/nagios/var/ndo.sock
#reconnect_warning_interval=15
reconnect_warning_interval=900
#config_output_options=2
config_output_options=3
Edit ndo2db configuration file:
sudo nano /usr/local/nagios/etc/ndo2db.cfg
find and replace these sections:
#socket_type=unix
socket_type=tcp
db_name=ndo
# Keep timed events for 24 hours
max_timedevents_age=1440
# Keep system commands for 1 week
max_systemcommands_age=1440
# Keep service checks for 1 week
max_servicechecks_age=1440
# Keep host checks for 1 week
max_hostchecks_age=1440
# Keep event handlers for 31 days
max_eventhandlers_age=1440
Edit nagios configuration file:
sudo nano /usr/local/nagios/etc/nagios.cfg
find “broker” section and add this entry:
broker_module=/usr/local/nagios/bin/ndomod.o config_file=/usr/local/nagios/etc/ndomod.cfg
Edit sudoers grant file:
sudo nano /etc/sudoers
and add nagios user account after root account:
nagios ALL=(ALL) ALL
Create ndo2db file:
sudo nano /etc/init.d/ndo2db
Paste the following script (be carefull if you choose to use diferent credentials than nagios:nagios, you’ll have to modifiy the corresponding lines below(find NdoUser and NdoGroup)):
#!/bin/sh
#
#
# chkconfig: 345 99 01
# description: Nagios to mysql
#
# Author : Gaëtan Lucas
# Realase : 07/02/08
# Version : 0.1 b
# File : ndo2db
# Description: Starts and stops the Ndo2db daemon
#              used to provide network services status in a database.
#
 
status_ndo ()
{
        if ps -p $NdoPID > /dev/null 2>&1; then
                return 0
        else
                return 1
        fi
 
        return 1
}
 
printstatus_ndo()
{
        if status_ndo $1 $2; then
                echo "ndo (pid $NdoPID) is running..."
        else
                echo "ndo is not running"
        fi
}
 
killproc_ndo ()
{
        echo "kill $2 $NdoPID"
        kill $2 $NdoPID
}
 
pid_ndo ()
{
        if test ! -f $NdoRunFile; then
                echo "No lock file found in $NdoRunFile"
                echo -n "         checking runing process..."
                NdoPID=`ps h -C ndo2db -o pid`
                if [ -z "$NdoPID" ]; then
                        echo "     No ndo2db process found"
                        exit 1
                else
                        echo "     found process pid: $NdoPID"
                        echo -n "         reinit $NdoRunFile ..."
                        touch $NdoRunFile
                        chown $NdoUser:$NdoGroup $NdoRunFile
                        echo "$NdoPID" > $NdoRunFile
                        echo "     done"
                fi
        fi
 
        NdoPID=`head $NdoRunFile`
}
 
# Source function library
# Solaris doesn't have an rc.d directory, so do a test first
if [ -f /etc/rc.d/init.d/functions ]; then
        . /etc/rc.d/init.d/functions
elif [ -f /etc/init.d/functions ]; then
        . /etc/init.d/functions
fi
 
prefix=/usr/local/nagios
exec_prefix=${prefix}
NdoBin=${exec_prefix}/bin/ndo2db
NdoCfgFile=${prefix}/etc/ndo2db.cfg
NdoRunFile=${prefix}/var/ndo2db.run
NdoLockDir=/var/lock/subsys
NdoLockFile=ndo2db.lock
NdoUser=nagios
NdoGroup=nagios
 
# Check that ndo exists.
if [ ! -f $NdoBin ]; then
   echo "Executable file $NdoBin not found.  Exiting."
   exit 1
fi
 
# Check that ndo.cfg exists.
if [ ! -f $NdoCfgFile ]; then
   echo "Configuration file $NdoCfgFile not found.  Exiting."
   exit 1
fi
 
# See how we were called.
case "$1" in
 
        start)
                echo -n "Starting ndo:"
                touch $NdoRunFile
                chown $NdoUser:$NdoGroup $NdoRunFile
                $NdoBin -c $NdoCfgFile
                if [ -d $NdoLockDir ]; then
                        touch $NdoLockDir/$NdoLockFile;
                fi
                ps h -C ndo2db -o pid > $NdoRunFile
                if [ $? -eq 0 ]; then
                        echo " done."
                        exit 0
                else
                        echo " failed."
                        $0 stop
                        exit 1
                fi
                ;;
 
        stop)
                echo -n "Stopping ndo: "
 
                pid_ndo
                killproc_ndo
 
                # now we have to wait for ndo to exit and remove its
                # own NdoRunFile, otherwise a following "start" could
                # happen, and then the exiting ndo will remove the
                # new NdoRunFile, allowing multiple ndo daemons
                # to (sooner or later) run
                #echo -n 'Waiting for ndo to exit .'
                for i in 1 2 3 4 5 6 7 8 9 10 ; do
                    if status_ndo > /dev/null; then
                        echo -n '.'
                        sleep 1
                    else
                        break
                    fi
                done
                if status_ndo > /dev/null; then
                    echo
                    echo 'Warning - ndo did not exit in a timely manner'
                else
                    echo 'done.'
                fi
 
                rm -f $NdoRunFile $NdoLockDir/$NdoLockFile
                ;;
 
        status)
                pid_ndo
                printstatus_ndo ndo
                ;;
 
        restart)
                $0 stop
                $0 start
                ;;
 
        *)
                echo "Usage: ndo {start|stop|restart|status}"
                exit 1
                ;;
esac
# End of this script
change the owner, rights and add the job to autostart:
sudo chown root:root /etc/init.d/ndo2db
sudo chmod +x /etc/init.d/ndo2db
sudo update-rc.d ndo2db defaults
You could now realy proceed to Centreon installation section. Download sources:
cd /usr/local/src
wget http://download.centreon.com/index.php?id=179
mv index.php?id=179 centreon-2.3.7.tar.gz
tar xvf centreon-2.3.7.tar.gz
cd centreon-2.3.7
export PATH="$PATH:/usr/local/nagios/bin/"
sudo ./install.sh -i
accept the readme and lic. gplv3 (use q to exit readme) A whole bunch of yes an so on.. at RRD.mo use our compiled:
/opt/rrdtool-1.4.5/lib/perl/5.10.1/x86_64-linux-gnu-thread-multi/RRDs.pm
For ndmod.o use:
/usr/local/nagios/bin/ndomod.o
Where is your SNMP configuration directory default to [/etc/snmp] /usr/local/centreon/bin/ Initialise the NDO database
mysql -u root -p
use ndo;
source /usr/local/src/centreon-2.3.7/www/install/createNDODB.sql
GRANT SELECT , INSERT , UPDATE , DELETE ON ndo . * TO ndouser@localhost IDENTIFIED BY "ndopassword"; FLUSH PRIVILEGES;
exit
reload apache login to webgui follow pictuires here some flaw in the nagios config
ln -s /usr/local/nagios/bin/nagios /usr/local/bin/nagios
nagios -v /usr/local/nagios/etc/nagios.cfg
Website: http://www.nagios.org Reading configuration data... Error in configuration file '/usr/local/nagios/etc/nagios.cfg' - Line 464 (Check result path is not a valid directory) Error processing main config file! Line 464 says: heck_result_path=/usr/local/nagios/var/spool/checkresults
mkdir /usr/local/nagios/var/spool
touch /usr/local/nagios/var/spool/objects.cache
mkdir /usr/local/nagios/var/spool/checkresults
chown nagios:nagios /usr/local/nagios/var/spool -R
touch /usr/local/nagios/var/nagios.log
touch /usr/local/nagios/var/retention.dat
chown nagios:nagios /usr/local/nagios/var/nagios.log
chown nagios:nagios /usr/local/nagios/var/retention.dat
Finally restart nagios
/etc/init.d/nagios restart

 

Hessen Kasselstraat 8
5615 SM Eindhoven
phone: +316-81888456