Centreon and Nagios Install Guide

Centreon and Nagios Install Guide

Centreon and Nagios Install Guide 150 150 Roderick Derks

Centos 5.5 add repo to get RedHat packages

echo "[dag]
name=Dag RPM Repository for Red Hat Enterprise Linux
baseurl=http://apt.sw.be/redhat/el\$releasever/en/\$basearch/dag
gpgcheck=1
gpgkey=http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt
enabled=1" > /etc/yum.repos.d/dag.repo

And you are off...

 

This is what I did on my Fedora 7 box:

Disable SELINUX

—————————————-
nagios update 2.9 to 3.0.3
—————————————-

tar xvzf nagios-3.0.3.tar.gz
cd nagios-3.0.3
./configure –with-gd-lib=/usr/lib –with-gd-inc=/usr/include –with-command-group=nagcmd
make all
make install
vi /etc/local/nagios/etc/nagios.conf
disable parameter check_result_buffer_slots

service nagios restart

Nagios/Apache authetication against local htpasswd file

# vi /etc/httpd/conf.d/nagios.conf

ScriptAlias /nagios/cgi-bin "/usr/local/nagios/sbin"

<Directory "/usr/local/nagios/sbin">

   AuthType Basic
   AuthName "Nagios Access"

   Options Indexes FollowSymLinks
   AllowOverride None
   Order allow,deny
   Allow from all
   Require valid-user

   # Lokale autenticatie file ipv LDAP
   AuthUserFile /usr/local/nagios/etc/apache/htpasswd.users

</Directory>

Alias /nagios "/usr/local/nagios/share"

<Directory "/usr/local/nagios/share">
   Options None
   AllowOverride AuthConfig
   Allow from all

</Directory>

Add First User and create htpasswd file:
htpasswd -c /usr/local/nagios/etc/apache/htpasswd.users nagiosadmin
Add Second User and use existing htpasswd file:
htpasswd -c /usr/local/nagios/etc/apache/htpasswd.users nagiosadmin

Nagios/Apache authetication against Windows Active Directory W2003R2 and higher

# vi /etc/httpd/conf.d/nagios.conf

ScriptAlias /nagios/cgi-bin "/usr/local/nagios/sbin"

<Directory "/usr/local/nagios/sbin">

   AuthBasicProvider ldap
   AuthType Basic
   AuthzLDAPAuthoritative on
   AuthName "Nagios Access"

   Options Indexes FollowSymLinks
   AllowOverride None
   Order allow,deny
   Allow from all
   Require valid-user

   # Active Directory LDAP
   AuthLDAPURL "ldap://elisabeth.nl:389/ou=Users,ou=admins,dc=elisabeth,dc=nl?sAMAccountName?sub?(objectClass=*)"
   AuthLDAPBindDN "cn=sa_nagios,ou=Service Accounts,ou=admins,dc=elisabeth,dc=nl"
   AuthLDAPBindPassword "wwwwachtwoord"
</Directory>

Alias /nagios "/usr/local/nagios/share"

<Directory "/usr/local/nagios/share">
   Options None
   AllowOverride AuthConfig
   Allow from all

</Directory>

————————————-
Install Linux Software
————————————-

yum install perl-RRD-Simple perl-DBI
yum install perl-DBI perl-DBD-MySQL
yum install gd fontconfig-devel libjpeg-devel libpng-devel gd-devel perl-GD
yum install php php-mysql php-gd
yum install perl-DBI perl-DBD-MySQL
yum install gd fontconfig-devel libjpeg-devel libpng-devel gd-devel perl-GD
yum install rrdtool perl-rrdtool
yum install perl-Crypt-DES perl-Digest-SHA1 perl-Digest-HMAC net-snmp-utils y
yum install perl-Socket6 perl-IO-Socket-INET6 net-snmp net-snmp-libs php-snmp dmidecode lm_sensors perl-Net-SNMP net-snmp-perl
yum install php
yum list |grep -i pear
yum install php-pear
pear channel-update pear.php.net

# yum install php-xml (voor xmlwriter.so vanaf Centreon 2.1)

#oftwel in één regel:

yum install perl-RRD-Simple perl-DBI perl-DBD-MySQL gd fontconfig-devel libjpeg-devel libpng-devel gd-devel perl-GD php php-mysql php-gd perl-DBI perl-DBD-MySQL gd fontconfig-devel libjpeg-devel libpng-devel gd-devel perl-GD rrdtool perl-rrdtool perl-Crypt-DES perl-Digest-SHA1 perl-Socket6 perl-IO-Socket-INET6 net-snmp net-snmp-libs php-snmp dmidecode lm_sensors perl-Net-SNMP net-snmp-perl perl-Digest-HMAC net-snmp-utils openssl-devel perl-DBD-MySQL mysql-server mysql-devel sudo php-ldap php-xml

yum install php-pear -y ; pear channel-update pear.php.net

Now, I had an issue when I want to install/upgrade my PEAR modules with the script install.sh for the installation of Centreon (§5). It's impossible to upgrade/install modules. My internet connection works fine (http, apt etc … work) but is there a configuration file to access outside with pear ? In fact, you can see the configuration of pear with this command :
# pear config-show

If you have an internet access with a proxy, the script install.sh will not be able to upgrade your PEAR modules. Before that, you must configure your proxy parameter for pear :
pear config-set http_proxy http://[your_login]:[your password]@[@IP proxy]:[port]
Example :
pear config-set http_proxy http://toto:fgdto@192.168.1.25:8080

This is the PEAR module that the script installs, you can install it yourself:
# yum install php-pear-SOAP -y

yum install mysqlclient14-devel.i386 -y

vi /etc/php.ini

;;;;;;;;;;;;;;;;;;;;;;
; Dynamic Extensions ;
;;;;;;;;;;;;;;;;;;;;;;

;RRD
extension=ldap.so

———————————-
NDOutils
———————————-
cd /tmp
tar xvzf ndoutils-cvs.tar.gz
cd ndoutils-cvs
./configure –prefix=/usr/local/nagios/ –enable-mysql –disable-pgsql –with-ndo2db-user=nagios –with-ndo2db-group=nagios
make
cp ./src/ndomod-3x.o /usr/local/nagios/bin/ndomod.o
cp ./src/ndo2db-3x /usr/local/nagios/bin/ndo2db
chmod 774 /usr/local/nagios/bin/ndo*
chown nagios:nagios /usr/local/nagios/bin/ndo*
cp config/ndo* /usr/local/nagios/etc/

#oftwel:
#cp ./src/ndomod-3x.o /usr/local/nagios/bin/ndomod.o; cp ./src/ndo2db-3x /usr/local/nagios/bin/ndo2db; chmod 774 /usr/local/nagios/bin/ndo*; chown nagios:nagios /usr/local/nagios/bin/ndo*;cp config/ndo* /usr/local/nagios/etc/

#vi /usr/local/nagios/etc/nagios.cfg
# event_broker_options=-1
# broker_module=/usr/local/nagios/bin/ndomod.o config_file=/usr/local/nagios/etc/ndomod.cfg

-bash-3.2# vi /etc/init.d/ndo2db
*** zie file onderaan ****

chmod +x /etc/init.d/ndo2db
chkconfig –add ndo2db
chkconfig –level 345 ndo2db on

service mysqld start
chkconfig –level 345 mysqld on

mysql -u root
mysql> update mysql.user set Password=PASSWORD('root') where User='root';
mysql> CREATE DATABASE ndo;
mysql> GRANT SELECT, INSERT, UPDATE, DELETE ON ndo.* TO 'ndo'@'localhost' IDENTIFIED BY 'ndo';
mysql> FLUSH PRIVILEGES;
mysql> exit

——————————-
INSTALL CENTREON
——————————-

-bash-3.2# visudo
#Defaults requiretty

cd /tmp
tar xvzf centreon-2.0-b6.tar.gz
export PATH="$PATH:/usr/local/nagios/bin/"
cd /tmp/centreon-2.0-b6
./install.sh -i

—————————————————–
Please choose what you want to install
—————————————————–

Do you want to install : Centreon Web Front
[y/n], default to [n]:
> y

Do you want to install : Centreon CentCore
[y/n], default to [n]:
> n

Do you want to install : Centreon Nagios Plugins
[y/n], default to [n]:
> y

Do you want to install : Centreon Snmp Traps process
[y/n], default to [n]:
> n
—————————————————–
Start CentWeb Installation
—————————————————–

Where is your Centreon directory?
default to [/usr/local/centreon]
>

Do you want me to create this directory ? [/usr/local/centreon]
[y/n], default to [n]:
> y
Path /usr/local/centreon OK

Where is your Centreon log directory
default to [/usr/local/centreon/log]
>

Do you want me to create this directory ? [/usr/local/centreon/log]
[y/n], default to [n]:
> y
Path /usr/local/centreon/log OK

Where is your Centreon etc directory
default to [/etc/centreon]
>

Do you want me to create this directory ? [/etc/centreon]
[y/n], default to [n]:
> y
Path /etc/centreon OK

Where is your Centreon generation_files directory?
default to [/usr/local/centreon]
>
Path /usr/local/centreon OK

Where is the RRD perl module installed [RRDs.pm]
default to [/usr/lib/perl5/RRDs.pm]
> /usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi/RRDs.pm
Path /usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-mulOK
/usr/bin/rrdtool OK
/bin/mail OK

Where is PEAR [PEAR.php]
default to [/usr/share/php/PEAR.php]
> /usr/share/pear/PEAR.php
Path /usr/share/pear OK

Where is installed Nagios ?
default to [/usr/local/nagios]
>
Path /usr/local/nagios OK

Where is your nagios config directory
default to [/usr/local/nagios/etc]
>
Path /usr/local/nagios/etc OK

Where is your Nagios var directory ?
default to [/usr/local/nagios/var]
>
Path /usr/local/nagios/var OK

Where is your Nagios plugins (libexec) directory ?
default to [/usr/local/nagios/libexec]
>
Path /usr/local/nagios/libexec OK
/usr/local/nagios/bin//nagios OK

Where is your Nagios image directory ?
default to [/usr/local/nagios/share/images/logos]
>
Path /usr/local/nagios/share/images/logos OK
/usr/local/nagios/bin//nagiostats OK
p1_file : /usr/local/nagios/bin/p1.pl OK
/usr/bin/php OK
Finding Apache group : apache
Finding Apache user : apache
Finding Nagios user : nagios
Finding Nagios group : nagios

Do you want to use NDO ?
[y/n], default to [n]:
> y
/usr/local/nagios/bin/ndomod.o OK
————————————————————————
Configure Sudo
————————————————————————

Where is sudo configuration file
default to [/etc/sudoers]
>
/etc/sudoers OK
Nagios init script OK
Your sudo is not configured

Do you want me to configure your sudo ? (WARNING)
[y/n], default to [n]:
> y
Configuring Sudo OK
————————————————————————
Configure Apache server
————————————————————————

Do you want to write in Apache configuration file ?
[y/n], default to [n]:
> y
Create '/etc/httpd/conf.d/centreon.conf' OK
Configuring Apache OK

Do you want to reload your Apache ?
[y/n], default to [n]:
> y
Reloading Apache service OK
Preparing Centreon temporary files)
In process
Change macros for php file
Change macros for php file OK
Copy CentWeb in system directory
CentWeb file installation OK
Install Centreon cron OK
Pear Modules
Check PEAR modules
PEAR 1.5.0 1.5.0 OK
DB 1.7.6 NOK
DB_DataObject 1.8.4 NOK
DB_DataObject_FormBuilder 1.0.0RC4 NOK
MDB2 2.0.0 NOK
Date 1.4.6 NOK
HTML_Common 1.2.2 NOK
HTML_QuickForm 3.2.5 NOK
HTML_QuickForm_advmultiselect 1.1.0 NOK
HTML_Table 1.6.1 NOK
Archive_Tar 1.1 1.3.2 OK
Auth_SASL 1.0.1 NOK
Console_Getopt 1.2 1.2.1 OK
HTTP 1.2.2 NOK
Image_GraphViz 1.1.0 NOK
Net_SMTP 1.2.8 NOK
Net_Socket 1.0.1 NOK
Net_Traceroute 0.21 NOK
Net_Ping 2.4.1 NOK
Validate 0.6.2 NOK
XML_RPC 1.4.5 1.5.1 OK
SOAP 0.10.1 NOK
Log 1.9.11 NOK

Do you want me to install/upgrade your PEAR modules
[y/n], default to [y]:
> y
Upgrading PEAR modules
Installing PEAR modules
DB 1.7.6 1.7.13 OK
DB_DataObject 1.8.4 1.8.8 OK
DB_DataObject_FormBuilder 1.0.0RC4 1.0.0RC7 OK
MDB2 2.0.0 2.4.1 OK
HTML_QuickForm_advmultiselect 1.1.0 1.4.1 OK
HTML_Table 1.6.1 1.8.2 OK
Auth_SASL 1.0.1 1.0.2 OK
HTTP 1.2.2 1.4.0 OK
Image_GraphViz 1.1.0 1.2.1 OK
Net_SMTP 1.2.8 1.3.1 OK
Net_Traceroute 0.21 0.21.1 OK
Net_Ping 2.4.1 2.4.3 OK
Validate 0.6.2 0.8.1 OK
SOAP 0.10.1 0.11.0 OK
Log 1.9.11 1.11.0 OK
Check PEAR modules
PEAR 1.5.0 1.5.0 OK
DB 1.7.6 1.7.13 OK
DB_DataObject 1.8.4 1.8.8 OK
DB_DataObject_FormBuilder 1.0.0RC4 1.0.0RC7 OK
MDB2 2.0.0 2.4.1 OK
Date 1.4.6 1.4.7 OK
HTML_Common 1.2.2 1.2.4 OK
HTML_QuickForm 3.2.5 3.2.10 OK
HTML_QuickForm_advmultiselect 1.1.0 1.4.1 OK
HTML_Table 1.6.1 1.8.2 OK
Archive_Tar 1.1 1.3.2 OK
Auth_SASL 1.0.1 1.0.2 OK
Console_Getopt 1.2 1.2.1 OK
HTTP 1.2.2 1.4.0 OK
Image_GraphViz 1.1.0 1.2.1 OK
Net_SMTP 1.2.8 1.3.1 OK
Net_Socket 1.0.1 1.0.9 OK
Net_Traceroute 0.21 0.21.1 OK
Net_Ping 2.4.1 2.4.3 OK
Validate 0.6.2 0.8.1 OK
XML_RPC 1.4.5 1.5.1 OK
SOAP 0.10.1 0.11.0 OK
Log 1.9.11 1.11.0 OK
All PEAR modules OK
————————————————————————
Centreon Post Install
————————————————————————

Create /usr/local/centreon/www/install/install.conf.php OK
Create /etc/centreon/instCentWeb.conf OK

————————————————————————
Start CentStorage Installation
————————————————————————

Where is your Centreon Run Dir directory?
default to [/var/run/centreon]
>

Do you want me to create this directory ? [/var/run/centreon]
[y/n], default to [n]:
> y
Path /var/run/centreon OK

Where is your CentStorage binary directory
default to [/usr/local/centreon/bin]
>

Do you want me to create this directory ? [/usr/local/centreon/bin]
[y/n], default to [n]:
> y
Path /usr/local/centreon/bin OK

Where is your CentStorage RRD directory
default to [/var/lib/centreon]
>

Do you want me to create this directory ? [/var/lib/centreon]
[y/n], default to [n]:
> y
Path /var/lib/centreon OK
Finding Nagios group : nagios
Finding Nagios user : nagios
Preparing Centreon temporary files)
/tmp/centreon-setup exists, it will be moved…
Creating Centreon Directory '/var/lib/centreon/status' OK
Creating Centreon Directory '/var/lib/centreon/metrics' OK
Replace Centstorage Macro OK
Set CentStorage properties OK
Change macros for centstorage init script OK

Do you want me to install CentStorage init script ?
[y/n], default to [n]:
> y

Do you want me to install CentStorage run level ?
[y/n], default to [n]:
> y
Set logAnalyser properties OK
Set nagiosPerfTrace properties OK
Install CentStorage cron OK
Create /etc/centreon/instCentStorage.conf OK

————————————————————————
Start CentPlugins Installation
————————————————————————

Where is your CentPlugins lib directory
default to [/var/lib/centreon/centplugins]
>

Do you want me to create this directory ? [/var/lib/centreon/centplugins]
[y/n], default to [n]:
> y
Path /var/lib/centreon/centplugins OK
Finding Nagios user : nagios
Finding Nagios group : nagios
Preparing Centreon temporary files)
/tmp/centreon-setup exists, it will be moved…
CentPlugins is installed
Create /etc/centreon/instCentPlugins.conf OK
#################################################
# #
# Go to the URL : http://your-server/centreon/ #
# to finish the setup #
# #
# Report bugs at http://trac.centreon.com #
# #
# Thanks for using Centreon. #
# ———————– #
# Contact : infos@centreon.com #
# http://www.centreon.com #
# #
#################################################

mysql -u root -p ndo < /tmp/centreon-2.0-b6/www/install/createNDODB.sql
mysql> GRANT SELECT , INSERT , UPDATE , DELETE ON `ndo` . * TO 'centreon'@'localhost';
mysql> FLUSH PRIVILEGES;
mysql> use centreon;
mysql> update cfg_ndo2db set db_user = 'centreon';
mysql> exit;

# vi /usr/local/nagios/etc/ndo2db.cfg
db_user=ndo
db_pass=ndo

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

system-config-security
port 3306 en 5669 openen (tcp en ik heb ook udp geopend)

# vi /usr/local/nagios/etc/ndo2db.cfg
socket_type=tcp
tcp_port=5669
db_name=ndo
db_prefix=nagios_
db_user=ndo
db_pass=ndo
output_type=tcpsocket

# vi /usr/local/nagios/etc/ndomod.cfg
output=127.0.0.1
tcp_port=5669

service centcore start
service centstorage start

 

———————————————————————–
#!/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

 

—————————————-
Add another Nagios server to the configuration
—————————————-

When you create the config files for a nagios server, fiels will be generated in the following directory:
/usr/local/centreon/filesGeneration/nagiosCFG/1/ for the local Centreon/Nagios server
/usr/local/centreon/filesGeneration/nagiosCFG/2/ for the satelite (and 3 and so on for more satelites)

—————————————-
Importing existing Nagios files
—————————————-

This part of setting up Centreon lacks documentation so this took a while to find out who things work. The order of importing the data is very important because of the dependencies:

01 checkcommandfile – select the "YES" radiobutton for the option "Delete all configuration for the chosen type of files" if youwant to delete the default preconfigured items
02 notificationcommands – from now on select the "NO" radiobutton for each step
03 timeperiods
04 servicegroups
05 contacts
06 contact_groups
07 services_templates
08 host_templates
09 hostgroups
10 hosts
11 services

Ok, after loading a file into the database check the result to see if the number of imported configuration items is correct.

It's still not the perfect solution for me cause I miss the relationship between servicegroups and services, but that's not a major issue.

I ran into some more problems. To be able to import the service templates I had to add the service _description parameter to each template, something I had not done in Nagios and it was not mandatory:

define service {
name 7×24-service
service_description 7×24-service
use generic-service
max_check_attempts 4
normal_check_interval 14
retry_check_interval 1
register 0
notification_interval 60
contact_groups 24u-medewerkers,kantoortijd-medewerkers
notification_options c,r
notification_period 7×24
}

The services were loaded and I can see them being attached directly to a host or to a hostgroup. It took me a while to understand the pages. The relationships between services and hosts were made in the Nagios config files. Hosts are member of a group that have services attached to it and other services were related directly to a certain host, not using hostgroups.

I have the idea though that sometimes the "services by host" or "services by host group" pages do not show up correctly. I get blank pages when i.e. I select a pagenumber to see more services.

Then I had to manually configure the users that were imported in the database. A lot of fields that for some reason were not filled needed to be filled manually:

– Host and Service notification options
– Host and Service notification period
– Host and Service commands

I think this has got something to do with the fact that usertemplates are not used by Centreon. At least, I can't find them. And in my Nagios config these templates contained this info.

 

——————————————————
LDAP and Active Directory
——————————————————

LDAP Information
Enable LDAP authentification: YES
LDAP Server: dnsname_or_ipaddress
LDAP port: 389
LDAP Base DN: ou=Users,ou=admins,dc=elisabeth,dc=nl
LDAP Login Attribute: samaccountname
Enable LDAP over SSL: NO

LDAP Search Information
User to search (anonymous if empty): cn=username,ou=Service Accounts,ou=admins,dc=your_ad_name,dc=nl
Password: ************
Default LDAP filter: (&(objectClass=user)(samaccounttype=805306368)(memberOf=cn=APP_Nagios,ou=Applicaties,ou=Groups,ou=EZH,dc=elisabeth,dc=nl)(cn=*))Category=person)(cn=*))
LDAP search timeout: 60
LDAP Search Size Limit: 60

For each user select LDAP as the Authentication Type, and fill in the LDAP DN (cn=username,ou=Users,dc=your_ad_name,dc=nl)
I think you can automate the last step by doing an LDAP import, but I could not get this to work.

—————————————————–
SQL stuff
—————————————————–

Install phpMyAdmin
yum install phpMyAdmin

vi /usr/share/phpMyAdmin/config.inc.php
$cfg['Servers'][$i]['auth_type'] = 'http';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = 'passsswooorrrddd';

vi /etc/httpd/conf.d/phpMyAdmin.conf
-> adjust the rights to your needs

SQL SELECT statements:

SELECT `centreon`.`ns_host_relation` SET `nagios_server_id` = '2' WHERE `ns_host_relation`.`nagios_server_id` = 1
FROM `ns_host_relation`
LIMIT 0 , 300

SELECT * FROM `ns_host_relation` WHERE `nagios_server_id` = 1

SQL UPDATE statement to change the nagios server that monitors a host:
UPDATE `centreon`.`ns_host_relation` SET `nagios_server_id` = '2' WHERE `ns_host_relation`.`nagios_server_id` = '1'

SELECT * FROM `index_data` WHERE `service_description` = 'drive-space-root'

————————————–
GRAPHS
————————————–

First configure Nagios to export the plugin service performance data to a file:

vi /usr/local/nagios/libexec/process-service-perfdata

#!/bin/bash
# some parameters passed on command line
TIMET=$1
HOSTNAME=$2
SERVICEDESC=$3
OUTPUT=$4
SERVICESTATE=$5
PERFDATA=$6
PERFFILE="/usr/local/nagios/var/service-perfdata"
/usr/bin/printf "%b" "$TIMET\t$HOSTNAME\t$SERVICEDESC\t$OUTPUT\t$SERVICESTATE\t$PERFDATA\n" >> $PERFFILE

chmod +rx /usr/local/nagios/libexec/process-service-perfdata

First of all, create a new Nagios command:
Go to 'Centreon -> Configuration -> Commands -> Miscellaneous Commands' and add a new command
name: process-service-perfdata-centreon
commandline: $USER1$/process-service-perfdata "$LASTSERVICECHECK$" "$HOSTNAME$" "$SERVICEDESC$" "$SERVICEOUTPUT$" "$SERVICESTATE$" "$SERVICEPERFDATA$"

Then, activate this command in Nagios :
Go to 'Centreon -> Configuration -> Nagios -> Nagios CFG'
Set 'Performance Data Processing Option' option to YES
In 'Service Performance Data Processing Command', select 'process-service-perfdata-centreon' plugin
Save changes and restart Nagios

Check /usr/local/nagios/var/service-perf-data. This file is now created and getting filled with data from Nagios's activated check plugins results. This file will be used by CentStorage to collect the data.

-bash-3.2# cat /usr/local/nagios/var/service-perfdata
# New File #
1218743663 ezhappl21 centreon_ping GPING OK – rtt min/avg/max/mdev = 1.064/1.064/1.064/0.000 ms OK time=1.064ms;20;40;; ok=1
[SERVICEPERFDATA] 1218743664 ezhappl21 centreon_ping 0.078 0.758 GPING OK – rtt min/avg/max/mdev = 1.064/1.064/1.064/0.000 ms time=1.064ms;20;40;; ok=1

Now configure CentStorage which is fully configured in the Centreon's webinterface

Go to 'Centreon -> Administration -> CentStorage -> Options'

Path to RRDTool Database For Metrics: /var/lib/centreon/metrics/
Path to RRDTool Database For Status: /var/lib/centreon/status/
Path to RRDTool Database for Nagios: /var/lib/centreon/nagios-perf/
RRDTool database size: 365
Retention Duration for Data in MySQL: 365
RRDTool auto delete: unselect
Sleep Time: 10
Purge check interval: 60
Storage Type: RRDTool & MySQL
Perfdata: /usr/local/nagios/var/service-perfdata
Drop Data in another file: unselect (or select for debugging to collect the perfdata picked up by CentStorage)
Drop file: /usr/local/nagios/var/service-perfdata.tmp
Archive Nagios Logs: select
Logs retention duration: 31
Nagios current log file to parse: /usr/local/nagios/var/nagios.log

– rrd files will be generated in /var/lib/centreon/metrics/{hostnumber}.rrd and /var/lib/centreon/status/{hostnumber}.rrd (depends on your Centstrore config, satelite nagios servers use directories like perfmon-2, perfmon-3, etc.
– go to 'Centreon -> Administration -> CentStorage -> Manage' to see hosts for which graphs are created.

Using CentStorage compatible Checkplugins

CentStorage catches a specific string group within Nagios checkplugin's results. CentStorage reads the performance data: behind the | in the result's string.

Example (in bold: readable data for CentStorage) :
cpu_user:OK-0% cpu_system:OK-0% cpu_idle:WARNING-97>70% | cpu_user=0%;120;90; cpu_system=0%;100;70; cpu_idle=97%;100;70;

This is the same data that used Perfparse but much more compliant.
General format is :
(user_readable_message_for_nagios) | (label)=(value)(metric);(warn level);(crit level);(min level);(max level)
Only bold string are requested by CentStorage to be able to read data.

Check if a plugin is perfdata or perfparse compatible :
1. (plugin_name) –help : usually, -f option to get perfdata.
2. Just run the plugin in a terminal to check its response format.
3. In Oreon or Nagios : have a look to 'Performance Data' info when checking a service (field must contain strings after the '|' in the message)

A problem I ran into:
I produced my first selfmade graphs. Unfortunately the legenda has got an error because of a problem with the output of the plugin. I fixed this error but the graph is still not allright. I changed the fields in the Metrics table to be as it is supposed to be and then I lost the graph and no new one is generated. I had to reset the graph and start from zero:

Administration -> Centstorage -> Manage -> Select service -> Select Metrics -> Empty All Service Data

So, step by step:

  1. So first create a plugin with the correct output
  2. Then go to "Views -> Curves" and create a curve for each label in the perfdata of the pluginyou want to put in a graph. Curves are more important then Templates.
  3. Create a command:"Configuration -> Commands -> Add.."
  4. Create a Service using the command "Services -> Add.." and link the service to a host or hostgroup (in the service object
    In the service configuration screen, go into Service Extended Infos and select a Graph Template that actually matches the perfdata that you are gathering, for example, Latency would apply to performance figures such as PING or response time.
    At this point the graph setup should be complete as long as your service has perfdata turned ON. Check your templates to make sure it's not 'blocked' somewhere
  5. Execute a Nagios Configuration Files Export

 

MySQL commmands for centstorage:

All tables but not the tabale no_data
mysqldump –opt -hlocalhost -uroot -proot centstorage config data_stats_daily data_stats_monthly data_stats_yearly index_data instance log log_archive_host log_archive_last_status log_archive_service log_snmptt metrics statistics |gzip > /tmp/mysql_centstorage_db_table_no_data.gz

Just table data_bin without the data
mysqldump –opt -hlocalhost -uroot -proot –no_data centstorage data_bin |gzip > /tmp/mysql_centstorage_db.gz

Restore:

-bash-3.2# gzip -d 20081126174501.centreon.gz
-bash-3.2# gzip -d 20081126174501.centstorage.gz
-bash-3.2# gzip -d 20081126174501.ndo.gz
-bash-3.2# mysql -u root -p centreon < 20081126174501.centreon
Enter password:
-bash-3.2# mysql -u root -p centstorage < 20081126174501.centstorage
Enter password:
-bash-3.2# mysql -u root -p ndo < 20081126174501.ndo
Enter password:

Empty Rows In Table

There are two ways to delete all the data in a MySQL database table.

TRUNCATE TABLE tablename; This will delete all data in the table very quickly. In MySQL the table is actually dropped and recreated, hence the speed of the query. The number of deleted rows for MyISAM tables returned is zero; for INNODB it returns the actual number deleted.
DELETE FROM tablename;
This also deletes all the data in the table, but is not as quick as using the "TRUNCATE TABLE" method. In MySQL >= 4.0 the number of rows deleted is returned; in MySQL 3.23 the number returned is always zero.

 

 

Database Growth Control

1. Change Retention Duration for Data in MySQL to 182 days, has this got any effect on the data that is being reported in the reporting tool?

2. Empty the NDO database (except for the tables nagios_acknowledgements, nagios_commenthistory, nagios_comments, nagios_downtimehistory, nagios_instances I think)

3. In Administration> Options > Centstorage > Options I have this config:
I unchecked teh box to prevent the unlimited growth of the service-perfdata.tmp file.
Drop possibility after parsing performance data
Drop Data in another file [ ]
Drop file /usr/local/nagios/var/service-perfdata.tmp

Database performance

Use the tuning-primer.sh script to check mysqld performance and follow the advices given.

-bash-3.2# vi /etc/my.cnf
key_buffer_size=500M
table_cache=1024
query_cache_size=32M

-bash-3.2# service mysqld restart

You can use the other mysql check script to see if there is a difference. Run it before and after the command above.
-bash-3.2# ./ mysql_mem_usage /etc/my.cnf /usr/libexec/mysqld


Upgrade 2.0.2 to 2.1RC6

Got the message that there were not enough rights on the NDO database to execute the script.

mysql -u root  mysql> GRANT SELECT , INSERT , UPDATE , DELETE, ALTER ON `ndo` . * TO 'centreon'@'localhost'; mysql> exit

The the script was executted but it gave me the status CRITICAL. The result was that a user who is NOT a Centreon admin does not see any of the hosts or services in the Home or Monitoring tab. Also no graphs, no reporting info, nothing. The user can just see the config pages.

Solution: with MySQL client or phpMyAdmin, execute this on NDO database:

ALTER TABLE `centreon_acl` ADD host_id INT(11) default NULL AFTER `id` ; ALTER TABLE `centreon_acl` ADD service_id INT(11) default NULL AFTER `host_name`; ALTER TABLE `nagios_servicestatus` ADD INDEX (`current_state`);

Then you have to execute the right SQL script again on the commandline. Scripts can be found in dirs like /usr/local/centreon/www/zKi45v/.

Another problem with the upgrade too. I had to do the upgrade to RC6 in steps (RC6, then RC2, then RC6 again) because the webpage got stuck trying to run the SQL scripts going from RC1 to RC2 when trying to do the upgrade directly from the 2.1RC6 package.

 

MYSQL statement example:

# SELECT host_name, host_address FROM `host` where `host_register`='1'

Roderick Derks

Liefhebber van fietsen, van het oplossen van IT puzzels, en van het delen van informatie om anderen te helpen.

All stories by:Roderick Derks

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Your Name (required)

Your Email (required)

Subject

Your Message

Your Name (required)

Your Email (required)

Subject

Your Message