How To Install Icinga2 On Ubuntu 12.04

Icinga is an open source network monitoring system which checks the availability of your network resources, notifies users of outages, and generates performance data for reporting. Its Scalable and extensible, Icinga2 can monitor large, complex environments across multiple locations.

Installation

Open Terminal (Ctrl+Alt+T). Enter the following commands.

sudo su
sudo apt-get update
sudo apt-get upgrade

Now add the Icinga repository:

sudo add-apt-repository ppa:formorer/icinga
sudo apt-get update

Install Icinga2:

sudo apt-get install icinga2

Now Install Icinga2 ClassicUI:

sudo apt-get install icinga2-classicui

Adding password for user icingaadmin. Here, I use password=password.

When Installation is finished then open your browser and type http://localhost/icinga2-classicui or IP address of the installing machine. Ex.http://192.168.10.81/icinga2-classicui.
GUI interface Icinga 2

Now install Mysql server.

sudo apt-get update
sudo apt-get install mysql-server icinga2-ido-mysql
Database configuration select Yes
sudo icinga2-enable-feature ido-mysql
sudo service icinga2 restart

Icinga2 Configuration

Open Terminal, and then;

sudo su
sudo apt-get update

Now go to Icinga2 dicrectory:

cd /etc/icinga2/conf.d/
ls -l

Now define Host or add the host in icinga2:

sudo mcedit hosts.conf

Replace the line:

object Host NodeName {

And type:

object Host "localhost"{

Add New host

object Host "Meeting-Room-Camera"{
import "generic-host"
address="192.168.10.199"
display_name="Meeting-Room-Camera"
vars.os="Camera"
vars.disks["disk"]={disk_partitions ="/"}
vars.notification["mail"]={groups =[ "icingaadmins" ]}
}

Now we need to save this configuration. Press Esc button two time and select save then press Enter.

Every host and service add after that restart the icinga2 server.

sudo service icinga2 restart

Note: Here, Meeting-Room-Camera is host name, and vars.os=”Camera” is the host group name.

Now you can add one more host after one by one.

Add the service for the host

sudo mcedit services.conf

Do the changes as shown below.

apply Service "ping4"{
import "generic-service"
check_command ="ping4"
assign where host.address
}
apply Service "ping6"
{
import "generic_service"
check_command ="ping6"
assign where host.address6
}
apply Service "ssh"{
import "generic_service"
check_command ="ssh"
assign where host.name=="localhost"
assign where host.address && host.vars.os =="PC"
}

See live Demo

service
Live demo:

live demo

Restart the icinga 2:

sudo service icinga2 restart

Create HostGroup

sudo mcedit groups.conf

Enter the following:

object HostGroup "PC" {
display_name="PC"
assign where host.vars.os=="PC"
}

groups
live demo:

live demo g

Note: Here PC means group name. vars.os==”PC” indicates the host.

Example:

object Host "Johor-Computer"{
import "generic-host"
address="192.168.10.54"
vars.os=="PC"
}

E-mail Notification

Open Terminal, and;

sudo su
cd /etc/icinga2/conf.d/
ls -l
sudo cp apt.conf Email.conf
sudo mcedit Email.conf

Now delete all text, and enter the email id.

object User "sita"{
import "generic-user"
display_name="Sita Group"
groups = ["icingaadmins"]
email ="mailofjohor@gmail.com"
}
apply Notification "mail-sita" to Service{
import "mail-service-notification"
users =["sita"]
assign where service.name =="ssh"
}

Email

Here, sita is a user group you can use any name and email add your own email address.

Be mindful that, after any changes in the configuration you should restart icinga2 server.

That’s all now. Happy monitoring!