This post describes the installation and configuration of the following software on FreeBSD.
Icinga is a fork of Nagios and is backward compatible.
PNP4Nagios is an addon which analyzes performance data provided by plugins and stores them automatically into RRD-databases.
NagiosQL is a web based administration tool.
Icinga
Install the software
# cd /usr/ports/ports-mgmt/portmaster # make clean all install # make clean # rehash # portmaster -d misc/rpl # rehash # portmaster -d net-mgmt/icinga # mv /usr/local/libexec/nagios /usr/local/libexec/nagios-before-icinga # ln -s /usr/local/libexec/icinga /usr/local/libexec/nagios # mv /var/spool/nagios /var/spool/nagios-before-icinga # ln -s /var/spool/icinga /var/spool/nagios
Prepare the Icinga environment
# cp /usr/local/etc/icinga/cgi.cfg-sample /usr/local/etc/icinga/cgi.cfg # cp /usr/local/etc/icinga/icinga.cfg-sample /usr/local/etc/icinga/icinga.cfg # cp /usr/local/etc/icinga/resource.cfg-sample /usr/local/etc/icinga/resource.cfg # rpl enable_environment_macros=0 enable_environment_macros=1 /usr/local/etc/icinga/icinga.cfg # rpl process_performance_data=0 process_performance_data=1 /usr/local/etc/icinga/icinga.cfg # rpl '#host_perfdata_command=process-host-perfdata' 'host_perfdata_command=process-host-perfdata' /usr/local/etc/icinga/icinga.cfg # rpl '#service_perfdata_command=process-service-perfdata' 'service_perfdata_command=process-service-perfdata' /usr/local/etc/icinga/icinga.cfg
Read the instructions on how to use Icinga
# cat /var/db/pkg/icinga-*/+DISPLAY
************************************************************************* Enable Icinga in /etc/rc.conf with the following line: icinga_enable="YES" Configuration templates are available in /usr/local/etc/icinga as *.cfg-sample files. Copy them to *.cfg files where required and edit to suit your needs. Documentation is available in HTML form in /usr/local/www/icinga/docs/. If you don't already have a web server running, you will need to install and configure one to finish off your Icinga installation. If you selected APACHE in Icinga's OPTION screen, the configuration is already installed as /usr/local/etc/apache22/extra/icinga.cfg and you only need to source the configuration file in Apache's config. If you like to use database backend with IDOutils the SQL scripts to setup the database have been installed in /usr/local/share/examples/icinga/idoutils/db/. *************************************************************************
Modify the Apache configuration file
Make sure you have enabled mod_suexec when you installed apache.
# /usr/local/sbin/httpd -f /usr/local/etc/apache22/httpd.conf -M | grep -i suexec ------------------------------ cut here ------------------------------ Syntax OK suexec_module (shared) ------------------------------ cut here ------------------------------ # vi /usr/local/etc/apache22/httpd.cfg ------------------------------ cut here ------------------------------ Include etc/apache22/extra/icinga.conf ------------------------------ cut here ------------------------------ # vi /usr/local/etc/apache22/extra/icinga.conf
------------------------------ cut here ------------------------------ SuexecUserGroup icinga icinga ScriptAlias /icinga/cgi-bin "/usr/local/www/icinga/cgi-bin" <Directory "/usr/local/www/icinga/cgi-bin"> # SSLRequireSSL Options ExecCGI AllowOverride None Order allow,deny Allow from all # Order deny,allow # Deny from all # Allow from 127.0.0.1 AuthName "Icinga Access" AuthType Basic AuthUserFile /usr/local/etc/icinga/htpasswd.users Require valid-user </Directory> Alias /icinga "/usr/local/www/icinga/" <Directory "/usr/local/www/icinga/"> # SSLRequireSSL Options None AllowOverride None Order allow,deny Allow from all # Order deny,allow # Deny from all # Allow from 127.0.0.1 AuthName "Icinga Access" AuthType Basic AuthUserFile /usr/local/etc/icinga/htpasswd.users Require valid-user </Directory> ------------------------------ cut here ------------------------------
PNP4Nagios
Install the software
# portmaster -d databases/rrdtool # portmaster -d lang/php5 # cd /usr/ports/net-mgmt/pnp # make clean all install # make NAGIOSUSER=icinga NAGIOSGROUP=icinga NAGIOSHTMURL=/icinga NAGIOSDIR=/var/spool/icinga clean all install # cp work/pnp4nagios-*/contrib/ssi/status-header.ssi /usr/local/www/icinga/ssi/status-header.ssi # make clean # cp /usr/local/etc/php.ini-production cp /usr/local/etc/php.ini # vi /usr/local/etc/apache22/httpd.cfg ------------------------------ cut here ------------------------------ AddType application/x-httpd-php .php AddType application/x-httpd-php-source .phps ------------------------------ cut here ------------------------------
Prepare the PNP4Nagios environment
# cp /usr/local/etc/pnp/background.pdf-sample /usr/local/etc/pnp/background.pdf # cp /usr/local/etc/pnp/misccommands.cfg-sample /usr/local/etc/pnp/misccommands.cfg # cp /usr/local/etc/pnp/nagios.cfg-sample /usr/local/etc/pnp/nagios.cfg # cp /usr/local/etc/pnp/process_perfdata.cfg-sample /usr/local/etc/pnp/process_perfdata.cfg # cp /usr/local/etc/pnp/rra.cfg-sample /usr/local/etc/pnp/rra.cfg # cp /usr/local/etc/pnp/check_commands/check_nrpe.cfg-sample /usr/local/etc/pnp/check_commands/check_nrpe.cfg # rpl /usr/local/nagios/var/rw/nagios.cmd /var/spool/icinga/rw/icinga.cmd /usr/local/libexec/check_pnp_rrds.pl # vi /usr/local/etc/icinga/resource.cfg ------------------------------ cut here ------------------------------ $USER5$=/usr/local/bin $USER7$=/usr/local/libexec ------------------------------ cut here ------------------------------
Read the instructions on how to use PNP4Nagios
# cat /var/db/pkg/pnp-*/+DISPLAY
======================================================================== You just installed/upgraded PNP graphing tool for Nagios. You will need to read the documentation at http://docs.pnp4nagios.org/pnp-0.6/doc_complete both for new installations and upgrades from 0.4, since you will need to tweak your Nagios and PNP configuration according to the 0.6.x recipes. We recommend to start with the following restrictive Apache configuration for the PNP area: {{{ # PNP graphing tool Alias /icinga/pnp /usr/local/www/pnp <Directory "/usr/local/www/pnp/"> Order deny,allow Allow from all Deny from all AddHandler application/x-httpd-php .php DirectoryIndex index.php RewriteEngine on RewriteBase /icinga/pnp/ # Protect application and system files from being viewed RewriteRule ^(application|modules|system) - [F,L] # Allow any files or directories that exist to be displayed directly RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d # Rewrite all other URLs to index.php/URL RewriteRule .* index.php/$0 [PT,L] </Directory> }}} Create /usr/local/www/pnp/install.ignore to disable sanity check and start using PNP. Please, note that user who runs Apache processes should be able to read PNP RRD spool files from /var/spool/icinga/pnp/rrd so you should tune path permissions accordingly. Probably one could start from adding Apache user to the group 'icinga'. Remember to restart NPCD service after upgrade if you're using 'bulk' mode with NPCD. ========================================================================
Install suphp and modify the Apache configuration file
# portmaster -d -m 'WITH_SETID_MODE=force' www/suphp # cp /usr/local/etc/suphp.conf-example /usr/local/etc/suphp.conf # cp /usr/local/etc/php.ini-production /usr/local/etc/pnp/php.ini # rpl 'variables_order = "GPCS"' 'variables_order = "EGPCS"' /usr/local/etc/pnp/php.ini # vi /usr/local/etc/apache22/httpd.cfg ------------------------------ cut here ------------------------------ LoadModule suphp_module libexec/apache22/mod_suphp.so ------------------------------ cut here ------------------------------ # vi /usr/local/etc/apache22/extra/icinga.conf
------------------------------ cut here ------------------------------ suPHP_Engine on suPHP_UserGroup icinga icinga suPHP_AddHandler application/x-httpd-php suPHP_ConfigPath /usr/local/etc/pnp Alias /icinga/pnp /usr/local/www/pnp <Directory "/usr/local/www/pnp/"> Order deny,allow Allow from all Deny from all AddHandler application/x-httpd-php .php DirectoryIndex index.php RewriteEngine on RewriteBase /icinga/pnp/ # Protect application and system files from being viewed RewriteRule ^(application|modules|system) - [F,L] # Allow any files or directories that exist to be displayed directly RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d # Rewrite all other URLs to index.php/URL RewriteRule .* index.php/$0 [PT,L] </Directory> ------------------------------ cut here ------------------------------
NagiosQL
Install the software
# portmaster -d databases/mysql55-server # vi /etc/rc.conf ------------------------------ cut here ------------------------------ mysql_enable="YES" ------------------------------ cut here ------------------------------ # /bin/sh /usr/local/etc/rc.d/mysql-server start # portmaster -d www/php5-session # portmaster -d databases/php5-mysqli # portmaster -d devel/php5-gettext # portmaster -d security/php5-filter # portmaster -d net-mgmt/nagiosql # rpl 'cfg_file=' '#cfg_file=' /usr/local/etc/icinga/icinga.cfg # echo 'cfg_dir=/var/spool/icinga/nagiosql' >> /usr/local/etc/icinga/icinga.cfg # mkdir /var/spool/icinga/nagiosql # mkdir /var/spool/icinga/nagiosql/hosts # mkdir /var/spool/icinga/nagiosql/services # mkdir /var/spool/icinga/nagiosql/backup # mkdir /var/spool/icinga/nagiosql/backup/hosts # mkdir /var/spool/icinga/nagiosql/backup/services # chown -R icinga:icinga /var/spool/icinga/. # touch /usr/local/www/nagiosql/install/ENABLE_INSTALLER
Modify the Apache configuration file
# vi /usr/local/etc/apache22/extra/icinga.conf
------------------------------ cut here ------------------------------ Alias /nagiosql/ "/usr/local/www/nagiosql/" <Directory /usr/local/www/nagiosql> Order deny,allow Allow from all AuthType None Require all granted Satisfy Any </Directory> ------------------------------ cut here ------------------------------
Access the NagiosQL installation page to finish the installation on myserver
http://myserver/icinga/nagiosql/install/index.php
Check the NagiosQL documentation
Use nagiosql to customize the configuration of PNP4Nagios
Add the commands process-host-perfdata and process-service-perfdata
define command { command_name process-host-perfdata command_line $USER5$/perl $USER7$/process_perfdata.pl -d HOSTPERFDATA register 1 } define command { command_name process-service-perfdata command_line $USER5$/perl $USER7$/process_perfdata.pl register 1 }
Add the templates host-pnp and service-pnp
define host { name host-pnp action_url /icinga/pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=_HOST_' class='tips' rel='/icinga/pnp4nagios/index.php/popup?host=$HOSTNAME$&srv=_HOST_ register 0 }
define service { name service-pnp action_url /icinga/pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=$SERVICEDESC$' class='tips' rel='/icinga/pnp4nagios/index.php/popup?host=$HOSTNAME$&srv=$SERVICEDESC$ register 0 }