Mosudi Isiaka

Mosudi Isiaka

Data Center Infrastructure

Contact Me

ICINGA 2 AND ICINGA WEB 2 INSTALLATION

Incinga2 was installed on the three servers, namely
  • EC2 Instance Ubuntu 14.04.4 LTS (Trusty Tahr)
  • Database Server: mosudi.db Ubuntu 14.04.4 LTS (Trusty Tahr) - Docker container
  • Web Server: mosudi.web Ubuntu 14.04.4 LTS (Trusty Tahr) - Docker container
  • While Icinga Web 2 and its dependencies were also installed on EC2 Instance Ubuntu 14.04.4 LTS (Trusty Tahr)
The steps to install Icinga 2 is available on the Icinga website
Likewise Icinga Web 2 is available at Icinga Git hub

Click here to watch fullscreen video

Installation Steps

Log into your Ubuntu serrver, in this case Ubuntu server intsance on Amazon EC2 as indicated above. Package manager will be used installing Icinga 2, therefore add necessary repository required for the installation.
  • http://packages.icinga.org/icinga.key
  • ppa:formorer/icinga
  • deb http://packages.icinga.org/ubuntu icinga-trusty main'
Start by running the following commands to add the required repositories

$ wget -O - http://packages.icinga.org/icinga.key | apt-key add -

$ sudo add-apt-repository ppa:formorer/icinga
$ sudo add-apt-repository 'deb http://packages.icinga.org/ubuntu icinga-trusty main'
Then update the repository and upgrade

$ sudo apt-get update ; sudo apt-get upgrade

Install Webmin


$ sudo apt-get -y install perl libnet-ssleay-perl openssl libauthen-pam-perl libpam-runtime libio-ptyperl apt-show-versions python

$ wget http://prdownloads.sourceforge.net/webadmin/webmin_1.801_all.deb
$ sudo dpkg --install webmin_1.801_all.deb


$ sudo passwd root

Provide login password for root (create or reset root password)

Edit PHP configuration

Login to AWS cloud instance Webmin GUI panel Navigate to PHP to the left panel of your browser, the Click “Manage” corresponding to /etc/php5/apache2/php.ini
Click on “Other Settings”
Navigate to expected local time and select

Adjust the timezone using the tzdata.

First install tzdata if not available
$ sudo apt-get install tzdata
$ sudo dpkg-reconfigure tzdata
This is not a requirement but local time will be guaranteed as it relates to icinga2 log



Then install Icinga2



$ sudo apt-get update ; sudo apt-get upgrade -y ;sudo apt-get -y install icinga2

This will install Inciga 2 as well as other dependencies


$ sudo apt-get -y install nagios-plugins

$ sudo service icinga2 status

Start Icinga 2 if not running


$ sudo service icinga2 start

This marks Icinga 2 installation as it is required on all the three servers.
Further installation procedures are not required for Icinga 2 to run but for Icinga Web 2 installation


$ sudo apt-get -y install tasksel

It is easier using tasksel to install LAMP stack as a whole. LAMP stack is a very important requirement for Icinga Web 2


$ sudo tasksel

Then select LAMP


$ sudo apt-get -y install mysql-client phpmyadmin

Select Apache2 and press return key.

Choose “No” for “Configure database for phpmyadmin with dbconfig-common?”



$ sudo   apt-get -y install php5-intl php5-imagick php5-ldap php5-pgsql icinga2-ido-mysql

$ mysql -u root -p
sudo mysql -u root -p

mysql> CREATE DATABASE icinga;
GRANT SELECT, INSERT, UPDATE, DELETE, DROP, CREATE VIEW, INDEX, EXECUTE ON icinga.* TO 'icinga'@'localhost' IDENTIFIED BY 'icingadbpassword';
>flush privileges;
>quit
$ sudo mysql -u root -p icinga < /usr/share/icinga2-ido-mysql/schema/mysql.sql
$ sudo vi /etc/icinga2/features-enabled/ido-mysql.conf
/** * The db_ido_mysql library implements IDO functionality
* for MySQL. */
library "db_ido_mysql"
object IdoMysqlConnection "ido-mysql" {
user = "icinga",
password = "icingadbpassword",
host = "localhost",
database = "icinga"
}
$ sudo service icinga2 restart
$ sudo icinga2 feature list
$ sudo icinga2 feature enable ido-mysql
$ sudo service mysql restart
$ sudo usermod -aG nagios ubuntu
$ sudo icinga2 feature enable ido-mysql
$ sudo service icinga2 restart
$ sudo icingacli setup config directory --group icingaweb2;
$ sudo chmod -R 777 /etc/icingaweb2/
$ sudo icingacli setup token create
Then instal Icinga Web 2

$  sudo apt-get -y install icingaweb2


Copy url of public instance and paste into address bar of your browser



Finally visit Icinga Web 2 in your browser to access the setup wizard and complete the installation:
http://ec2-52-40-100-221.us-west-2.compute.amazonaws.com/icingaweb2/setup.





Click “Next” to continue with the web installation

Click “Next” if every requirement is satified

Input the required database parameter to be created for Icingaweb 2

Validate and click “Next” after successful validation.

Mysql root user parameters to create the database and click “Next”

Clieck “Next”

Web admin user details

Leave defaults and click “Next”



Validate the icinga database created The db_ido_mysql and click next

Command Transport click “Next”



Click “Next”

Click “Finish”

Voila! Icinga Web 2 Installation complete.
You may login with administrator user created

ICINGA 2 CLIENT CONFIGURATION

This assignment requires the monitoring and report of the followings
  1. Mysql database within the Database Server. Docker container mosudi.db will be for the setup of Database Server.
  2. Apache Web Server withing the Web Server. Docker container mosudi.web will be used for the setup of Web Server.

For convenience LAMP stack will be configure on each of the Docker containers. The installation instructions for both containers will be similar except for their different hostname and the corresponding IP addresses. Linux hosts configuration file /etc/hosts will be edited on the AWS Instance, mosudi.web and mosudi.db to permit seemless name resolution among the servers.

The following bash commands as were indicated earlier in Docker Installation will provide us with both dockers with hosnames mosudi.web and mosudi.db.


$ docker run -h mosudi.web  -i -p 804:80 -p 10004:10000   -t  mosudi/crossoverweb /bin/bash

$ docker run -h mosudi.db  -i -p 805:80 -p 10005:10000 -p 3309:3306   -t mosudi/crossoverdb /bin/bash



At the bash prompt, run “ docker ps -l “ immediately after each of the command above to obtain particular container ID. These IDs will be used to connect to the containers while running .

$  docker exec -it  /bin/bash

root@web:/# 

root@web:/#  apt-get update

root@web:/#  apt-get upgrade

root@web:/#  apt-get -y install build-essential

root@web:/#   apt-get -y install lamp-server^


provide the mysql root password at the prompt
It is very important installing “lamp-server^” instead of using tasksel to make the deployment hasle free

root@web:/#  apt-get -y install tzdata

root@web:/# dpkg-reconfigure tzdata


Please select the geographic area in which you live at the prompt

root@web:/#  apt-get -y install perl libnet-ssleay-perl openssl libauthen-pam-perl libpam-runtime libio-pty-perl apt-show-versions python wget

You might encounter error with apt-show-version

Errors were encountered while processing:

 apt-show-versions

E: Sub-process /usr/bin/dpkg returned an error code (1)

root@web:/# apt-get -y purge apt-show-versions

root@web:/# rm /var/lib/apt/lists/*gz

root@web:/# apt-get -o Acquire::GzipIndexes=false update

root@web:/# apt-get -y install software-properties-common

root@web:/# apt-get -y install python-software-properties

root@web:/# apt-get -y install perl libnet-ssleay-perl openssl libauthen-pam-perl libpam-runtime libio-pty-perl apt-show-versions python wget



Then continue with the installation

root@web:/#  wget http://prdownloads.sourceforge.net/webadmin/webmin_1.801_all.deb

root@web:/#  dpkg --install webmin_1.801_all.deb



Adding Icinga 2 repository

root@web:/# wget -O - http://packages.icinga.org/icinga.key | apt-key add -
root@web:/# add-apt-repository 'deb http://packages.icinga.org/ubuntu icinga-trusty main'
root@web:/# add-apt-repository ppa:formorer/icinga 
root@web:/#  apt-get update


Installing Icinga 2

root@web:/# apt-get -y install icinga2

Nagios plugins:
nagios-plugins-basic and nagios-plugins-common were installed along with Icinga 2 as to satisfy dependecy . Also install nagio-plugins


root@web:/# apt-get install nagios-plugins
root@web:/# apt-get -y install phpmyadmin

Select Apache and No to dbconfig-common at the prompt
Before you exit the Web Server
root@web:/# ip address show | grep eth0
Note the allocated IP address. It will be required while editing /etc/hosts

root@web:/# exit

$ docker exec -it /bin/bash
root@db:/#
Repeat the installation process as done to mosudi.web
Edit /etc/hosts


root@db:/# vi /etc/hosts

IP address hostname
172.17.0.1 ip-172-31-46-140.us-west-2.compute.internal
172.17.0.2 web.mosudi
172.17.0.3 db.mosudi

root@web:/#

ICINGA 2 MONITORING CONFIGURATION

I intend to monitor single service for each of the Icinga 2 clients
Icinga 2 Client Service to Monitor
mosudi.web Apache2 i.e http service
mosudi.db Mysql Server

Once the Icinga 2 client configuration is complete a whole lot of service will be available for monnitoring. Every other services will be disabled except the target even http will be disabled on mosudi.db

login to the web server mosudi.web shell using docker command


$  docker exec -it  /bin/bash


where mosudi.web container ID 980939710a88


$  docker exec -it 980939710a88 /bin/bash

root@web:/#

Navigate to Icinga 2 configuration directory



root@web:/# cd /etc/icinga2/


root@web:/etc/icinga2# ls
conf.d features-available icinga2.conf pki scripts zones.d constants.conf features-enabled init.conf repository.d zones.conf root@web:/etc/icinga2#
The main configuration folder during Icinga 2 client configuration is the conf.d directory


root@web:/etc/icinga2# cd conf.d/


root@web:/etc/icinga2/conf.d# ls app.conf commands.conf groups.conf notifications.conf services.conf timeperiods.conf apt.conf downtimes.conf hosts.conf satellite.conf templates.conf users.conf
root@web:/etc/icinga2/conf.d#

First I need to edit hosts.conf file


root@web:/etc/icinga2/conf.d# vi hosts.conf  


/*

 * Host definitions with object attributes

 * used for apply rules for Service, Notification,

 * Dependency and ScheduledDowntime objects.

 *

 * Tip: Use `icinga2 object list --type Host` to

 * list all host objects after running

 * configuration validation (`icinga2 daemon -C`).

 */



/*

 * This is an example host based on your

 * local host's FQDN. Specify the NodeName

 * constant in `constants.conf` or use your

 * own description, e.g. "db-host-1".

 */



object Host NodeName {

  /* Import the default host template defined in `templates.conf`. */

  import "generic-host"



  /* Specify the address attributes for checks e.g. `ssh` or `http`. */

  address = "127.0.0.1"

  address6 = "::1"



  /* Set custom attribute `os` for hostgroup assignment in `groups.conf`. */

  vars.os = "Linux"



  /* Define http vhost attributes for service apply rules in `services.conf`. */

  vars.http_vhosts["http"] = {

    http_uri = "/"

  }

  /* Uncomment if you've sucessfully installed Icinga Web 2. */

  //vars.http_vhosts["Icinga Web 2"] = {

  //  http_uri = "/icingaweb2"

  //}



  /* Define disks and attributes for service apply rules in `services.conf`. */

  vars.disks["disk"] = {

    /* No parameters. */

  }

  vars.disks["disk /"] = {

    disk_partitions = "/"

  }



Comment out services I do not intend to monitor fon this hostt. As I indicated earlier my I intention is to monitor on http the files will look like this after the edit



/*

 * Host definitions with object attributes

 * used for apply rules for Service, Notification,

 * Dependency and ScheduledDowntime objects.

 *

 * Tip: Use `icinga2 object list --type Host` to

 * list all host objects after running

 * configuration validation (`icinga2 daemon -C`).

 */



/*

 * This is an example host based on your

 * local host's FQDN. Specify the NodeName

 * constant in `constants.conf` or use your

 * own description, e.g. "db-host-1".

 */



object Host NodeName {

  /* Import the default host template defined in `templates.conf`. */

  import "generic-host"



  /* Specify the address attributes for checks e.g. `ssh` or `http`. */

  address = "127.0.0.1"

  address6 = "::1"



  /* Set custom attribute `os` for hostgroup assignment in `groups.conf`. */

  vars.os = "Linux"



  /* Define http vhost attributes for service apply rules in `services.conf`. */

  vars.http_vhosts["http"] = {

    http_uri = "/"

  }

  /* Uncomment if you've sucessfully installed Icinga Web 2. */

  //vars.http_vhosts["Icinga Web 2"] = {

  //  http_uri = "/icingaweb2"

  //}



  /* Define disks and attributes for service apply rules in `services.conf`. */

/*  vars.disks["disk"] = { */

    /* No parameters. */

 /* }

  vars.disks["disk /"] = {

    disk_partitions = "/"

  } */


This was done on services.conf. All the services except http were commented out. Meanwhile I added:


apply Service "MySQL - Registration DB" {

   import "generic-service"

   check_command = "mysql"

  import "generic-service"

   check_command = "mysql"

   vars.mysql_database = "dbname"

   assign where host.name == "db.mosudi"

}


This at the end of services.conf. Reload icinga 2 service


root@db:/etc/icinga2/conf.d# service icinga2 restart


Then exit the server.



root@db:/etc/icinga2/conf.d# exit                   

exit

root@ip-172-31-46-140:~#
 

root@ip-172-31-46-140:~# icinga2 node wizard

At the prompt


root@ip-172-31-46-140:~# icinga2 node wizard

Welcome to the Icinga 2 Setup Wizard!



We'll guide you through all required configuration details.







Please specify if this is a satellite setup ('n' installs a master setup) [Y/n]: 


press “n” this  is the master

Please specifiy the common name (CN) [ip-172-31-46-140.us-west-2.compute.internal]

Type :  ip-172-31-46-140.us-west-2.compute.internal


172.17.0.1