Install Icinga on CentOS

Embed Size (px)

DESCRIPTION

Icinga Open Source System Monitoring Software Installation Guide for CentOS 6.

Citation preview

  • Icinga (Monitoring Solution) Installation And Configuration On CentOS

    By SunilPublished: 2011-01-19 13:01

    Icinga (Monitoring Solution) Installation And Configuration On CentOS Icinga is an enterprise grade open source monitoring system which keeps watch over networks and any conceivable network resource, notifies the user oferrors and recoveries and generates performance data for reporting. Scalable and extensible, Icinga can monitor complex, large environments acrossdispersed locations.

    I am going with the Icinga basic installation and this is similar to Nagios and this document can also be referred for Nagios installation, too. Lots ofdocuments are available on the Internet and they will be installing with nagios user but for my setup I made use of the default user which is already presentin the system (daemon) and also I will not be installing it on the default path instead I will be referring to /opt since I find it very convenient. The UI ofIcinga is much better than Nagios.

    In this tutorial I will using three servers:

    192.168.1.20 - Icinga monitoring server (centos5)

    192.168.1.30 - win 2008 to be monitored

    192.168.1.40 - Ubuntu 10.10 server to be monitored

    Requirements Note: Make sure development tools and development libraries have been installed during installation:

    - GCC compiler - C/C++ development libraries - GD development libraries

    Packages Needed 1. Xampp for Linux:

    Copyright 2014 All Rights Reserved. HowtoForge Page 1 of 29

  • Icinga (Monitoring Solution) Installation And Configuration On CentOS http://www.howtoforge.com/

    [root@sunil~]# mkdir /software

    [root@sunil~]# cd /software

    [root@sunil software]# wget http://sourceforge.net/projects/xampp/files/XAMPP%20Linux/1.7.3/xampp-linux-1.7.3.tar.gz/download

    2. Icinga core:

    [root@sunil software]# wget http://sourceforge.net/projects/icinga/files/icinga/1.2.1/icinga-1.2.1.tar.gz/download

    Installation of Icinga 1. Untar the xampp package:

    [root@sunil software]# tar -zxvf xampp-linux-1.7.3.tar.gz

    [root@sunil software]# mv lampp/ /opt/

    Xampp package is very neatly compilied package and extracting the same is more than enough for more details can refer to xampp page:

    http://www.apachefriends.org/en/xampp.html

    2. Untar the Icinga package:

    [root@sunil software]# tar -zxvf icinga-1.2.1.tar.gz

    [root@sunil software]# cd icinga-1.2.1

    [root@sunil icinga-1.2.1]# ./configure --prefix=/opt/icinga --with-icinga-user=daemon --with-icinga-group=daemon--with-httpd-conf=/opt/lampp/etc

    Copyright 2014 All Rights Reserved. HowtoForge Page 2 of 29

  • Icinga (Monitoring Solution) Installation And Configuration On CentOS http://www.howtoforge.com/

    Note: please make sure you do not get any error while compiling. If you are getting errors make sure the required packages are installed.

    [root@sunil icinga-1.2.1]# make all

    [root@sunil icinga-1.2.1]# make install

    [root@sunil icinga-1.2.1]# make install-config

    [root@sunil icinga-1.2.1]# make install-commandmode

    [root@sunil icinga-1.2.1]# make install-webconf

    3. Now need to configure Apache with Icinga:

    [root@sunil icinga-1.2.1]# cd /opt/lampp/etc/

    [root@suniletc]# vim httpd.conf

    4. Add the following line:

    Include etc/icinga.conf

    5. Set password for login:

    [root@sunil /]# cd /opt/lampp/bin/

    [root@sunil bin]# ./htpasswd c /opt/icinga/etc/htpasswd.users icingaadmin

    New password:

    Copyright 2014 All Rights Reserved. HowtoForge Page 3 of 29

  • Icinga (Monitoring Solution) Installation And Configuration On CentOS http://www.howtoforge.com/

    Re-type new password: Adding password for user icingaadmin

    6. Start Apache:

    [root@sunillampp]# cd /opt/lampp/

    [root@sunillampp]# ./lamp startapache

    XAMPP: Starting Apache with SSL (and PHP5)... XAMPP: Error 1! Couldn't start Apache! XAMPP: Starting diagnose... XAMPP: Make the httpd.conf fit your system. XAMPP: Next try... XAMPP: Starting Apache with SSL (and PHP5)...

    7. Check whether Apache is working:

    http://192.168.1.20

    Copyright 2014 All Rights Reserved. HowtoForge Page 4 of 29

  • Icinga (Monitoring Solution) Installation And Configuration On CentOS http://www.howtoforge.com/

    8. Now we need to start Icinga but before that we need to check whether Icinga has been compiled properly and all the configuration are set:

    [root@sunillampp]# cd /opt/icinga/

    9. Before configuring Icinga we will start and see whether we get the page:

    [root@sunilicinga]# /opt/icinga/bin/icinga v /opt/icinga/etc/icinga.cfg

    Copyright 2014 All Rights Reserved. HowtoForge Page 5 of 29

  • Icinga (Monitoring Solution) Installation And Configuration On CentOS http://www.howtoforge.com/

    Total Warnings: 0 Total Errors: 0

    Things look okay - No serious problems were detected during the pre-flight check.

    10. Now start Icinga since we do not get any errors:

    [root@sunilicinga]# /opt/icinga/bin/icinga -d /opt/icinga/etc/icinga.cfg

    [root@sunilicinga]# ps -ef|grep icinga

    daemon 6961 1 0 19:03 ? 00:00:00 /opt/icinga/bin/icinga -d /opt/icinga/etc/icinga.cfgroot 6998 2929 0 19:05 pts/1 00:00:00 grep icinga

    [root@sunilrw]# chmod 777 /opt/

    [root@sunilrw]# chmod 777 /opt/icinga/

    [root@sunilrw]# chmod 777 /opt/icinga/var/

    [root@sunilrw]# chmod 777 /opt/icinga/var/rw/

    [root@sunilrw]# chmod 777 /opt/icinga/var/rw/icinga.cmd

    11. Login to check whether Icinga website opens:

    Copyright 2014 All Rights Reserved. HowtoForge Page 6 of 29

  • Icinga (Monitoring Solution) Installation And Configuration On CentOS http://www.howtoforge.com/

    Copyright 2014 All Rights Reserved. HowtoForge Page 7 of 29

  • Icinga (Monitoring Solution) Installation And Configuration On CentOS http://www.howtoforge.com/

    Installation of Nagios plugins for monitoring1. Download the Nagios plugin and compile the same:

    [root@sunil software]# wget http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.15.tar.gz

    [root@sunil software]# tar -zxvf nagios-plugins-1.4.15.tar.gz

    [root@sunil software]# cd nagios-plugins-1.4.15

    [root@sunil nagios-plugins-1.4.15]# ./configure --prefix=/opt/icinga/ --with-nagios-user=daemon --with-nagios-group=daemon

    Copyright 2014 All Rights Reserved. HowtoForge Page 8 of 29

  • Icinga (Monitoring Solution) Installation And Configuration On CentOS http://www.howtoforge.com/

    [root@sunil nagios-plugins-1.4.15]# make && make install

    Cutomization of Icinga Mail alert configuration:

    [root@sunil /]# cd /opt/icinga/etc/

    [root@suniletc]# vi objects/contacts.cfg

    define contact{contact_nameicingaadmin ; Short name of user

    use generic-contact ; Inherit default values from generic-contact template (defined above)alias Icinga Admin ; Full name of user

    emaildaemon@localhost ;

  • Icinga (Monitoring Solution) Installation And Configuration On CentOS http://www.howtoforge.com/

    Disable the following line:

    DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')dnldnl#DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')dnl

    Enable the following line:

    dnl define(`SMART_HOST', `smtp.your.provider')dnl

    Give your smtp address here - in this case sunil.cc:

    define(`SMART_HOST', `smtp.sunil.cc')dnl

    [root@sunil /]#m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf

    [root@sunil /]#/etc/init.d/sendmail restart

    Installing Nagios Plugin and nrpe in Ubuntu 192.168.1.40 1. For Ubuntu to be monitored by the Icinga server we need to install Nagios plugin and nrpe:

    root@ubuntu10:~# apt-get install gcc*

    root@ubuntu10:~#wget http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.15.tar.gz

    root@ubuntu10:~# tar -zxvf nagios-plugins-1.4.15.tar.gz

    Copyright 2014 All Rights Reserved. HowtoForge Page 10 of 29

  • Icinga (Monitoring Solution) Installation And Configuration On CentOS http://www.howtoforge.com/

    2. Compiling Nagios plugin:

    root@ubuntu10:~# cd nagios-plugins-1.4.15/

    root@ubuntu10:~/nagios-plugins-1.4.15# ./configure --with-nagios-user=daemon --with-nagios-group=daemon

    root@ubuntu10:~/nagios-plugins-1.4.15# make && make install

    root@ubuntu10:~/nagios-plugins-1.4.15# chown -R daemon:daemon /usr/local/nagios/

    Installation of NRPE (Nagios Remote Plugin Executor) 1. Download and compile NRPE:

    root@ubuntu10:~# wget http://prdownloads.sourceforge.net/sourceforge/nagios/nrpe-2.12.tar.gz

    root@ubuntu10:~# tar -zxvf nrpe-2.12.tar.gz

    root@ubuntu10:~# cd nrpe-2.12/

    root@ubuntu10:~/nrpe-2.12# apt-get install openssllibssl-dev

    root@ubuntu10:~# make all

    root@ubuntu10:~# make install-plugin

    root@ubuntu10:~# make install-daemon

    root@ubuntu10:~# make install-daemon-config

    root@ubuntu10:~/nrpe-2.12# apt-get installxinetd

    Copyright 2014 All Rights Reserved. HowtoForge Page 11 of 29

  • Icinga (Monitoring Solution) Installation And Configuration On CentOS http://www.howtoforge.com/

    root@ubuntu10:~# make install-xinetd

    2. We need to configure the nrpe as a xinetd service:

    root@ubuntu10:~/nrpe-2.12# vim /etc/xinetd.d/nrpe

    servicenrpe

    {flags = REUSE

    socket_type = stream

    port = 5666

    wait = no

    user = daemon

    group = daemon

    server = /usr/local/nagios/bin/nrpe

    server_args = -c /usr/local/nagios/etc/nrpe.cfg --inetd

    log_on_failure += USERID

    disable = no

    only_from = 127.0.0.1

    }

    3. Edit by adding the Icinga server IP in only_from:

    servicenrpe

    {flags = REUSE

    socket_type = stream

    port = 5666

    wait = no

    Copyright 2014 All Rights Reserved. HowtoForge Page 12 of 29

  • Icinga (Monitoring Solution) Installation And Configuration On CentOS http://www.howtoforge.com/

    user = daemon

    group = daemon

    server = /usr/local/nagios/bin/nrpe

    server_args = -c /usr/local/nagios/etc/nrpe.cfg --inetd

    log_on_failure += USERID

    disable = no

    only_from = 127.0.0.1 192.168.1.20

    }

    4. Now we need to run it as a service by adding the following line:

    root@ubuntu10:~# vim /etc/services

    nrpe 5666/tcp

    5. Restart the xinetd service:

    root@ubuntu10:~# /etc/init.d/xinetd restart

    6. Check whether nrpe has started:

    root@ubuntu10:~# netstat -a |grep nrpe

    To check whether Ubuntu is able to communicate with the Icinga server:

    root@ubuntu10:~# /usr/local/nagios/libexec/check_nrpe -H localhost

    Copyright 2014 All Rights Reserved. HowtoForge Page 13 of 29

  • Icinga (Monitoring Solution) Installation And Configuration On CentOS http://www.howtoforge.com/

    NRPE v2.12

    You should be able to get this output.

    Client Side Configuration Windows 2008 (192.168.1.30) 1. Download from http://nsclient.org/nscp/downloads.

    2. Just follow the screenshots:

    Copyright 2014 All Rights Reserved. HowtoForge Page 14 of 29

  • Icinga (Monitoring Solution) Installation And Configuration On CentOS http://www.howtoforge.com/

    Copyright 2014 All Rights Reserved. HowtoForge Page 15 of 29

  • Icinga (Monitoring Solution) Installation And Configuration On CentOS http://www.howtoforge.com/

    Copyright 2014 All Rights Reserved. HowtoForge Page 16 of 29

  • Icinga (Monitoring Solution) Installation And Configuration On CentOS http://www.howtoforge.com/

    Copyright 2014 All Rights Reserved. HowtoForge Page 17 of 29

  • Icinga (Monitoring Solution) Installation And Configuration On CentOS http://www.howtoforge.com/

    Copyright 2014 All Rights Reserved. HowtoForge Page 18 of 29

  • Icinga (Monitoring Solution) Installation And Configuration On CentOS http://www.howtoforge.com/

    Copyright 2014 All Rights Reserved. HowtoForge Page 19 of 29

  • Icinga (Monitoring Solution) Installation And Configuration On CentOS http://www.howtoforge.com/

    Copyright 2014 All Rights Reserved. HowtoForge Page 20 of 29

  • Icinga (Monitoring Solution) Installation And Configuration On CentOS http://www.howtoforge.com/

    3. Verify that nsclient++ is running as a service:

    Copyright 2014 All Rights Reserved. HowtoForge Page 21 of 29

  • Icinga (Monitoring Solution) Installation And Configuration On CentOS http://www.howtoforge.com/

    Configuration of Ubuntu and Win 2008 on the server side 1.

    Copyright 2014 All Rights Reserved. HowtoForge Page 22 of 29

  • Icinga (Monitoring Solution) Installation And Configuration On CentOS http://www.howtoforge.com/

    [root@sunil /]# cd /opt/icinga/etc/objects/

    2. First we configure the Ubuntu client.

    3. Create a cfg file for the same with the following content you can also refer to localhost.cfg present in the same directory:

    [root@sunil ~]# vim /opt/icinga/etc/objects/ubuntu10.cfg

    define host{uselinux-server

    host_name ubuntu10

    alias ubuntu10

    address 192.168.1.40

    }define service{use local-service

    host_name ubuntu10

    service_description PING

    check_command check_ping!100.0,20%!500.0,60%

    }define service{use local-service

    host_name ubuntu10

    service_description Root

    check_command check_local_disk!20%!10%!/

    }define service{use local-service

    host_name ubuntu10

    service_description Current Users

    check_command check_local_users!20!50

    Copyright 2014 All Rights Reserved. HowtoForge Page 23 of 29

  • Icinga (Monitoring Solution) Installation And Configuration On CentOS http://www.howtoforge.com/

    }define service{use local-service

    host_name ubuntu10

    service_description Total Processes

    check_command check_local_procs!250!400!RSZDT

    }define service{use local-service

    host_name ubuntu10

    service_description Current Load

    check_command check_local_load!5.0,4.0,3.0!10.0,6.0,4.0

    }define service{use local-service

    host_name ubuntu10

    service_description Swap Usage

    check_command check_local_swap!20!10

    }define service{use local-service

    host_name ubuntu10

    service_description SSH

    check_commandcheck_ssh

    notifications_enabled 0

    }

    For grouping of servers you can append this line to ubuntu10.cfg:

    definehostgroup{hostgroup_namelinux-servers ; The name of the hostgroup

    alias Linux Servers ; Long name of the group

    Copyright 2014 All Rights Reserved. HowtoForge Page 24 of 29

  • Icinga (Monitoring Solution) Installation And Configuration On CentOS http://www.howtoforge.com/

    memberslocalhost, ubuntu10 ; Comma separated list of hosts that belong to this group

    }

    4. For Windows 2008 we will referring to windows.cfg:

    define host{use windows-server ; Inherit default values from a template

    host_namewin2008 ; The name we're giving to this host

    alias My Windows Server ; A longer name associated with the host

    address 192.168.1.30 ; IP address of the host

    }

    define service{use generic-service

    host_name win2008

    service_descriptionNSClient++ Version

    check_commandcheck_nt!CLIENTVERSION

    }define service{use generic-service

    host_name win2008

    service_description Uptime

    check_commandcheck_nt!UPTIME

    }define service{use generic-service

    host_name win2008

    service_description CPU Load

    check_commandcheck_nt!CPULOAD!-l 5,80,90

    }define service{use generic-service

    Copyright 2014 All Rights Reserved. HowtoForge Page 25 of 29

  • Icinga (Monitoring Solution) Installation And Configuration On CentOS http://www.howtoforge.com/

    host_name win2008

    service_description Memory Usage

    check_commandcheck_nt!MEMUSE!-w 80 -c 90

    }define service{use generic-service

    host_name win2008

    service_description C:\ Drive Space

    check_commandcheck_nt!USEDDISKSPACE!-l c -w 80 -c 90

    }

    5. We need to set the password to log into the Windows server:

    [root@sunil etc]# vim objects/commands.cfg

    # 'check_nt' command definition

    define command{command_namecheck_nt

    command_line $USER1$/check_nt -H $HOSTADDRESS$ -p 12489 -v $ARG1$ $ARG2$ }

    6. Add your password:

    define command{command_namecheck_nt

    command_line $USER1$/check_nt -H $HOSTADDRESS$ -p 12489 s password@123 -v $ARG1$ $ARG2$ }

    [root@sunil objects]# chown -R daemon:daemon /opt/icinga/

    Copyright 2014 All Rights Reserved. HowtoForge Page 26 of 29

  • Icinga (Monitoring Solution) Installation And Configuration On CentOS http://www.howtoforge.com/

    [root@suniletc]# vimicinga.cfg

    cfg_file=/opt/icinga/etc/objects/ubuntu10.cfgcfg_file=/opt/icinga/etc/objects/win2008.cfg

    Add the two lines.

    Stop and start Icinga.

    Copyright 2014 All Rights Reserved. HowtoForge Page 27 of 29

  • Icinga (Monitoring Solution) Installation And Configuration On CentOS http://www.howtoforge.com/

    Copyright 2014 All Rights Reserved. HowtoForge Page 28 of 29

  • Icinga (Monitoring Solution) Installation And Configuration On CentOS http://www.howtoforge.com/

    Copyright 2014 All Rights Reserved. HowtoForge Page 29 of 29