ICINGA + pnp4nagios installation



Icinga web with pnp4nagios
PNP is an addon for the Nagios Network Monitoring System. PNP provides easy to use, easy to configure RRDTools based performance charts feeded by the performance data output of the Nagios Plugins.


Setting up icinga using repository:-
OS used in this env = CentOS release 6.5 X64bit

1. Install CentOS 6.4 minimal version

2. Prepare your system
# yum groupinstall Development tools
# yum install vim mc
3. Add EPEL and Remi repositories
# wget http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
# rpm -ivh epel-release-6-8.noarch.rpm
#wget http://dl.iuscommunity.org/pub/ius/stable/CentOS/6/x86_64/ius-release-1.0-13.ius.centos6.noarch.rpm
#rpm -Uvh ius-release*.rpm
4. Check your repolist[the under lined repos should be present]

5. Installing packages
#yum install php php-cli php-pear php-xmlrpc php-xsl php-pdo php-soap php-gd php-ldap php-mysql
# yum install icinga icinga-gui icinga-doc icinga-idoutils-libdbi-mysql               or    yum install icinga*
# yum install nagios-plugins-all
# yum install mysql-server mysql-client libdbi libdbi-dbd-mysql libdbi-devel icinga-idoutils-libdbi-mysql libdbi-drivers
6. Database setup
 # mysql -u root -p
 mysql> CREATE DATABASE icinga_web;
        GRANT USAGE ON *.* TO 'icinga_web'@'localhost' IDENTIFIED BY 'icinga_web' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0;
        GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, ALTER, INDEX ON icinga_web.* TO 'icinga_web'@'localhost';
        quit;

#echo "CREATE DATABASE icinga; \
GRANT USAGE ON *.* TO 'icinga'@'localhost' \
  IDENTIFIED BY 'icinga' \
  WITH MAX_QUERIES_PER_HOUR 0 \
  MAX_CONNECTIONS_PER_HOUR 0 \
  MAX_UPDATES_PER_HOUR 0; \
GRANT SELECT , INSERT , UPDATE , DELETE, DROP, CREATE VIEW \
  ON icinga.* TO 'icinga'@'localhost'; \
FLUSH PRIVILEGES;" \
| mysql -uroot -p

                               
7. Import the schema
mysql -u root -p   icinga_web < /usr/share/doc/icinga-web-1.7.2/schema/mysql.sql
mysql -u root -p icinga < /usr/share/doc/icinga-idoutils-libdbi-mysql-1.8.4/db/mysql/mysql.sql

chkconfig ido2db on
chkconfig icinga on
chkconfig httpd on
service ido2db start
service icinga start
service httpd start


8. Test classic Web GUI
Set a SHA encrypted administrator password for Basic Authentication
htpasswd -s /etc/icinga/passwd icingaadmin

Icinga- Web
Test New Web GUI
Open the URL https://ICINGA_SERVER_IP/icinga-web and login with user “root and password “password
Set the Timezone
Proper time setting is required to make the scheduled check commands work.
Set the variable TIMEZONE to your timezone, e.g. "Europe/Berlin"
export TIMEZONE="Europe/Berlin"
sed -i "s|^[ ;]*date.timezone *=.*|date.timezone='$TIMEZONE'|" /etc/php.ini
Example 2
ln -s /usr/share/zoneinfo/Canada/Central /etc/localtime
[root@VM156 ~]# date
Mon Sep 22 03:29:14 CDT 2014
[]#vim /etc/php.ini
 [Date]                  #line number 943
date.timezone = "Canada/Central"                      ##line number 946
Install pnp4nagios
Install the required packages:
# yum install rrdtool rrdtool-devel rrdtool-perl openssl-devel gcc php-rrdtool php-gd php php-pdo php-common perl-Time-HiRes
# yum install wget
Download pnp4nagios source
# wget -c 
http://sourceforge.net/projects/pnp4nagios/files/PNP-0.6/pnp4nagios-0.6.21.tar.gz
# tar -xvzf pnp4nagios-0.6.21.tar.gz
# cd pnpnagios-0.6.21
Compile and install pnp4nagios for Icinga user:
# ./configure --with-nagios-user=icinga --with-nagios-group=icinga
# make all
# make install
# make install-webconf
# make install-config
# make install-init

Configure pnp4nagios for Icinga Core:
# vim /etc/icinga/icinga.cfg
................
#process_performance_data=0
process_performance_data=1
.................
broker_module=/usr/local/pnp4nagios/lib/npcdmod.o config_file=/usr/local/pnp4nagios/etc/npcd.cfg
..................

Add new command for check configuration files of the Icinga:
# alias icicheck='/usr/bin/icinga -v /etc/icinga/icinga.cfg'
Integration Icinga htpasswd file in pnp4nagios:
# vim /etc/httpd/conf.d/pnp4nagios.conf    [check the highlighted values]
AuthName "Nagios Access"                   #line number 12
AuthType Basic
AuthUserFile /etc/icinga/passwd

Restart following services:
# service httpd restart
# /etc/init.d/npcd start && chkconfig npcd on
# icicheck
# /etc/init.d/icinga restart
Please check correct installation of pnp4nagios.
Go to web http://<server name>/pnp4nagios/
If you see in the end web page following "Your environment passed all requirements." so you must remove or rename the /usr/local/pnp4nagios/share/install.php file
# mv /usr/local/pnp4nagios/share/install.php /usr/local/pnp4nagios/share/install.php.testfile
Configure main config file of the pnp4nagios:
# cd /usr/local/pnp4nagios/etc/
# mv rra.cfg-sample rra.cfg
# vim npcd.cfg

user = icinga
group = icinga
log_type = file
log_level = -1
load_threshold = 10.0

After that check icinga configuration
# icicheck
Total Warnings: 0
Total Errors: 0
# vim config.php
# Link back to Nagios or Thruk
#
$conf['nagios_base'] = "/icinga/cgi-bin";

Please, overwrite all settings for perfdata:
# vim /etc/icinga/icinga.cfg
#host_perfdata_file=/tmp/host-perfdata
#service_perfdata_file=/tmp/service-perfdata
host_perfdata_file=/usr/local/pnp4nagios/var/host-perfdata
service_perfdata_file=/usr/local/pnp4nagios/var/service-perfdata
#host_perfdata_file_template=[HOSTPERFDATA]\t$TIMET$\t$HOSTNAME$\t$HOSTEXECUTIONTIME$\t$HOSTOUTPUT$\t$HOSTPERFDATA$
#service_perfdata_file_template=[SERVICEPERFDATA]\t$TIMET$\t$HOSTNAME$\t$SERVICEDESC$\t$SERVICEEXECUTIONTIME$\t$SERVICELATENCY$\t$SERVICEOUTPUT$\t$SERVICEPERFDATA$
host_perfdata_file_template=DATATYPE::HOSTPERFDATA\tTIMET::$TIMET$\tHOSTNAME::$HOSTNAME$\tHOSTPERFDATA::$HOSTPERFDATA$\tHOSTCHECKCOMMAND::$HOSTCHECKCOMMAND$\tHOSTSTATE::$HOSTSTATE$\tHOSTSTATETYPE::$HOSTSTATETYPE$
service_perfdata_file_template=DATATYPE::SERVICEPERFDATA\tTIMET::$TIMET$\tHOSTNAME::$HOSTNAME$\tSERVICEDESC::$SERVICEDESC$\tSERVICEPERFDATA::$SERVICEPERFDATA$\tSERVICECHECKCOMMAND::$SERVICECHECKCOMMAND$\tHOSTSTATE::$HOSTSTATE$\tHOSTSTATETYPE::$HOSTSTATETYPE$\tSERVICESTATE::$SERVICESTATE$\tSERVICESTATETYPE::$SERVICESTATETYPE$
#host_perfdata_file_mode=a
#service_perfdata_file_mode=a
host_perfdata_file_mode=a
service_perfdata_file_mode=a
#host_perfdata_file_processing_interval=0
#service_perfdata_file_processing_interval=0
host_perfdata_file_processing_interval=30
service_perfdata_file_processing_interval=30
#host_perfdata_file_processing_command=process-host-perfdata-file
#service_perfdata_file_processing_command=process-service-perfdata-file
host_perfdata_file_processing_command=process-host-perfdata-file
service_perfdata_file_processing_command=process-service-perfdata-file

After that check icinga configuration
# icicheck
Total Warnings: 0
Total Errors: 0
Either edit or append. A sample is provided within /usr/local/pnp4nagios/etc/misccommands.cfg:
# cp /usr/local/pnp4nagios/etc/misccommands.cfg-sample /etc/icinga/misccommands.cfg
# vi /etc/icinga/misccommands.cfg
and uncomment following strings
define command {
command_name process-service-perfdata-file
command_line /bin/mv /usr/local/pnp4nagios/var/service-perfdata /usr/local/pnp4nagios/var/spool/service-perfdata.$TIMET$
}
define command {
command_name process-host-perfdata-file
command_line /bin/mv /usr/local/pnp4nagios/var/host-perfdata /usr/local/pnp4nagios/var/spool/host-perfdata.$TIMET$
}
After that check icinga configuration
# icicheck
Total Warnings: 0
Total Errors: 0
# /etc/init.d/httpd restart
# /etc/init.d/icinga reload
Check for perfdata
# ls -la /usr/local/pnp4nagios/var/perfdata/localhost
In this directory you must see files: .rrd+.xml
Useful tools
Clear web cache
#/usr/bin/icinga-web-clearcache

Reference:-
https://wiki.icinga.org/display/howtos/Setting+up+Icinga+Web+on+RHEL

No comments:

Post a Comment