Quick steps for how to install icinga2 on CentOS7

 

 

icinga2-web-login.png

This is a quick install steps of icinga2 on CentOS7.

1. Install Prerequisites

[icinga2@CentOS7]# yum -y install wget httpd mod_ssl gd gd-devel mariadb-server php-mysql php-xmlrpc gcc mariadb libdbi libdbi-devel libdbi-drivers libdbi-dbd-mysql

 

2. Disable SELinux.

[icinga2@CentOS7]# sed -i ‘s/SELINUX=enforcing/SELINUX=disabled/g’ /etc/selinux/config

– Admin privilege and reboot after above command
– To check a status of SELinux’s enable / disable

[icinga2@CentOS7]# sestatus
 

* It is important. If you are not diable SELinux properly, you will get an error

"Uncaught AgaviLoggingException thrown:
Cannot open file "/var/log/icinga-web/debug-2015-03-05.log", please check permissions on file or directory.
"

3. install group tool

[icinga2@CentOS7]# yum groupinstall "Development tools"

4. Reboot

5. user & group

[icinga2@CentOS7]# useradd icinga
[icinga2@CentOS7]# groupadd icinga-cmd
[icinga2@CentOS7]# usermod -a -G icinga-cmd icinga
[icinga2@CentOS7]# usermod -a -G icinga-cmd apache
 

6. Package Repositories

[icinga2@CentOS7]# rpm –import http://packages.icinga.org/icinga.key
[icinga2@CentOS7]# curl -o /etc/yum.repos.d/ICINGA-release.repo http://packages.icinga.org/epel/ICINGA-release.repo

[icinga2@CentOS7]# wget http://packages.icinga.org/epel/7/release/x86_64/icinga2-2.2.4-1.el7.centos.x86_64.rpm
[icinga2@CentOS7]# wget http://packages.icinga.org/epel/7/release/x86_64/icinga2-classicui-config-2.2.4-1.el7.centos.x86_64.rpm
[icinga2@CentOS7]# wget http://packages.icinga.org/epel/7/release/x86_64/icinga2-bin-2.2.4-1.el7.centos.x86_64.rpm
[icinga2@CentOS7]# yum makecache
[icinga2@CentOS7]# yum update

 

7. Installing Icinga 2

[icinga2@CentOS7]# yum install icinga2
[icinga2@CentOS7]# systemctl enable icinga2
[icinga2@CentOS7]# systemctl start icinga2

8. Verify required features

checker
mainlog
notification

Try below command

[icinga2@CentOS7]# icinga2 feature list

Disabled features: api command compatlog debuglog gelf graphite icingastatus ido-mysql ido-pgsql livestatus perfdata statusdata syslog
Enabled features: checker mainlog notification

9. icinga2 System check

[icinga2@CentOS7]#systemctl status icinga2

expecting output below

icinga2.service – Icinga host/service/network monitoring system
   Loaded: loaded (/usr/lib/systemd/system/icinga2.service; enabled)
   Active: active (running) since Thu 2015-03-05 18:42:07 EST; 21s ago
  Process: 2528 ExecStart=/usr/sbin/icinga2 daemon -d -e ${ICINGA2_ERROR_LOG} (code=exited, status=0/SUCCESS)
  Process: 2485 ExecStartPre=/usr/lib/icinga2/prepare-dirs /etc/sysconfig/icinga2 (code=exited, status=0/SUCCESS)
 Main PID: 2559 (icinga2)
   CGroup: /system.slice/icinga2.service
           └─2559 /usr/sbin/icinga2 –no-stack-rlimit daemon -d -e /var/log/icinga2/error.log

Mar 05 18:42:07 localhost.localdomain icinga2[2528]: [2015-03-05 18:42:07 -0500] information/ConfigItem: Checked 3 ServiceGroup(s).
Mar 05 18:42:07 localhost.localdomain icinga2[2528]: [2015-03-05 18:42:07 -0500] information/ConfigItem: Checked 1 Host(s).
Mar 05 18:42:07 localhost.localdomain icinga2[2528]: [2015-03-05 18:42:07 -0500] information/ConfigItem: Checked 11 Service(s).
Mar 05 18:42:07 localhost.localdomain icinga2[2528]: [2015-03-05 18:42:07 -0500] information/ConfigItem: Checked 1 User(s).
Mar 05 18:42:07 localhost.localdomain icinga2[2528]: [2015-03-05 18:42:07 -0500] information/ConfigItem: Checked 12 Notification(s).
Mar 05 18:42:07 localhost.localdomain icinga2[2528]: [2015-03-05 18:42:07 -0500] information/ConfigItem: Checked 1 UserGroup(s).
Mar 05 18:42:07 localhost.localdomain icinga2[2528]: [2015-03-05 18:42:07 -0500] information/ConfigItem: Checked 1 IcingaApplication(s).
Mar 05 18:42:07 localhost.localdomain icinga2[2528]: [2015-03-05 18:42:07 -0500] information/ConfigItem: Checked 1 ScheduledDowntime(s).
Mar 05 18:42:07 localhost.localdomain icinga2[2528]: [2015-03-05 18:42:07 -0500] information/ScriptVariable: Dumping variables to file ‘/var/ca…2.vars’
Mar 05 18:42:07 localhost.localdomain systemd[1]: Started Icinga host/service/network monitoring system.
Hint: Some lines were ellipsized, use -l to show in full.
 

10. install DB

[icinga2@CentOS7]#yum install php php-cli php-pear php-xmlrpc php-xsl php-pdo php-soap php-gd php-ldap php-mysql

[icinga2@CentOS7]# yum install mariadb-server mariadb
[icinga2@CentOS7]# systemctl enable mariadb
[icinga2@CentOS7]# systemctl start mariadb
[icinga2@CentOS7]# mysql_secure_installation

/usr/bin/mysql_secure_installation: line 379: find_mysql_client: command not found

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we’ll need the current
password for the root user.  If you’ve just installed MariaDB, and
you haven’t set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):
 
OK, successfully used password, moving on…

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
 … Success!

By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] y
 … Success!

Normally, root should only be allowed to connect from ‘localhost’.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] y
 … Success!

By default, MariaDB comes with a database named ‘test’ that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] y
 – Dropping test database…
 … Success!
 – Removing privileges on test database…
 … Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y
 … Success!

Cleaning up…

All done!  If you’ve completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!
[icinga2@CentOS7]#

11. Installing the IDO modules for MySQL

[icinga2@CentOS7]# yum install icinga2-ido-mysql
[icinga2@CentOS7]# yum install icinga-idoutils-libdbi-mysql

12. Setting up the MySQL database

[icinga2@CentOS7]# mysql -u root -p

Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 13
Server version: 5.5.41-MariaDB MariaDB Server

Copyright (c) 2000, 2014, Oracle, MariaDB Corporation Ab and others.

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.

MariaDB [(none)]>

MariaDB [(none)]> CREATE DATABASE icinga;
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> GRANT SELECT, INSERT, UPDATE, DELETE, DROP, CREATE VIEW, INDEX, EXECUTE ON icinga.* TO ‘icinga’@’localhost’ IDENTIFIED BY ‘icinga’;
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> quit

[icinga2@CentOS7]# mysql -u root -p icinga < /usr/share/icinga2-ido-mysql/schema/mysql.sql
Enter password:

13. Install icinga web

[icinga2@CentOS7]# yum install icinga-web icinga-web-mysql

– Create icinga web database

[icinga2@CentOS7]# mysql -u root -p

CREATE DATABASE icinga_web;
GRANT SELECT, INSERT, UPDATE, DELETE, DROP, CREATE VIEW, INDEX, EXECUTE ON icinga_web.* TO ‘icinga_web’@’localhost’ IDENTIFIED BY ‘icinga_web’;
FLUSH PRIVILEGES;

[icinga2@CentOS7]# mysql -u root -p icinga_web < /usr/share/icinga-web/etc/schema/mysql.sql

14. Enabling the IDO MySQL module

[icinga2@CentOS7]# icinga2 feature enable ido-mysql
warning/cli: Feature ‘ido-mysql’ already enabled.
 
[icinga2@CentOS7]# systemctl restart icinga2

15. WebServer

[icinga2@CentOS7]# yum install httpd
[icinga2@CentOS7]# systemctl enable httpd
[icinga2@CentOS7]# systemctl start httpd

16. Firewall update

[icinga2@CentOS7]# firewall-cmd –add-service=http
[icinga2@CentOS7]# firewall-cmd –permanent –add-service=http

17. Enable features

[icinga2@CentOS7]# icinga2 feature enable command
[icinga2@CentOS7]# icinga2 feature enable livestatus
[icinga2@CentOS7]# systemctl restart icinga2

18. /etc/icinga-web/conf.d/access.xml

/var/spool/icinga/cmd/icinga.cmd
to /var/run/icinga2/cmd/icinga2.cmd
 
[icinga2@CentOS7]# icinga-web-clearcache
[icinga2@CentOS7]# systemctl restart httpd

19. plugins

[icinga2@CentOS7]# wget http://nagios-plugins.org/download/nagios-plugins-2.0.3.tar.gz
tar xzf nagios-plugins-2.0.3.tar.gz
[icinga2@CentOS7]# ./configure –with-nagios-user=nagios –with-nagios-group=nagios
[icinga2@CentOS7]# make
[icinga2@CentOS7]# make install

– Directory

/tmp/nagios-plugins-2.0.3/plugins/

– Testing plugins

[icinga2@CentOS7]# ./check_disk -w 20% -c 10% /dev/sda
DISK OK – free space: /dev 1887 MB (100% inode=99%);| /dev=0MB;1509;1698;0;1887
[icinga2@CentOS7]#

[icinga2@CentOS7]# yum install xinetd -y

chkconfig –list

20. To register nrpe in xientd deamon

vi / etc/xinetd.d/nrpe

install agent on client and on icinga server for monitoring

[icinga2@CentOS7]# yum install nagios-nrpe
[icinga2@CentOS7]# yum install xinetd -y

21.  Adding node

Define hosts in /etc/icinga2/conf.d/hosts.conf
Define services in /etc/icinga2/conf.d/service.conf
set user send email in users.conf

hosts.conf

object Host "Hello-192.168.99.33" {
    import "generic-host"
    address = "192.168.99.33"
    vars.os = "Linux"
    vars.sla = "24×7"
}

22. Login

http://Server-IP/icinga-web/

root / password

 

 icinga2-web-login.png

 

 

 

Leave a Reply