Saturday, March 26, 2011

Sys Admin Tools 0.1 - Installing and Monitoring with Icinga

Welcome to the third and final part of my 0.1 release. In this post I will discuss the steps necessary in order to in install and configure Icinga from source – at a later time I will post about installation from an RPM which a colleague of mine is working on.


We must install the prerequisites for Icinga before we move on, these include; Apache, GCC Compiler, C/C++ development libraries, and GD development libraries. Use the following command (as root or sudo) in order to install the necessary packages for RedHat Based distributions;

            yum install httpd gcc glibc glibc-common gd gd-devel libjpeg libjpeg-devel
            libpng libpng-devel net-snmp net-snmp-devel

Once you have the prerequisites installed you will need to the follow the upcoming steps in order to successfully install your Icinga Core and Icinga Web from source code.

Create your new icinga user account and give it a password
useradd –m icinga && passwd icinga

Create the required group named “icinga”
groupadd  icinga

We will then need to create a new group called “icinga-cmd” and adding the systems web user and Icinga user to this group will allow for them to use the classic web interface to send commands to Icinga.
groupadd icinga-cmd
usermod –a –G icinga-cmd icinga
usermod –a –G icinga-cmd apache

Change your current working directory to a location of your choosing and download and extract the following tarball files (as root or sudo) – the purpose of this post we will use “/usr/src” as our directory;
cd /usr/src/

Files to download;

wget http://sourceforge.net/projects/icinga/files/icinga/1.3.0/icinga-1.3.0.tar.gz/download
wget http://sourceforge.net/projects/icinga/files/icinga-web/1.3.0/icinga-web-1.3.0.tar.gz/download
wget http://sourceforge.net/projects/nagiosplug/files/nagiosplug/1.4.15/nagios-plugins-1.4.15.tar.gz/download

Next we will extract the Icinga Core and prepare it for installation;

tar –zxvf  icinga-1.3.0.tar.gz
cd /usr/src/icinga-1.3.0/
./configure --with-command-group=icinga-cmd (use the --help arguments for additional options)
            make all

To complete a full installation of Icinga from source you can simply enter the following command; “make fullinstall” – the default installation directory is “/usr/local/icinga/”. (Note: Do not start Icinga yet!)

Before we continue we must change the email address inside of the “/usr/local/icinga/etc/objects/contacts.cfg file – this address is used for notification emails, review the other options in the file for additional changes you may want to make.

Icinga does come with a Classic Web Interface already built in, use the following commands to set up and configure your web interface that will be used to administer your Icinga server – if you would like to know how to install the new Icinga-Web follow this link.
cd /usr/src/icinga-1.3.0/
            make cgis
            make install-cgis
            make install-html
            make install-webconf

Create the icingaadmin account that will be logging into the Icinga classic web interface and then restart your web server – the account is determined by the entry found in the “/usr/loca/icinga/etc/objects/contacts.cfg” file’s “contact_name” option.

            htpasswd -c /usr/local/icinga/etc/htpasswd.users icingaadmin
            /etc/init.d/httpd restart

Because Icinga is backwards compitable with Nagios, it uses all of Nagios’ available plugins – these will need to be installed as well.

            cd /usr/src/nagios-plugins-1.4.15
            ./configure --prefix=/usr/loca/icinga --with-cgiurl=/icinga/cgi-bin --with-htmurl=/icinga --with-nagios-user=icinga --with-nagios-group=icinga
            make && make install


IMPORTANT: The commands above much also be executed on ALL machines that are to be monitored by Icinga. 

You may run into the always annoying encounters with SELinux settings on RedHat distributions, to perform an easy fix you can simply set your SELinux settings to permissive mode (setenforce 0) – the Icinga documentation provides the necessary commands in order to fix the SELinux issue, the commands are found below;
            
            chcon –R –t httpd_sys_script_exec_t /usr/local/icinga/sbin/
            chcon –R –t httpd_sys_content_t /usr/local/icinga/share/
            chcon –t httpd_sys_script_rw_t /usr/local/icinga/var/rw/icinga.cmd

This concludes the installation of your new Icinga server, you are now able to start your Icinga service – be sure to add it to your start up scripts;
            chkconfig --add icinga
            chkconfig icinga on
            /etc/init.d/icinga start

In order to access your Classic Web Interface you will need to redirect yourself to the following URL – http://localhost/icinga/ or http://yourdomain.com/icinga/
IMPORTANT: If iptables is enabled you MUST add the exception for port 80 to be accepted –     iptables –A INPUT –p tcp –m tcp –dport 80 –j ACCEPT


The following video will show a very small demonstration of what Icinga looks like after it is installed, with also a simple notification sample. Note that it is a demonstration on my virtual servers at home and is not yet ready for production. 



To be continued... Stay tuned for my 0.2 release where I will 
demonstrate Icinga in action, showing configuration 
and real-time monitoring on Fedora-ARM machines.



Gian-Luca Casella -- Last Updated on Tuesday, March 26, 2011

No comments:

Post a Comment