Tuesday 9 April 2013

Icinga Server Installation in RedHat and Debian



Icinga is an open source network and computer system monitoring application that  monitors specified hosts and services and alerts with any kind of developing issues, errors or improvements. It was originally created as a fork of the Nagios system and is backward compatible. So, basically speaking Icinga is compatible with Nagios configurations, plugins and addons. 

Here, I will be showing you how to install Icinga using its Source Code and in fact it is better to install this way rather than installing packages that are available for Linux OS's. I will be showing installation for RHEL and Debian based OS but honestly, I have tested this on Debian based server but it should work fine for RHEL, Fedora and CentOS.

So basically, we need few things installed before proceeding with Icinga installation.
  • GCC compiler
  • C/C++ development libraries
  • GD development libraries AND
  • Apache Server

Debian/Ubuntu

 # apt-get install apache2 build-essential libgd2-xpm-dev

 # apt-get install libjpeg62 libjpeg62-dev libpng12-0 libpng12-0-dev

 # apt-get install snmp libsnmp-dev



RHEL/Fedora/ CentOS

 # yum install httpd gcc glibc glibc-common gd gd-devel

 # yum install libjpeg libjpeg-devel libpng libpng-devel

 # yum install net-snmp net-snmp-devel net-snmp-utils               

Now, lets create user account for Icinga and the user will be icinga and will create a new group icinga-cmd and we will add the user to the group. We will add webuser and the icinga user to icinga-cmd group. Depending upon Linux distro webuser can differ. RHEL(apache) and Debian(www-data).

# useradd -m icinga
# passwd icinga
# groupadd icinga-cmd
# usermod -a -G icinga-cmd icinga
# usermod -a -G icinga-cmd www-data


 Lets start with Icinga installation from its Source Code and Nagios Plugin.

# cd /usr/src

# wget http://kent.dl.sourceforge.net/project/icinga/icinga/1.8.4/icinga-1.8.4.tar.gz
# wget http://kent.dl.sourceforge.net/project/nagiosplug/nagiosplug/1.4.16/nagios-plugins-1.4.16.tar.gz  

  
Or download latest version.


# tar -zxvf icinga-1.8.4.tar.gz

# cd  icinga-1.8.4

# ./configure --with-command-group=icinga-cmd

# make all

# make install
# make install-init
# make install-config
# make install-eventhandlers
# make install-commandmode


Now, lets install Classic Web Interface.

# make cgis
# make install-cgis
# make install-html
# make install-webconf

Lets create users (john) and icingaadmin as well and give permission to users so that they can access and monitor.

# htpasswd -c /usr/local/icinga/etc/htpasswd.users icingaadmin
# htpasswd -c /usr/local/icinga/etc/htpasswd.users  john
# cd /usr/local/icinga/etc
# vim cgi.cfg

Here, in cgi.cfg, you can add user (john) to give access to system information and other access required. For example :-

authorized_for_system_information=icingaadmin,john
authorized_for_all_services=icingaadmin,john
authorized_for_all_hosts=icingaadmin,john

I am sure this should give users basic access to icinga.

# /etc/init.d/httpd restart     
# /etc/init.d/apache2 restart

We're almost finished, we just need to install Nagios plugins

 # cd /usr/src
 # tar xvzf nagios-plugins-1.4.16.tar.gz
 # cd nagios-plugins-1.4.16
 # ./configure --prefix=/usr/local/icinga --with-cgiurl=/icinga/cgi-bin --with-nagios-user=icinga --with-nagios-group=icinga
 # make
 # make install

Now, it is ready but before we proceed, I would like turn SELinux to permissive mode and stop Iptables or accept packets from port 22, 80 and 443. This isn't a bother for usual Debian/Ubuntu based server but this needs to be done for RHEL/Fedora/CentOS server

# setenforce 0
Or
# cd /etc/selinux/sysconfig
Change Enforcing to Permissive

# iptables -A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
Or
# cd /etc/sysconfig/iptables
Add following
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 443 -j ACCEPT

Finally, we are done, lets start icinga

RHEL/Fedora/CentOS
# chkconfig icinga on

Debian/Ubuntu
# update-rc.d icinga defaults

Verify the samples
# /usr/local/icinga/bin/icinga -v /usr/local/icinga/etc/icinga.cfg
# /etc/init.d/icinga show-errors
# /etc/init.d/icinga start

Open you browser http://localhost/icinga


Enjoy Icinga

No comments:

Post a Comment