Difference between revisions of "Icinga"

From ArchWiki
Jump to: navigation, search
(Configure PHP)
(simplification and beautification of wikilinks, fixing whitespace, capitalization and section fragments (https://github.com/lahwaacz/wiki-scripts/blob/master/link-checker.py (interactive)))
 
(20 intermediate revisions by 11 users not shown)
Line 1: Line 1:
[[Category:Daemons and system services]]
+
[[Category:Network monitoring]]
[[Category:Networking]]
+
{{Article summary start}}
+
{{Article summary text|A short installation and configuration guide for the service and network monitoring program Icinga}}
+
{{Article summary end}}
+
 
+
 
[http://www.icinga.org/ Icinga] is an open source host, service and network monitoring program. It monitors specified hosts and services, alerting you to any developing issues, errors or improvements. This article describes the installation and configuration of Icinga.
 
[http://www.icinga.org/ Icinga] is an open source host, service and network monitoring program. It monitors specified hosts and services, alerting you to any developing issues, errors or improvements. This article describes the installation and configuration of Icinga.
  
==Installation==
+
== Installation ==
  
Follow [[Web Application Package Guidelines#Install Web Application Package|Install Web Application Package]]  
+
Follow [[Web application package guidelines#Install web application package|Install Web Application Package]]  
  
Install {{AUR|icinga}} from the [[AUR]].
+
Before you install the package create the user {{ic|icinga:icinga}} with these commands:
 +
# groupadd -g 667 icinga
 +
# useradd -u 667 -g icinga -G http -d /dev/null -s /bin/false icinga
 +
Install {{AUR|icinga}} or {{AUR|icinga2}} from the [[AUR]].
  
Users may also want to install {{AUR|nagios-plugins}}.
+
Users may also want to install {{Pkg|monitoring-plugins}} from the Community repositories.
  
==Icinga Configuration==
+
== Icinga configuration ==
  
 
Copy the sample config files as root:
 
Copy the sample config files as root:
  
  # cd /etc/icinga
+
# cd /etc/icinga
  # cp cgi.cfg.sample cgi.cfg
+
# cp cgi.cfg.sample cgi.cfg
  # cp resource.cfg.sample resource.cfg
+
# cp resource.cfg.sample resource.cfg
  # cp icinga.cfg.sample icinga.cfg
+
# cp icinga.cfg.sample icinga.cfg
  # cp objects/commands.cfg.sample objects/commands.cfg
+
# cp objects/commands.cfg.sample objects/commands.cfg
  # cp objects/contacts.cfg.sample objects/contacts.cfg
+
# cp objects/contacts.cfg.sample objects/contacts.cfg
  # cp objects/localhost.cfg.sample objects/localhost.cfg
+
# cp objects/localhost.cfg.sample objects/localhost.cfg
  # cp objects/templates.cfg.sample objects/templates.cfg
+
# cp objects/templates.cfg.sample objects/templates.cfg
  # cp objects/timeperiods.cfg.sample objects/timeperiods.cfg
+
# cp objects/timeperiods.cfg.sample objects/timeperiods.cfg
 +
 
 +
Edit {{ic|/etc/icinga/resource.cfg}}:
 +
{{hc|head=/etc/icinga/resource.cfg|
 +
output=# Default monitoring plugins
 +
$USER1$=/usr/lib/monitoring-plugins
 +
# or legacy Nagios plugins
 +
#$USER1$=/usr/share/nagios/libexec
 +
}}
 +
 
 +
== Icinga2 configuration ==
  
Edit /etc/icinga/resource.cfg
+
By default Icinga 2 uses the following files and directories:
  
  $USER1$=/usr/share/nagios/libexec
+
# /etc/icinga2                 Contains Icinga 2 configuration files.
 +
# /etc/init.d/icinga2         The Icinga 2 init script.
 +
# /usr/sbin/icinga2*         The Icinga 2 binary.
 +
# /usr/share/doc/icinga2 Documentation files that come with Icinga 2.
 +
# /usr/share/icinga2/include The Icinga Template Library and plugin command configuration.
 +
# /var/run/icinga2         PID file.
 +
# /var/run/icinga2/cmd         Command pipe and Livestatus socket.
 +
# /var/cache/icinga2         status.dat/objects.cache, icinga2.debug files
 +
# /var/spool/icinga2         Used for performance data spool files.
 +
# /var/lib/icinga2         Icinga 2 state file, cluster log, local CA and configuration files.
 +
# /var/log/icinga2         Log file location and compat/ directory for the CompatLogger feature.
  
==Webserver Configuration==
+
== Webserver configuration ==
  
 
Create htpasswd.users file with a username and password.
 
Create htpasswd.users file with a username and password.
  
  # htpasswd -c /etc/icinga/htpasswd.users icingaadmin
+
# htpasswd -c /etc/icinga/htpasswd.users icingaadmin
  
 
If you define another user foo, you need grant access permission to that user. Edit /etc/icinga/cgi.cfg
 
If you define another user foo, you need grant access permission to that user. Edit /etc/icinga/cgi.cfg
  
  authorized_for_system_information=icingaadmin,foo
+
authorized_for_system_information=icingaadmin,foo
  authorized_...
+
authorized_...
  ...
+
...
  
===Additional Nginx Configuration===
+
=== Additional Nginx configuration ===
  
Configure Authentication
+
Configure Authentication:
  
 
   location /icinga/ {
 
   location /icinga/ {
 +
    alias                  /usr/share/webapps/icinga/;
 
     auth_basic              "Restricted";
 
     auth_basic              "Restricted";
 
     auth_basic_user_file    /etc/icinga/htpasswd.users;
 
     auth_basic_user_file    /etc/icinga/htpasswd.users;
 
   }
 
   }
  
Configure CGI
+
Configure CGI:
  
     location ~ \.cgi$ {
+
     location ~ ^/icinga/(.*)\.cgi$ {
       fastcgi_pass   unix:/var/run/fcgiwrap.sock;
+
      root          /usr/share/webapps/;
 +
       fastcgi_pass   unix:/var/run/fcgiwrap.sock;
 
       include        fastcgi.conf;
 
       include        fastcgi.conf;
 
       fastcgi_param  AUTH_USER          $remote_user;
 
       fastcgi_param  AUTH_USER          $remote_user;
Line 63: Line 83:
 
     }
 
     }
  
==Icinga-web==
+
== Icinga-web ==
  
> Follow [[Web Application Package Guidelines#Install Web Application Package|Install Web Application Package]]  
+
Follow [[Web application package guidelines#Install web application package|Install Web Application Package]]  
  
Install {{aur|icinga-web}} from the [[AUR]].
+
Install {{AUR|icinga-web}} from the [[AUR]].
  
===Configure IDOUtils===
+
=== Configure IDOUtils ===
 
    
 
    
 
   # cd /etc/icinga
 
   # cd /etc/icinga
 
   # mv idomod.cfg-sample idomod.cfg
 
   # mv idomod.cfg-sample idomod.cfg
 
   # mv ido2db.cfg-sample ido2db.cfg
 
   # mv ido2db.cfg-sample ido2db.cfg
 +
 
 +
  # cd /etc/icinga/modules
 +
  # mv idoutils.cfg-sample idoutils.cfg
 
    
 
    
 
   ! Database Setup
 
   ! Database Setup
Line 79: Line 102:
 
   (Mysql)
 
   (Mysql)
 
   $ mysql -u root -p
 
   $ mysql -u root -p
   > CREATE USER 'icinga' IDENTIFIED BY 'icinga';
+
   > CREATE USER 'icinga'@'localhost' IDENTIFIED BY 'icinga';
 
   > CREATE DATABASE icinga;
 
   > CREATE DATABASE icinga;
 
   > GRANT USAGE ON icinga.* TO 'icinga'@'localhost' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0;
 
   > GRANT USAGE ON icinga.* TO 'icinga'@'localhost' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0;
Line 89: Line 112:
 
   $ mysql -u root -p icinga < /usr/share/icinga/idoutils/db/mysql/mysql.sql
 
   $ mysql -u root -p icinga < /usr/share/icinga/idoutils/db/mysql/mysql.sql
  
===Configure WebServer===
+
=== Configure web server ===
  
 
Example config files are located at
 
Example config files are located at
Line 96: Line 119:
 
   /etc/icinga-web/nginx.example.conf
 
   /etc/icinga-web/nginx.example.conf
  
====Configure PHP====
+
If you get 503 'Access denied' errors, check in these configuration files to see if you're allowed to visit the page:
 +
  Order allow,deny
 +
  Allow from all
 +
in sections ''<Directory "/usr/local/icinga-web/lib/ext3/">'' and ''<Directory "/usr/local/icinga-web/pub/">''.
  
Edit /etc/php.ini
+
==== Configure PHP ====
 +
 
 +
Edit {{ic|/etc/php.ini}}
  
 
   open_basedir = ...:/usr/share/icinga-web:/var/cache/icinga-web:/var/log/icinga
 
   open_basedir = ...:/usr/share/icinga-web:/var/cache/icinga-web:/var/log/icinga
Line 105: Line 133:
 
   extension=sockets.so
 
   extension=sockets.so
  
====Confiure Database====
+
==== Configure database ====
  
=====Mysql=====
+
===== MySQL =====
  
  ! Create database and grants.
+
! Create database and grants.
  # mysql -u root -p
+
# mysql -u root -p
  > CREATE USER 'icinga_web' IDENTIFIED BY 'icinga_web';
+
> CREATE USER 'icinga_web'@'localhost' IDENTIFIED BY 'icinga_web';
  > CREATE DATABASE icinga_web;
+
> CREATE DATABASE icinga_web;
  > GRANT USAGE ON icinga_web.* TO 'icinga_web'@'localhost' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0;
+
> GRANT USAGE ON icinga_web.* TO 'icinga_web'@'localhost' 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';
+
> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, ALTER, INDEX ON icinga_web.* TO 'icinga_web'@'localhost';
  > quit
+
> quit
 
    
 
    
 
   ! Import the schema.
 
   ! Import the schema.
  # mysql -u root -p icinga_web < /usr/share/icinga-web/etc/schema/mysql.sql
+
# mysql -u root -p icinga_web < /usr/share/icinga-web/etc/schema/mysql.sql
  
===Finally===
+
=== Finally ===
  
  ! Start IDOUtils
+
! Start IDOUtils
  # systemctl start ido2db
+
# systemctl start ido2db
   
+
  ! Start Icinga
+
! Start Icinga
  # systemctl start icinga
+
# systemctl start icinga
   
+
  ! Start Mysql
+
! Start Mysql
  # systemctl start mysqld
+
# systemctl start mysqld
   
+
  ! Start Web Server
+
! Start Web Server
  # systemctl start httpd or nginx
+
# systemctl start httpd or nginx
   
+
  ! goto http://localhost/icinga-web
+
! goto http://localhost/icinga-web
  > login with 'root' and 'password'
+
> login with 'root' and 'password'
  
==Upgrade database==
+
== Upgrade database ==
  
A new version usually requires an upgrade of the database. You find the sql upgrade scripts in  
+
A new version usually requires an upgrade of the database. You find the sql upgrade scripts in:
  /usr/share/icinga/idoutils/db/mysql/upgrade
+
/usr/share/icinga/idoutils/db/mysql/upgrade
  /usr/share/icinga-web/etc/schema/updates/mysql
+
/usr/share/icinga-web/etc/schema/updates/mysql
Commands to upgrade with these scripts are
+
Commands to upgrade with these scripts are:
  # mysql -u root -p icinga < ./mysql-upgrade-1.8.0.sql  
+
# mysql -u root -p icinga < ./mysql-upgrade-1.8.0.sql  
  # mysql -u root -p icinga_web < ./mysql_v1-7-2_to_v1-8-0.sql
+
# mysql -u root -p icinga_web < ./mysql_v1-7-2_to_v1-8-0.sql
  # systemctl --system daemon-reload
+
# systemctl --system daemon-reload
  # systemctl restart icinga
+
# systemctl restart icinga
  
==See also==
+
== See also ==
  
* [http://www.icinga.org/ icinga.org] Official website
+
* [http://www.icinga.org/ icinga.org] - Official website
* [http://www.nagiosplugins.org/ Nagios Plugins] the home of the official plugins  
+
* [https://www.monitoring-plugins.org/ monitoring-plugins] - Default plugins for Icinga and other monitoring applications
* [[Wikipedia:Icinga|wikipedia.org]] Wikipedia article
+
* [http://www.nagiosplugins.org/ Nagios Plugins] - The home of the legacy plugins  
* [http://www.nagiosexchange.org NagiosExchange] overview of plugins, addons, mailing lists for Icinga
+
* [[Wikipedia:Icinga|wikipedia.org]] - Wikipedia article
 +
* [http://www.nagiosexchange.org NagiosExchange] - Overview of plugins, addons, mailing lists for Icinga

Latest revision as of 16:16, 20 September 2015

Icinga is an open source host, service and network monitoring program. It monitors specified hosts and services, alerting you to any developing issues, errors or improvements. This article describes the installation and configuration of Icinga.

Installation

Follow Install Web Application Package

Before you install the package create the user icinga:icinga with these commands:

# groupadd -g 667 icinga
# useradd -u 667 -g icinga -G http -d /dev/null -s /bin/false icinga

Install icingaAUR or icinga2AUR from the AUR.

Users may also want to install monitoring-plugins from the Community repositories.

Icinga configuration

Copy the sample config files as root:

# cd /etc/icinga
# cp cgi.cfg.sample cgi.cfg
# cp resource.cfg.sample resource.cfg
# cp icinga.cfg.sample icinga.cfg
# cp objects/commands.cfg.sample objects/commands.cfg
# cp objects/contacts.cfg.sample objects/contacts.cfg
# cp objects/localhost.cfg.sample objects/localhost.cfg
# cp objects/templates.cfg.sample objects/templates.cfg
# cp objects/timeperiods.cfg.sample objects/timeperiods.cfg

Edit /etc/icinga/resource.cfg:

/etc/icinga/resource.cfg
# Default monitoring plugins
$USER1$=/usr/lib/monitoring-plugins
# or legacy Nagios plugins 
#$USER1$=/usr/share/nagios/libexec

Icinga2 configuration

By default Icinga 2 uses the following files and directories:

# /etc/icinga2	                Contains Icinga 2 configuration files.
# /etc/init.d/icinga2	        The Icinga 2 init script.
# /usr/sbin/icinga2*	        The Icinga 2 binary.
# /usr/share/doc/icinga2	Documentation files that come with Icinga 2.
# /usr/share/icinga2/include	The Icinga Template Library and plugin command configuration.
# /var/run/icinga2	        PID file.
# /var/run/icinga2/cmd	        Command pipe and Livestatus socket.
# /var/cache/icinga2	        status.dat/objects.cache, icinga2.debug files
# /var/spool/icinga2	        Used for performance data spool files.
# /var/lib/icinga2	        Icinga 2 state file, cluster log, local CA and configuration files.
# /var/log/icinga2	        Log file location and compat/ directory for the CompatLogger feature.

Webserver configuration

Create htpasswd.users file with a username and password.

# htpasswd -c /etc/icinga/htpasswd.users icingaadmin

If you define another user foo, you need grant access permission to that user. Edit /etc/icinga/cgi.cfg

authorized_for_system_information=icingaadmin,foo
authorized_...
...

Additional Nginx configuration

Configure Authentication:

 location /icinga/ {
   alias                   /usr/share/webapps/icinga/;
   auth_basic              "Restricted";
   auth_basic_user_file    /etc/icinga/htpasswd.users;
 }

Configure CGI:

   location ~ ^/icinga/(.*)\.cgi$ {
     root           /usr/share/webapps/;
     fastcgi_pass   unix:/var/run/fcgiwrap.sock;
     include        fastcgi.conf;
     fastcgi_param  AUTH_USER          $remote_user;
     fastcgi_param  REMOTE_USER        $remote_user;
   }

Icinga-web

Follow Install Web Application Package

Install icinga-webAUR from the AUR.

Configure IDOUtils

 # cd /etc/icinga
 # mv idomod.cfg-sample idomod.cfg
 # mv ido2db.cfg-sample ido2db.cfg
 
 # cd /etc/icinga/modules
 # mv idoutils.cfg-sample idoutils.cfg
 
 ! Database Setup
 
 (Mysql)
 $ mysql -u root -p
 > CREATE USER 'icinga'@'localhost' IDENTIFIED BY 'icinga';
 > CREATE DATABASE icinga;
 > GRANT USAGE ON icinga.* TO 'icinga'@'localhost' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0;
 > GRANT SELECT , INSERT , UPDATE , DELETE, DROP, CREATE VIEW, INDEX
  ON icinga.* TO 'icinga'@'localhost';
 > FLUSH PRIVILEGES;
 > quit
 
 $ mysql -u root -p icinga < /usr/share/icinga/idoutils/db/mysql/mysql.sql

Configure web server

Example config files are located at

 /etc/icinga-web/apache.example.conf
 /etc/icinga-web/nginx.example.conf

If you get 503 'Access denied' errors, check in these configuration files to see if you're allowed to visit the page:

 Order allow,deny
 Allow from all

in sections <Directory "/usr/local/icinga-web/lib/ext3/"> and <Directory "/usr/local/icinga-web/pub/">.

Configure PHP

Edit /etc/php.ini

 open_basedir = ...:/usr/share/icinga-web:/var/cache/icinga-web:/var/log/icinga
 extension=pdo_mysql.so
 extension=xsl.so
 extension=sockets.so

Configure database

MySQL
! Create database and grants.
# mysql -u root -p
> CREATE USER 'icinga_web'@'localhost' IDENTIFIED BY 'icinga_web';
> CREATE DATABASE icinga_web;
> GRANT USAGE ON icinga_web.* TO 'icinga_web'@'localhost' 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
  
 ! Import the schema.
# mysql -u root -p icinga_web < /usr/share/icinga-web/etc/schema/mysql.sql

Finally

! Start IDOUtils
# systemctl start ido2db

! Start Icinga
# systemctl start icinga

! Start Mysql
# systemctl start mysqld

! Start Web Server
# systemctl start httpd or nginx

! goto http://localhost/icinga-web
> login with 'root' and 'password'

Upgrade database

A new version usually requires an upgrade of the database. You find the sql upgrade scripts in:

/usr/share/icinga/idoutils/db/mysql/upgrade
/usr/share/icinga-web/etc/schema/updates/mysql

Commands to upgrade with these scripts are:

# mysql -u root -p icinga < ./mysql-upgrade-1.8.0.sql 
# mysql -u root -p icinga_web < ./mysql_v1-7-2_to_v1-8-0.sql
# systemctl --system daemon-reload
# systemctl restart icinga

See also