Difference between revisions of "Icinga"

From Amahi Wiki
Jump to: navigation, search
 
(26 intermediate revisions by 3 users not shown)
Line 1: Line 1:
Understand that without a web interface to do the configuration of objects the learning curve is large to configure Icinga for the first time.
+
{{MessageBox|
 +
backgroundcolor = #faa|
 +
image =Warning.png|
 +
heading =WARNING|
 +
message = This is recommended only for advanced users, proceed with caution.}}
 +
'''NOTE: ''' Understand that without a web interface to do the configuration of objects the learning curve is large to configure Icinga for the first time.
 +
 
 +
These instructions were modified from documentation already on the [http://docs.icinga.org/1.4.0/en/ Icinga Website].  They are geared toward installing Icinga v1.4.
 +
 
 +
<div style="display:block;float:right;clear:right;margin-left:1em;text-align:center">[[File:Icinga-screenshot.png|275px|right|thumb|alt=Icinga Web 2.0 Interface|Icinga Web 2.0 Interface Screenshot]]</div>
 +
 
 +
These instructions are the combined effort documented in the following Icinga Documentation pages:
 +
* [http://docs.icinga.org/1.4.0/en/ Icinga Version 1.4 Documentation]
 +
** [http://docs.icinga.org/1.4.0/en/quickstart-icinga.html Icinga Quickstart]
 +
** [http://docs.icinga.org/1.4.0/en/quickstart-idoutils.html Icinga with IDOUtils Quickstart]
 +
** [http://docs.icinga.org/1.4.0/en/icinga-web-scratch.html Installation of the Icinga-Web Frontend]
 +
** [http://docs.icinga.org/1.4.0/en/icinga-api.html Installation and use of the Icinga API]
 +
** [http://docs.icinga.org/1.2.0/en/icinga-web-pnp.html Integration of PNP4Nagios into Icinga Web]
 +
* [https://wiki.icinga.org/display/howtos/Setting+up+icinga-mobile Setting up icinga-mobile]
 +
* [http://docs.pnp4nagios.org/pnp-0.6/start PNP4Nagios Documenation]
 +
 
 +
If you have any questions then please contact me.
 +
 
 +
-- [[User:Sag47|Sag47]] 22:37, 18 July 2011 (PDT)
  
 
= What is Icinga? =
 
= What is Icinga? =
Line 14: Line 37:
 
* Fedora 14
 
* Fedora 14
 
* Amahi set up and running
 
* Amahi set up and running
* and the following packages installed
+
* and update your HDA Server and install all of the prereqs for Icinga/Icinga-web
{{Code|yum groupinstall "Development Tools" "Legacy Software Development"}}
+
'''NOTE:''' If there is a kernel update then you should restart your machine after running yum update and start these instructions over.
 +
 
 +
<pre>
 +
yum check-update
 +
yum update -y
 +
yum groupinstall "Development Tools" "Legacy Software Development" -y
 +
yum install <nowiki>httpd httpd-devel gcc glibc glibc-common gd gd-devel libjpeg libjpeg-devel libpng libpng-devel mysql mysql-server libdbi libdbi-devel libdbi-drivers libdbi-dbd-mysql net-snmp net-snmp-devel net-snmp-utils php php-cli php-pear php-xmlrpc php-xsl php-pdo php-gd php-ldap php-mysql php-mysql php-soap java-1.6.0-openjdk java-1.6.0-openjdk-devel zip unzip</nowiki> -y</PRE>
 +
 
 +
== Create a Webapp ==
 +
Go to your HDA CP (HDA Control Panel) and go to Apps > Webapps and click New Webapp.  Name it "icinga" without quotes.
 +
Root path should be /var/hda/web-apps/icinga (which is automatically generated by Amahi).
 +
 
 +
Create /var/hda/web-apps/icinga/html/index.html and give it the following contents.
 +
<pre><nowiki><html>
 +
<head>
 +
<title>Icinga Monitoring Server</title>
 +
<meta HTTP-EQUIV="REFRESH" content="0; url=/icinga/">
 +
</head>
 +
<body>
 +
</body>
 +
</html></nowiki></pre>
 +
 
 +
'''NOTE:''' Icinga will install to /usr/local/icinga.  Icinga Web will install to /usr/local/icinga-web
 +
 
 +
== Download required source tarballs ==
 +
Download the following packages from the [http://sourceforge.net/projects/icinga/files/ Icinga Project Page].
 +
* icinga/icinga-1.4.2.tar.gz or latest 1.4.x
 +
* icinga-web/icinga-web-1.4.1.tar.gz or latest 1.4.x
 +
* icinga-mobile/icinga-mobile-0.1.0.zip or latest
 +
Download the following packages from the [http://sourceforge.net/projects/nagiosplug/files/ Nagios Plugin Project Page].
 +
* nagiosplug/1.4.15/nagios-plugins-1.4.15.tar.gz or latest
 +
Download the [https://git.icinga.org/index?p=icinga-api.git;a=snapshot;h=refs/heads/master;sf=tgz latest Icinga API] from git snapshot as seen in the [http://docs.icinga.org/1.4.0/en/icinga-api.html Icinga API] documentation.
 +
 
 +
Move all source tarballs to /usr/local/src/ on your HDA server.
 +
 
 +
== Compile and install Icinga with IDOUtils ==
 +
Create an icinga user, icinga-cmd group, and add the apache user and icinga user to the icinga-cmd group.
 +
<pre>
 +
useradd -m icinga
 +
groupadd icinga-cmd
 +
usermod -a -G icinga-cmd icinga
 +
usermod -a -G icinga-cmd apache</pre>
 +
 
 +
Now lets do some compiling.
 +
<pre>
 +
cd /usr/local/src/
 +
tar -xzf icinga-1.4.2.tar.gz
 +
cd icinga-1.4.2
 +
./configure <nowiki>--with-command-group=icinga-cmd --enable-idoutils --enable-event-broker</nowiki>
 +
make all
 +
make fullinstall
 +
</pre>
 +
Edit the ''/usr/local/icinga/etc/objects/contacts.cfg'' config file with your favorite editor and change the email address associated with the icingaadmin contact definition to the address you'd like to use for receiving alerts.
 +
<pre>
 +
vim /usr/local/icinga/etc/objects/contacts.cfg
 +
cp /usr/local/icinga/etc/ido2db.cfg-sample /usr/local/icinga/etc/ido2db.cfg
 +
cp /usr/local/icinga/etc/idomod.cfg-sample /usr/local/icinga/etc/idomod.cfg
 +
cp /usr/local/icinga/etc/modules/idoutils.cfg-sample /usr/local/icinga/etc/modules/idoutils.cfg</pre>
 +
 
 +
Create the icinga db/user/pass for IDOUtils to use and import the mysql database (you should still be in ''/usr/local/src/icinga-1.4.2'' working directory).
 +
<pre>hda-create-db-and-user icinga
 +
mysql -u icinga -picinga icinga < module/idoutils/db/mysql/mysql.sql</pre>
 +
 
 +
Configure the password for the icinga directory.
 +
<pre>htpasswd -c /usr/local/icinga/etc/htpasswd.users icingaadmin</pre>
 +
 
 +
Configure the Apache config located in ''/etc/httpd/conf.d/''
 +
 
 +
<pre>
 +
ls /etc/httpd/conf.d/ <nowiki>|</nowiki> grep icinga
 +
#you should see two files.  Something like 1002-icinga.conf and icinga.conf
 +
cat /etc/httpd/conf.d/icinga.conf >> /etc/httpd/conf.d/1002-icinga.conf
 +
#Now edit /etc/httpd/conf.d/1002-icinga.conf
 +
vim /etc/httpd/conf.d/1002-icinga.conf
 +
#and move </VirtualHost> from the middle of the file to the end.
 +
#be sure to confirm that the contents of icinga.conf are within 1002-icinga.conf before removing it
 +
rm -f /etc/httpd/conf.d/icinga.conf</pre>
 +
 
 +
Start icinga, idoutils and restart the apache server.
 +
<pre>service icinga start
 +
service ido2db start
 +
service httpd restart</pre>
 +
 
 +
Visit http://icinga and make sure that it is currently working.
 +
 
 +
'''Note:''' http://icinga should redirect to http://icinga/icinga and your localhost (which is the Amahi HDA) will show up as down.
  
== Installation ==
+
== Install Nagios Plugins ==
Follow the [http://docs.icinga.org/1.4.0/en/quickstart-icinga.html Quickstart Installation Guide for Icinga] to compile and install Icinga and common Nagios plugins.
+
Time to compile again!
 +
<pre>
 +
cd /usr/local/src/
 +
tar -xzf nagios-plugins-1.4.15.tar.gz
 +
cd nagios-plugins-1.4.15
 +
./configure <nowiki>--prefix=/usr/local/icinga --with-cgiurl=/icinga/cgi-bin --with-htmurl=/icinga --with-nagios-user=icinga --with-nagios-group=icinga</nowiki>
 +
make
 +
make install
 +
service icinga restart</pre>
 +
Now visit http://icinga/ and click on Service Detail in the menu on the left under Status.  After about 5 mins everything should slowly start turning green.
  
Once you have Icinga running when you attempt to access the web interface you should get permission denied. That is okay because we're going to fix that now.
+
== Install the latest Icinga API ==
 +
Don't worry, there's nothing to compile here.  But you still have to configure and install the Icinga API.
 +
<pre>cd /usr/local/src/
 +
tar -xzf icinga-api-refs-heads-master.tar.gz
 +
cd icinga-api
 +
./configure <nowiki>--datarootdir=/usr/local/icinga/share --sysconfdir=/usr/local/icinga/etc --with-command-user=icinga-cmd --with-command-group=icinga-cmd --with-icinga-user=icinga --with-icinga-group=icinga --with-web-user=apache --with-web-group=apache</nowiki>
 +
make install</pre>
  
Visit your hda at http://hda because now you have to set up a webappI know that this is in reverse order and that it should be compiled for the webapp directory but I'm still new to Amahi and not new to other things. So more detailed and correct instructions will come later.
+
== Install the Icinga Web 2.0 Interface ==
 +
Create the Icinga Web db/user/pass.
 +
<pre>hda-create-db-and-user icinga_web</pre>
 +
Configure and install the new web interface.
 +
<pre>cd /usr/local/src/
 +
tar -xzf icinga-web-1.4.1.tar.gz
 +
cd icinga-web-1.4.1
 +
./configure <nowiki>--with-web-user=apache --with-web-group=apache --with-web-apache-path=/etc/httpd/conf.d</nowiki>
 +
make install
 +
make install-apache-config
 +
make db-initialize
 +
#Choose y for every question asked by make db-initialize</pre>
 +
Now we need to do the same thing with the virtual server as we did originally with the Icinga install so that it shows up for our Virtual Host.
 +
<pre>ls /etc/httpd/conf.d/ <nowiki>|</nowiki> grep icinga
 +
#you should see two filesSomething like 1002-icinga.conf and icinga-web.conf
 +
cat /etc/httpd/conf.d/icinga-web.conf >> /etc/httpd/conf.d/1002-icinga.conf
 +
#Now edit /etc/httpd/conf.d/1002-icinga.conf
 +
vim /etc/httpd/conf.d/1002-icinga.conf
 +
#and move </VirtualHost> from the middle of the file to the end.
 +
#be sure to confirm that the contents of icinga-web.conf are within 1002-icinga.conf before removing it
 +
rm -f /etc/httpd/conf.d/icinga-web.conf*</pre>
 +
Restart icinga, idoutils, and apache.
 +
<pre>service icinga restart
 +
service httpd restart</pre>
 +
Go to the webpath (http://icinga/icinga-web/) and check if the web interface starts without exceptions (database connections web and api). You can login with user 'root' and password 'password'.
  
Anyway, go to http://hda/setup?sub=webapps&tab=app and create a new webapp and call it icinga.
+
== Install the Icinga Mobile Interface ==
 +
Time for more source work!
 +
<pre>cd /usr/local/src/
 +
#if you want the latest then run git clone http://git.icinga.org/icinga-mobile.git
 +
unzip icinga-mobile-0.1.0.zip
 +
cd icinga-mobile
 +
autoconf
 +
./configure <nowiki>--with-web-user=apache --with-web-group=apache --with-web-apache-path=/etc/httpd/conf.d</nowiki>
 +
make compile
 +
make install
 +
make install-apache-config</pre>
  
Now it's time to go into the terminal.  All commands will be run as root and lines that start with # are comments.
+
Now we need to do the same thing with the virtual server as we did originally with the Icinga install so that it shows up for our Virtual Host.
{{Code|ls /etc/httpd/conf.d/ <nowiki>|</nowiki> grep icinga
+
<pre>ls /etc/httpd/conf.d/ <nowiki>|</nowiki> grep icinga
#you should see two files.  Something like 1007-icinga.conf and icinga.conf
+
#you should see two files.  Something like 1002-icinga.conf and icinga-mobile.conf
cat /etc/httpd/conf.d/icinga.conf >> /etc/httpd/conf.d/1007-icinga.conf
+
cat /etc/httpd/conf.d/icinga-mobile.conf >> /etc/httpd/conf.d/1002-icinga.conf
#Now edit /etc/httpd/conf.d/1007-icinga.conf
+
#Now edit /etc/httpd/conf.d/1002-icinga.conf
vim /etc/httpd/conf.d/1007-icinga.conf
+
vim /etc/httpd/conf.d/1002-icinga.conf
 
#and move </VirtualHost> from the middle of the file to the end.
 
#and move </VirtualHost> from the middle of the file to the end.
#be sure to confirm that the contents of icinga.conf are within 1007-icinga.conf before removing it
+
#be sure to confirm that the contents of icinga-mobile.conf are within 1002-icinga.conf before removing it
rm /etc/httpd/conf.d/icinga.conf
+
rm -f /etc/httpd/conf.d/icinga-mobile.conf*</pre>
}}
+
Restart icinga, idoutils, and apache.
Now you should have a 1007-icinga.conf file similar to the following (not exact)
+
<pre>service httpd restart</pre>
{{Text|Text=<pre><nowiki><VirtualHost *:80>
+
 
 +
Now go to http://icinga/icinga-web and log in as root.  Click on Admin > Users and Add new user.  Give it the following settings.
 +
* User name: mobile
 +
* Auth via: auth_key
 +
* password: whateveryouwant (different the the Api authkey)
 +
* Authkey for Api (optional): mobileaccess
 +
* Make sure that the moble user is part of these groups: appkit_user, icinga_user
 +
* The rest of the settings you can fill in what ever you want.
 +
 
 +
Now on your iPhone or Android phone visit http://icinga/icinga-mobile.  After it says request failed click on config.  Change the Icinga Web URL to reflect your server name.  For instance my server is icinga.home so your URL should be http://icinga.home/icinga-web.  Make the Auth key "mobileaccess" without quotes.
 +
=== Known Issues ===
 +
* You have to make the server for icinga-web the exact same as what you access icinga-mobile on the config page of Icinga Mobile.  For security reasons cross domain AJAX requests are denied.  Example if you're accessing http://xyz/icinga-mobile then Icinga Web URL must be http://xyz/icinga-web.  You can change the default credentials in Icinga Mobile from the instructions in the [https://wiki.icinga.org/display/howtos/Setting+up+icinga-mobile#Settingupicinga-mobile-Changingdefaultcredentials%28optional%29 Icinga Wiki] by editing ''/usr/local/src/icinga-mobile/lib/Model/IcingaConfiguration.js''.  You will have to recompile and reinstall Icinga Mobile (without running "make install-apache-config").
 +
* Icinga Mobile works neither with the desktop or mobile version of Firefox.
 +
* You may have to visit your fully qualified domain name on your mobile phone to access Icinga.  For instance going to http://icinga.home/icinga-mobile instead of http://icinga/icinga-mobile because the mobile browsers will attempt to search it like icinga is a keyword for a search engine.
 +
 
 +
= Overview and further Amahi integration =
 +
To get a better understanding of how Icinga works [http://www.youtube.com/watch?v=jLqhXvGTazI view this video].  So basically you have the Icinga core which runs locally on the machine.  Then you access the core using the Classic Web Interface, Icinga Web 2.0, and Icinga Mobile.
 +
 
 +
== Add Icinga servers to the Admin CP ==
 +
You will want to add two servers to your HDA Admin Control Panel.  One for Icinga and one for IDOUtils.
 +
<pre><nowiki>echo 'Server.create(:name => "icinga", :comment => "Icinga")' | (cd /var/hda/platform/html && ./script/console production)</nowiki></pre>
 +
 
 +
<pre><nowiki>echo 'Server.create(:name => "ido2db", :comment => "IDOUtils")' | (cd /var/hda/platform/html && ./script/console production)</nowiki></pre>
 +
 
 +
Now go to http://hda and visit Setup > Settings > Servers and you will see Icinga and IDOUtils showing up at the bottom.
 +
 
 +
== Smarter index.html ==
 +
Wouldn't it be awesome if when you visit http://icinga that it would default to the classic interface if JavaScript is disabled, default to web 2.0 interface if Javascript is enabled, or default to the mobile interface if you're visiting from a mobile phone?  Well you can if you configure your server right. 
 +
# Browse to ''/var/hda/web-apps/icinga/html/''.
 +
# Visit my [http://sourceforge.net/projects/webtechtools/files/Javascript%20Browser%20Detect/ sourceforge project] and download the latest browser_detect.js_XXXX.
 +
# Unzip browser_detect.js to ''/var/hda/web-apps/icinga/html/''
 +
# Create /var/hda/web-apps/icinga/html/index.html with the following contents.
 +
<pre><nowiki><html>
 +
<head>
 +
<title>Icinga Monitoring Server</title>
 +
<meta HTTP-EQUIV="REFRESH" content="1; url=/icinga/">
 +
<script type="text/javascript" src="browser_detect.js"></script>
 +
<script type="text/javascript">
 +
window.top.location.href=(isMobile)?"/icinga-mobile/":"/icinga-web/";
 +
</script>
 +
</head>
 +
<body>
 +
</body>
 +
</html></nowiki></pre>
 +
 
 +
= Icinga Plugins =
 +
== PNP4Nagios ==
 +
=== About ===
 +
This documentation is the combined effort from:
 +
* [http://docs.pnp4nagios.org/pnp-0.6/start PNP4Nagios Documentation] (click this to learn more about PNP4Nagios)
 +
* [http://docs.icinga.org/1.2.0/en/icinga-web-pnp.html Integration of PNP4Nagios into Icinga Web]
 +
=== Prerequisites ===
 +
* Icinga and all of its prerequisites.
 +
* Download latest [http://sourceforge.net/projects/pnp4nagios/files/PNP-0.6/ PNP4Nagios from sourceforge] and move it to ''/usr/local/src/''
 +
* Install the following packages
 +
<pre>yum install <nowiki>perl rrdtool rrdtool-perl</nowiki> -y</pre>
 +
 
 +
=== Set up PNP4Nagios ===
 +
More compiling!
 +
<pre>
 +
cd /usr/local/src/
 +
tar -xzf pnp4nagios-0.6.13.tar.gz
 +
cd pnp4nagios-0.6.13
 +
./configure <nowiki>--with-nagios-user=icinga --with-nagios-group=icinga --with-httpd-conf=/etc/httpd/conf.d</nowiki>
 +
make all
 +
make fullinstall</pre>
 +
 
 +
Change some PNP4Nagios settings
 +
<pre>sed -i 's/\/nagios\/cgi-bin/\/icinga\/cgi-bin/' /usr/local/pnp4nagios/etc/config.php</pre>
 +
 
 +
Apache integration for PNP4Nagios.
 +
<pre>
 +
cd /etc/httpd/conf.d/
 +
sed -i 's/nagios\/etc\/htpasswd.users/icinga\/etc\/htpasswd.users/' pnp4nagios.conf
 +
sed -i 's/Nagios Access/Icinga Access/' pnp4nagios.conf
 +
cat pnp4nagios.conf >> 1002-icinga.conf
 +
#Don't forget to move </VirtualHost> from the middle to the end of the file
 +
vim 1002-icinga.conf
 +
rm pnp4nagios.conf
 +
service httpd restart</pre>
 +
Visit http://icinga/pnp4nagios/ and make sure all tests pass.  Then remove the install.php file.
 +
<pre>rm /usr/local/pnp4nagios/share/install.php</pre>
 +
 
 +
Now enable processing performance data in Icinga.  Edit icinga.conf and set ''process_performance_data=1''.
 +
<pre>vim /usr/local/icinga/etc/icinga.cfg</pre>
 +
Uncommend the following lines in /usr/local/icinga/etc/icinga.cfg.
 +
<pre>
 +
host_perfdata_command=process-host-perfdata
 +
service_perfdata_command=process-service-perfdata}}
 +
Now create the process performance data commands (simply add them to the end of the file ''/usr/local/icinga/etc/objects/commands.cfg'')
 +
{{Text|Text=<pre><nowiki>define command{
 +
  command_name process-host-perfdata
 +
  command_line /usr/bin/perl /usr/local/pnp4nagios/libexec/process_perfdata.pl -d HOSTPERFDATA
 +
}
 +
define command{
 +
  command_name process-service-perfdata
 +
  command_line /usr/bin/perl /usr/local/pnp4nagios/libexec/process_perfdata.pl
 +
}</nowiki></pre></pre>
 +
Restart Icinga
 +
<pre>service icinga restart</pre>
 +
Now PNP4Nagios is installed.  You can visit PNP4Nagios by going to http://icinga/pnp4nagios
 +
 
 +
=== Integrating PNP4Nagios into Icinga ===
 +
Read [http://docs.pnp4nagios.org/pnp-0.6/webfe PNP4Nagios documentation] for integrating PNP4Nagios into the Icinga Classic web interface.  Read the [http://docs.icinga.org/1.2.0/en/icinga-web-pnp.html Icinga documentation] for integrating PNP4Nagios into the new Icinga Web 2.0 interface.
 +
==== Classic Interface ====
 +
Add the following lines to the top of ''/usr/local/icinga/etc/objects/templates.cfg''
 +
<pre><nowiki>define host{
 +
  name host-pnp
 +
  action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=_HOST_
 +
  register 0
 +
}
 +
 
 +
define service{
 +
  name srv-pnp
 +
  action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=$SERVICEDESC$
 +
  register 0
 +
}</nowiki></pre>
 +
Edit /usr/local/icinga/etc/objects/templates.cfg and within the ''generic-host'' definition add the following line underneath "''name generic-host''".
 +
<pre><nowiki>use host-pnp</nowiki></pre>
 +
Edit /usr/local/icinga/etc/objects/templates.cfg and within the ''generic-service'' definition add the following line underneath "''name generic-service''".
 +
<pre><nowiki>use srv-pnp</nowiki></pre>
 +
 
 +
==== New Interface ====
 +
First make backup copies of the configuration files you need to modify.
 +
<pre>
 +
cd /usr/local/icinga-web/app/modules/Cronks/data/xml/grid/
 +
cp icinga-host-template.xml icinga-host-template.bak
 +
cp icinga-service-template.xml icinga-service-template.bak</pre>
 +
Now edit ''icinga-host-template.xml'' and right before the line ''<field name="host_info">'' add the following following field definition.
 +
<pre><nowiki><field name="pnp4nagios_host_link">
 +
<!-- datasource maps a data field from api call -->
 +
<datasource>
 +
<parameter name="field">HOST_NAME</parameter>
 +
</datasource>
 +
 
 +
<display>
 +
<parameter name="visible">true</parameter>
 +
<parameter name="label">Perfdata</parameter>
 +
<parameter name="width">55</parameter>
 +
 
 +
<parameter name="Ext.grid.Column">
 +
<parameter name="menuDisabled">true</parameter>
 +
<parameter name="fixed">true</parameter>
 +
</parameter>
 +
 
 +
<parameter name="jsFunc">
 +
<!-- function to display column with icon in host status grid view -->
 +
<parameter>
 +
<parameter name="namespace">Cronk.grid.ColumnRenderer</parameter>
 +
<parameter name="function">columnImage</parameter>
 +
<parameter name="type">renderer</parameter>
  
ServerName icinga
+
<parameter name="arguments">
ServerAlias icinga.home
+
<parameter name="image">images/icons/application_view_gallery.png</parameter>
 +
<parameter name="css">x-icinga-grid-link</parameter>
 +
<parameter name="attr">
 +
<parameter name="qtip">Show host perfdata for this host</parameter>
 +
</parameter>
 +
</parameter>
 +
</parameter>
  
DocumentRoot /var/hda/web-apps/icinga/html
+
<!-- create cell click event for the previously defined column -->
 +
<parameter>
 +
<parameter name="namespace">Cronk.grid.IcingaColumnRenderer</parameter>
 +
<parameter name="function">iFrameCronk</parameter>
 +
<parameter name="type">cellclick</parameter>
 +
<parameter name="arguments">
 +
<parameter name="title">Host perfdata for {host_name}</parameter>
 +
<parameter name="url"><![CDATA[/pnp4nagios/index.php/graph?host={host_name}&srv=_HOST_]]></parameter>
 +
<parameter name="activateOnClick">true</parameter>
 +
</parameter>
 +
</parameter>
 +
</parameter>
 +
</display>
  
<Directory "/var/hda/web-apps/icinga/html">
+
<filter>
Options Indexes FollowSymLinks +ExecCGI
+
<parameter name="enabled">false</parameter>
AddHandler fcgid-script .fcg
+
</filter>
AllowOverride AuthConfig
 
Order allow,deny
 
Allow from all
 
 
</Directory>
 
  
ErrorLog  /var/hda/web-apps/Icinga/logs/error_log
+
<order>
  CustomLog /var/hda/web-apps/Icinga/logs/access_log combined env=!dontlog
+
<parameter name="enabled">false</parameter>
 +
</order>
 +
</field></nowiki></pre>
 +
Edit ''icinga-service-template.xml'' and right before the line ''<field name="service_info">'' add the following following field definition.
 +
<pre><nowiki><field name="pnp4nagios_service_link">
 +
<!-- datasource maps a data field from api call -->
 +
<datasource>
 +
<parameter name="field">SERVICE_NAME</parameter>
 +
</datasource>
  
#this is the beginning of the part from icinga.conf
+
<display>
ScriptAlias /icinga/cgi-bin "/usr/local/icinga/sbin"
+
<parameter name="visible">true</parameter>
<Directory "/usr/local/icinga/sbin">
+
<parameter name="label">Perfdata</parameter>
  Options ExecCGI
+
<parameter name="width">55</parameter>
  AllowOverride None
 
  Order allow,deny
 
  Allow from all
 
  AuthName "Icinga Access"
 
  AuthType Basic
 
  AuthUserFile /usr/local/icinga/etc/htpasswd.users
 
  Require valid-user
 
</Directory>
 
Alias /icinga "/usr/local/icinga/share/"
 
<Directory "/usr/local/icinga/share/">
 
  Options None
 
  AllowOverride None
 
  Order allow,deny
 
  Allow from all
 
  AuthName "Icinga Access"
 
  AuthType Basic
 
  AuthUserFile /usr/local/icinga/etc/htpasswd.users
 
  Require valid-user
 
</Directory>
 
</VirtualHost></nowiki></pre>}}
 
  
NOTE: The Icinga instructions should be rewritten so that it conforms to the icinga app path for Amahi standards.
+
<parameter name="Ext.grid.Column">
 +
<parameter name="menuDisabled">true</parameter>
 +
<parameter name="fixed">true</parameter>
 +
</parameter>
  
= Go to Icinga =
+
<parameter name="jsFunc">
Now visit Icinga at
+
<!-- function to display column with icon in host status grid view -->
{{Link|http://icinga/icinga}}
+
<parameter>
You can add a simple html redirect to /var/hda/web-apps/icinga/html/index.html to automatically redirect you so that you only have to visit http://icinga/.
+
<parameter name="namespace">Cronk.grid.ColumnRenderer</parameter>
 +
<parameter name="function">columnImage</parameter>
 +
<parameter name="type">renderer</parameter>
  
== TODO: ==
+
<parameter name="arguments">
When I update the instructions I'll write compiling instructions to:
+
<parameter name="image">images/icons/application_view_gallery.png</parameter>
* Install icinga to /var/hda/web-apps/icinga/html/icinga.
+
<parameter name="css">x-icinga-grid-link</parameter>
* Create a ScriptAlias to /cgi-bin instead of /icinga/cgi-bin
+
<parameter name="attr">
* Create an Alias to / instead of /icinga so that a user only need to visit http://icinga/
+
<parameter name="qtip">Show perfdata for this service</parameter>
 +
</parameter>
 +
</parameter>
 +
</parameter>
  
That's all for now...
+
<!-- create cell click event for the previously defined column -->
 +
<parameter>
 +
<parameter name="namespace">Cronk.grid.IcingaColumnRenderer</parameter>
 +
<parameter name="function">iFrameCronk</parameter>
 +
<parameter name="type">cellclick</parameter>
 +
<parameter name="arguments">
 +
<parameter name="title">Service perfdata for {service_name} on {host_name}</parameter>
 +
<parameter name="url"><![CDATA[/pnp4nagios/index.php/graph?host={host_name}&srv={service_name}]]></parameter>
 +
<parameter name="activateOnClick">true</parameter>
 +
</parameter>
 +
</parameter>
 +
</parameter>
 +
</display>
  
[[User:Sag47|Sag47]] 21:37, 10 June 2011 (PDT)
+
<filter>
 +
<parameter name="enabled">false</parameter>
 +
</filter>
  
[[Category:Apps]]
+
<order>
 +
<parameter name="enabled">false</parameter>
 +
</order>
 +
</field></nowiki></pre>
 +
You now have to clear the Icinga Web cache to finalize applying the settings you changed.
 +
<pre>/usr/local/icinga-web/bin/clearcache.sh</pre>

Latest revision as of 16:10, 17 July 2018

Warning.png WARNING
This is recommended only for advanced users, proceed with caution.


NOTE: Understand that without a web interface to do the configuration of objects the learning curve is large to configure Icinga for the first time.

These instructions were modified from documentation already on the Icinga Website. They are geared toward installing Icinga v1.4.

Icinga Web 2.0 Interface
Icinga Web 2.0 Interface Screenshot

These instructions are the combined effort documented in the following Icinga Documentation pages:

If you have any questions then please contact me.

-- Sag47 22:37, 18 July 2011 (PDT)

What is Icinga?

Icinga is a fork of Nagios. It is network monitoring software designed to monitor the overall status of your network through a polling system. This way when computers go down you know before anyone else because it will show up in Icinga.

In my Amahi HDA, I use Icinga to monitor: file share servers, network printers, router, internet modem, different internet websites. The reason why I monitor my router, internet mode and internet websites is because when my internet goes down I want to know if it's my router that is the problem or my ISP.

Icinga will also track statistics so you can measure how much downtime your computers have (or downtime of the internet) so you have exact statistics of your network monitored in realtime.

Now on to the good stuff.

How to install Icinga

Prerequisites

  • Fedora 14
  • Amahi set up and running
  • and update your HDA Server and install all of the prereqs for Icinga/Icinga-web

NOTE: If there is a kernel update then you should restart your machine after running yum update and start these instructions over.

yum check-update
yum update -y
yum groupinstall "Development Tools" "Legacy Software Development" -y
yum install httpd httpd-devel gcc glibc glibc-common gd gd-devel libjpeg libjpeg-devel libpng libpng-devel mysql mysql-server libdbi libdbi-devel libdbi-drivers libdbi-dbd-mysql net-snmp net-snmp-devel net-snmp-utils php php-cli php-pear php-xmlrpc php-xsl php-pdo php-gd php-ldap php-mysql php-mysql php-soap java-1.6.0-openjdk java-1.6.0-openjdk-devel zip unzip -y

Create a Webapp

Go to your HDA CP (HDA Control Panel) and go to Apps > Webapps and click New Webapp. Name it "icinga" without quotes. Root path should be /var/hda/web-apps/icinga (which is automatically generated by Amahi).

Create /var/hda/web-apps/icinga/html/index.html and give it the following contents.

<html>
<head>
<title>Icinga Monitoring Server</title>
<meta HTTP-EQUIV="REFRESH" content="0; url=/icinga/">
</head>
<body>
</body>
</html>

NOTE: Icinga will install to /usr/local/icinga. Icinga Web will install to /usr/local/icinga-web

Download required source tarballs

Download the following packages from the Icinga Project Page.

  • icinga/icinga-1.4.2.tar.gz or latest 1.4.x
  • icinga-web/icinga-web-1.4.1.tar.gz or latest 1.4.x
  • icinga-mobile/icinga-mobile-0.1.0.zip or latest

Download the following packages from the Nagios Plugin Project Page.

  • nagiosplug/1.4.15/nagios-plugins-1.4.15.tar.gz or latest

Download the latest Icinga API from git snapshot as seen in the Icinga API documentation.

Move all source tarballs to /usr/local/src/ on your HDA server.

Compile and install Icinga with IDOUtils

Create an icinga user, icinga-cmd group, and add the apache user and icinga user to the icinga-cmd group.

useradd -m icinga
groupadd icinga-cmd
usermod -a -G icinga-cmd icinga
usermod -a -G icinga-cmd apache

Now lets do some compiling.

cd /usr/local/src/
tar -xzf icinga-1.4.2.tar.gz
cd icinga-1.4.2
./configure --with-command-group=icinga-cmd --enable-idoutils --enable-event-broker
make all
make fullinstall

Edit the /usr/local/icinga/etc/objects/contacts.cfg config file with your favorite editor and change the email address associated with the icingaadmin contact definition to the address you'd like to use for receiving alerts.

vim /usr/local/icinga/etc/objects/contacts.cfg
cp /usr/local/icinga/etc/ido2db.cfg-sample /usr/local/icinga/etc/ido2db.cfg
cp /usr/local/icinga/etc/idomod.cfg-sample /usr/local/icinga/etc/idomod.cfg
cp /usr/local/icinga/etc/modules/idoutils.cfg-sample /usr/local/icinga/etc/modules/idoutils.cfg

Create the icinga db/user/pass for IDOUtils to use and import the mysql database (you should still be in /usr/local/src/icinga-1.4.2 working directory).

hda-create-db-and-user icinga
mysql -u icinga -picinga icinga < module/idoutils/db/mysql/mysql.sql

Configure the password for the icinga directory.

htpasswd -c /usr/local/icinga/etc/htpasswd.users icingaadmin

Configure the Apache config located in /etc/httpd/conf.d/

ls /etc/httpd/conf.d/ | grep icinga
#you should see two files.  Something like 1002-icinga.conf and icinga.conf
cat /etc/httpd/conf.d/icinga.conf >> /etc/httpd/conf.d/1002-icinga.conf
#Now edit /etc/httpd/conf.d/1002-icinga.conf
vim /etc/httpd/conf.d/1002-icinga.conf
#and move </VirtualHost> from the middle of the file to the end.
#be sure to confirm that the contents of icinga.conf are within 1002-icinga.conf before removing it
rm -f /etc/httpd/conf.d/icinga.conf

Start icinga, idoutils and restart the apache server.

service icinga start
service ido2db start
service httpd restart

Visit http://icinga and make sure that it is currently working.

Note: http://icinga should redirect to http://icinga/icinga and your localhost (which is the Amahi HDA) will show up as down.

Install Nagios Plugins

Time to compile again!

cd /usr/local/src/
tar -xzf nagios-plugins-1.4.15.tar.gz
cd nagios-plugins-1.4.15
./configure --prefix=/usr/local/icinga --with-cgiurl=/icinga/cgi-bin --with-htmurl=/icinga --with-nagios-user=icinga --with-nagios-group=icinga
make
make install
service icinga restart

Now visit http://icinga/ and click on Service Detail in the menu on the left under Status. After about 5 mins everything should slowly start turning green.

Install the latest Icinga API

Don't worry, there's nothing to compile here. But you still have to configure and install the Icinga API.

cd /usr/local/src/
tar -xzf icinga-api-refs-heads-master.tar.gz
cd icinga-api
./configure --datarootdir=/usr/local/icinga/share --sysconfdir=/usr/local/icinga/etc --with-command-user=icinga-cmd --with-command-group=icinga-cmd --with-icinga-user=icinga --with-icinga-group=icinga --with-web-user=apache --with-web-group=apache
make install

Install the Icinga Web 2.0 Interface

Create the Icinga Web db/user/pass.

hda-create-db-and-user icinga_web

Configure and install the new web interface.

cd /usr/local/src/
tar -xzf icinga-web-1.4.1.tar.gz
cd icinga-web-1.4.1
./configure --with-web-user=apache --with-web-group=apache --with-web-apache-path=/etc/httpd/conf.d
make install
make install-apache-config
make db-initialize
#Choose y for every question asked by make db-initialize

Now we need to do the same thing with the virtual server as we did originally with the Icinga install so that it shows up for our Virtual Host.

ls /etc/httpd/conf.d/ | grep icinga
#you should see two files.  Something like 1002-icinga.conf and icinga-web.conf
cat /etc/httpd/conf.d/icinga-web.conf >> /etc/httpd/conf.d/1002-icinga.conf
#Now edit /etc/httpd/conf.d/1002-icinga.conf
vim /etc/httpd/conf.d/1002-icinga.conf
#and move </VirtualHost> from the middle of the file to the end.
#be sure to confirm that the contents of icinga-web.conf are within 1002-icinga.conf before removing it
rm -f /etc/httpd/conf.d/icinga-web.conf*

Restart icinga, idoutils, and apache.

service icinga restart
service httpd restart

Go to the webpath (http://icinga/icinga-web/) and check if the web interface starts without exceptions (database connections web and api). You can login with user 'root' and password 'password'.

Install the Icinga Mobile Interface

Time for more source work!

cd /usr/local/src/
#if you want the latest then run git clone http://git.icinga.org/icinga-mobile.git
unzip icinga-mobile-0.1.0.zip
cd icinga-mobile
autoconf
./configure --with-web-user=apache --with-web-group=apache --with-web-apache-path=/etc/httpd/conf.d
make compile
make install
make install-apache-config

Now we need to do the same thing with the virtual server as we did originally with the Icinga install so that it shows up for our Virtual Host.

ls /etc/httpd/conf.d/ | grep icinga
#you should see two files.  Something like 1002-icinga.conf and icinga-mobile.conf
cat /etc/httpd/conf.d/icinga-mobile.conf >> /etc/httpd/conf.d/1002-icinga.conf
#Now edit /etc/httpd/conf.d/1002-icinga.conf
vim /etc/httpd/conf.d/1002-icinga.conf
#and move </VirtualHost> from the middle of the file to the end.
#be sure to confirm that the contents of icinga-mobile.conf are within 1002-icinga.conf before removing it
rm -f /etc/httpd/conf.d/icinga-mobile.conf*

Restart icinga, idoutils, and apache.

service httpd restart

Now go to http://icinga/icinga-web and log in as root. Click on Admin > Users and Add new user. Give it the following settings.

  • User name: mobile
  • Auth via: auth_key
  • password: whateveryouwant (different the the Api authkey)
  • Authkey for Api (optional): mobileaccess
  • Make sure that the moble user is part of these groups: appkit_user, icinga_user
  • The rest of the settings you can fill in what ever you want.

Now on your iPhone or Android phone visit http://icinga/icinga-mobile. After it says request failed click on config. Change the Icinga Web URL to reflect your server name. For instance my server is icinga.home so your URL should be http://icinga.home/icinga-web. Make the Auth key "mobileaccess" without quotes.

Known Issues

  • You have to make the server for icinga-web the exact same as what you access icinga-mobile on the config page of Icinga Mobile. For security reasons cross domain AJAX requests are denied. Example if you're accessing http://xyz/icinga-mobile then Icinga Web URL must be http://xyz/icinga-web. You can change the default credentials in Icinga Mobile from the instructions in the Icinga Wiki by editing /usr/local/src/icinga-mobile/lib/Model/IcingaConfiguration.js. You will have to recompile and reinstall Icinga Mobile (without running "make install-apache-config").
  • Icinga Mobile works neither with the desktop or mobile version of Firefox.
  • You may have to visit your fully qualified domain name on your mobile phone to access Icinga. For instance going to http://icinga.home/icinga-mobile instead of http://icinga/icinga-mobile because the mobile browsers will attempt to search it like icinga is a keyword for a search engine.

Overview and further Amahi integration

To get a better understanding of how Icinga works view this video. So basically you have the Icinga core which runs locally on the machine. Then you access the core using the Classic Web Interface, Icinga Web 2.0, and Icinga Mobile.

Add Icinga servers to the Admin CP

You will want to add two servers to your HDA Admin Control Panel. One for Icinga and one for IDOUtils.

echo 'Server.create(:name => "icinga", :comment => "Icinga")' | (cd /var/hda/platform/html && ./script/console production)
echo 'Server.create(:name => "ido2db", :comment => "IDOUtils")' | (cd /var/hda/platform/html && ./script/console production)

Now go to http://hda and visit Setup > Settings > Servers and you will see Icinga and IDOUtils showing up at the bottom.

Smarter index.html

Wouldn't it be awesome if when you visit http://icinga that it would default to the classic interface if JavaScript is disabled, default to web 2.0 interface if Javascript is enabled, or default to the mobile interface if you're visiting from a mobile phone? Well you can if you configure your server right.

  1. Browse to /var/hda/web-apps/icinga/html/.
  2. Visit my sourceforge project and download the latest browser_detect.js_XXXX.
  3. Unzip browser_detect.js to /var/hda/web-apps/icinga/html/
  4. Create /var/hda/web-apps/icinga/html/index.html with the following contents.
<html>
<head>
<title>Icinga Monitoring Server</title>
<meta HTTP-EQUIV="REFRESH" content="1; url=/icinga/">
<script type="text/javascript" src="browser_detect.js"></script>
<script type="text/javascript">
window.top.location.href=(isMobile)?"/icinga-mobile/":"/icinga-web/";
</script>
</head>
<body>
</body>
</html>

Icinga Plugins

PNP4Nagios

About

This documentation is the combined effort from:

Prerequisites

  • Icinga and all of its prerequisites.
  • Download latest PNP4Nagios from sourceforge and move it to /usr/local/src/
  • Install the following packages
yum install perl rrdtool rrdtool-perl -y

Set up PNP4Nagios

More compiling!

cd /usr/local/src/
tar -xzf pnp4nagios-0.6.13.tar.gz
cd pnp4nagios-0.6.13
./configure --with-nagios-user=icinga --with-nagios-group=icinga --with-httpd-conf=/etc/httpd/conf.d
make all
make fullinstall

Change some PNP4Nagios settings

sed -i 's/\/nagios\/cgi-bin/\/icinga\/cgi-bin/' /usr/local/pnp4nagios/etc/config.php

Apache integration for PNP4Nagios.

cd /etc/httpd/conf.d/
sed -i 's/nagios\/etc\/htpasswd.users/icinga\/etc\/htpasswd.users/' pnp4nagios.conf
sed -i 's/Nagios Access/Icinga Access/' pnp4nagios.conf
cat pnp4nagios.conf >> 1002-icinga.conf
#Don't forget to move </VirtualHost> from the middle to the end of the file
vim 1002-icinga.conf
rm pnp4nagios.conf
service httpd restart

Visit http://icinga/pnp4nagios/ and make sure all tests pass. Then remove the install.php file.

rm /usr/local/pnp4nagios/share/install.php

Now enable processing performance data in Icinga. Edit icinga.conf and set process_performance_data=1.

vim /usr/local/icinga/etc/icinga.cfg

Uncommend the following lines in /usr/local/icinga/etc/icinga.cfg.

host_perfdata_command=process-host-perfdata
service_perfdata_command=process-service-perfdata}}
Now create the process performance data commands (simply add them to the end of the file ''/usr/local/icinga/etc/objects/commands.cfg'')
{{Text|Text=<pre>define command{
  command_name process-host-perfdata
  command_line /usr/bin/perl /usr/local/pnp4nagios/libexec/process_perfdata.pl -d HOSTPERFDATA
}
define command{
  command_name process-service-perfdata
  command_line /usr/bin/perl /usr/local/pnp4nagios/libexec/process_perfdata.pl
}

Restart Icinga

service icinga restart

Now PNP4Nagios is installed. You can visit PNP4Nagios by going to http://icinga/pnp4nagios

Integrating PNP4Nagios into Icinga

Read PNP4Nagios documentation for integrating PNP4Nagios into the Icinga Classic web interface. Read the Icinga documentation for integrating PNP4Nagios into the new Icinga Web 2.0 interface.

Classic Interface

Add the following lines to the top of /usr/local/icinga/etc/objects/templates.cfg

define host{
  name host-pnp
  action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=_HOST_
  register 0
}

define service{
  name srv-pnp
  action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=$SERVICEDESC$
  register 0
}

Edit /usr/local/icinga/etc/objects/templates.cfg and within the generic-host definition add the following line underneath "name generic-host".

use host-pnp

Edit /usr/local/icinga/etc/objects/templates.cfg and within the generic-service definition add the following line underneath "name generic-service".

use srv-pnp

New Interface

First make backup copies of the configuration files you need to modify.

cd /usr/local/icinga-web/app/modules/Cronks/data/xml/grid/
cp icinga-host-template.xml icinga-host-template.bak
cp icinga-service-template.xml icinga-service-template.bak

Now edit icinga-host-template.xml and right before the line <field name="host_info"> add the following following field definition.

<field name="pnp4nagios_host_link">
<!-- datasource maps a data field from api call -->
<datasource>
<parameter name="field">HOST_NAME</parameter>
</datasource>

<display>
<parameter name="visible">true</parameter>
<parameter name="label">Perfdata</parameter>
<parameter name="width">55</parameter>

<parameter name="Ext.grid.Column">
<parameter name="menuDisabled">true</parameter>
<parameter name="fixed">true</parameter>
</parameter>

<parameter name="jsFunc">
<!-- function to display column with icon in host status grid view -->
<parameter>
<parameter name="namespace">Cronk.grid.ColumnRenderer</parameter>
<parameter name="function">columnImage</parameter>
<parameter name="type">renderer</parameter>

<parameter name="arguments">
<parameter name="image">images/icons/application_view_gallery.png</parameter>
<parameter name="css">x-icinga-grid-link</parameter>
<parameter name="attr">
<parameter name="qtip">Show host perfdata for this host</parameter>
</parameter>
</parameter>
</parameter>

<!-- create cell click event for the previously defined column -->
<parameter>
<parameter name="namespace">Cronk.grid.IcingaColumnRenderer</parameter>
<parameter name="function">iFrameCronk</parameter>
<parameter name="type">cellclick</parameter>
<parameter name="arguments">
<parameter name="title">Host perfdata for {host_name}</parameter>
<parameter name="url"><![CDATA[/pnp4nagios/index.php/graph?host={host_name}&srv=_HOST_]]></parameter>
<parameter name="activateOnClick">true</parameter>
</parameter>
</parameter>
</parameter>
</display>

<filter>
<parameter name="enabled">false</parameter>
</filter>

<order>
<parameter name="enabled">false</parameter>
</order>
</field>

Edit icinga-service-template.xml and right before the line <field name="service_info"> add the following following field definition.

<field name="pnp4nagios_service_link">
<!-- datasource maps a data field from api call -->
<datasource>
<parameter name="field">SERVICE_NAME</parameter>
</datasource>

<display>
<parameter name="visible">true</parameter>
<parameter name="label">Perfdata</parameter>
<parameter name="width">55</parameter>

<parameter name="Ext.grid.Column">
<parameter name="menuDisabled">true</parameter>
<parameter name="fixed">true</parameter>
</parameter>

<parameter name="jsFunc">
<!-- function to display column with icon in host status grid view -->
<parameter>
<parameter name="namespace">Cronk.grid.ColumnRenderer</parameter>
<parameter name="function">columnImage</parameter>
<parameter name="type">renderer</parameter>

<parameter name="arguments">
<parameter name="image">images/icons/application_view_gallery.png</parameter>
<parameter name="css">x-icinga-grid-link</parameter>
<parameter name="attr">
<parameter name="qtip">Show perfdata for this service</parameter>
</parameter>
</parameter>
</parameter>

<!-- create cell click event for the previously defined column -->
<parameter>
<parameter name="namespace">Cronk.grid.IcingaColumnRenderer</parameter>
<parameter name="function">iFrameCronk</parameter>
<parameter name="type">cellclick</parameter>
<parameter name="arguments">
<parameter name="title">Service perfdata for {service_name} on {host_name}</parameter>
<parameter name="url"><![CDATA[/pnp4nagios/index.php/graph?host={host_name}&srv={service_name}]]></parameter>
<parameter name="activateOnClick">true</parameter>
</parameter>
</parameter>
</parameter>
</display>

<filter>
<parameter name="enabled">false</parameter>
</filter>

<order>
<parameter name="enabled">false</parameter>
</order>
</field>

You now have to clear the Icinga Web cache to finalize applying the settings you changed.

/usr/local/icinga-web/bin/clearcache.sh