This brief tutorial shows students and new users how to install and configure Icinga 2 monitoring and analytics platform on Ubuntu 16.04 | 18.04 LTS servers.
Icinga 2, is an open source software which provides monitoring and analytics across network systems in the data center and clouds platform. It is a complete enterprise grade server and log monitoring platform.
Metrics from Graphite displayed directly in the Icinga web interface where you can view and analyse logs and data that are interpreted in simple form.
For more about Icinga 2, please visit its homepage.
When you’re ready, continue below with the steps:
Step 1: Install Icinga 2 Package
To install Icinga 2, you can go and download its .deb package file and install it locally on Ubuntu server. However, if you want to quickly and easily upgrade to newer versions of the software, you will want to add its official APT repository to Ubuntu.
To add its APT repository to Ubuntu, run the commands below to import its repository GPG key.
curl https://packages.icinga.com/icinga.key | sudo apt-key add -
After importing the repository key above, run the commands below to create a new repository file for Icinga 2. This file will contain Icinga’s repositories where all packages and upgrades are available.
sudo nano /etc/apt/sources.list.d/icinga2.list
Then copy and paste the lines below into the file and save.
deb http://packages.icinga.com/ubuntu icinga-bionic main deb-src http://packages.icinga.com/ubuntu icinga-bionic main
After adding the repository file above, run the commands below to update APT package list and install Icinga 2 packages:
sudo apt update sudo apt install icinga2 monitoring-plugins
Once installed, the commands below can be used to stop, start and enable Icinga 2 to automatically startup when the server boots up.
sudo systemctl stop icinga2.service sudo systemctl start icinga2.service sudo systemctl enable icinga2.service
To validate if Icinga 2 is installed, run the commands below:
systemctl status icinga2.service
You should see Icinga 2 system status details as shown below:
icinga2.service - Icinga host/service/network monitoring system Loaded: loaded (/lib/systemd/system/icinga2.service; enabled; vendor preset: enabled) Drop-In: /etc/systemd/system/icinga2.service.d └─limits.conf Active: active (running) since Wed 2019-07-17 10:46:47 CDT; 16s ago Main PID: 13860 (icinga2) Tasks: 13 CGroup: /system.slice/icinga2.service ├─13860 /usr/lib/x86_64-linux-gnu/icinga2/sbin/icinga2 --no-stack-rlimit daemon --clos └─13894 /usr/lib/x86_64-linux-gnu/icinga2/sbin/icinga2 --no-stack-rlimit daemon --clos Jul 17 10:46:47 ubuntu1804 icinga2: [2019-07-17 10:46:47 -0500] information/ScriptGlobal: Jul 17 10:46:47 ubuntu1804 icinga2: [2019-07-17 10:46:47 -0500] information/ConfigObject: Jul 17 10:46:47 ubuntu1804 icinga2: [2019-07-17 10:46:47 -0500] information/ConfigObject: Jul 17 10:46:47 ubuntu1804 icinga2: [2019-07-17 10:46:47 -0500] information/ConfigItem: Tr Jul 17 10:46:47 ubuntu1804 icinga2: [2019-07-17 10:46:47 -0500] information/FileLogger: 'm Jul 17 10:46:47 ubuntu1804 icinga2: [2019-07-17 10:46:47 -0500] information/NotificationCo Jul 17 10:46:47 ubuntu1804 icinga2: [2019-07-17 10:46:47 -0500] information/CheckerCompone Jul 17 10:46:47 ubuntu1804 icinga2: [2019-07-17 10:46:47 -0500] information/ConfigItem: Ac Jul 17 10:46:47 ubuntu1804 icinga2: [2019-07-17 10:46:47 -0500] information/cli: Closing c Jul 17 10:46:47 ubuntu1804 systemd: Started Icinga host/service/network monitoring system.
Step 2: Install MariaDB Database Server
Icinga 2 requires a database server to store its content. If you’re looking for a truly open source database server, then MariaDB is a great place to start. To install MariaDB run the commands below:
sudo apt-get install mariadb-server mariadb-client
After installing MariaDB, the commands below can be used to stop, start and enable MariaDB service to always start up when the server boots.
Run these on Ubuntu 16.04 LTS
sudo systemctl stop mysql.service sudo systemctl start mysql.service sudo systemctl enable mysql.service
Run these on Ubuntu 18.10 and 18.04 LTS
sudo systemctl stop mariadb.service sudo systemctl start mariadb.service sudo systemctl enable mariadb.service
Next, run the commands below to secure the database server with a root password if you were not prompted to do so during the installation.
When prompted, answer the questions below by following the guide.
- Enter current password for root (enter for none): Just press the Enter
- Set root password? [Y/n]: Y
- New password: Enter password
- Re-enter new password: Repeat password
- Remove anonymous users? [Y/n]: Y
- Disallow root login remotely? [Y/n]: Y
- Remove test database and access to it? [Y/n]: Y
- Reload privilege tables now? [Y/n]: Y
Now that MariaDB is installed, to test whether the database server was successfully installed, run the commands below.
sudo mysql -u root -p
type the root password when prompted.
If you see a similar screen as shown above, then the server was successfully installed.
After installing MariaDB database server above, run the commands below to install Icinga 2 database module. To do that, run the commands below:
sudo apt install icinga2-ido-mysql
During the installation, you’ll be prompted with few questions. Choose Yes to enable Icinga ido-mysql module, agree to create a database and create a password for the database.
After that, Icinga 2 database module should be installed and configured.
Run the commands below to enable the module.
sudo icinga2 feature enable ido-mysql sudo systemctl restart icinga2
That should be it
Step 3: Create Icinga 2 Database
When you’re done with the steps above, follow the guide below to create Icinga 2 blank database. The database will be used to store its content.
To logon to MariaDB database server, run the commands below.
sudo mysql -u root -p
Then create a database called icingaweb
CREATE DATABASE icingaweb;
Create a database user called icingawebuser with a new password
CREATE USER 'icingawebuser'@'localhost' IDENTIFIED BY 'new_password_here';
Then grant the user full access to the database.
GRANT ALL ON icingaweb.* TO 'icingawebuser'@'localhost' WITH GRANT OPTION;
Finally, save your changes and exit.
FLUSH PRIVILEGES; EXIT;
Step 4: Access Icinga 2 Web Portal
Now that Icinga 2 server is installed run the commands below to install its web tool.
sudo apt install icingaweb2 icingacli php-gd
By default, Apache2 web server will be installed and PHP.
After installing Apache2 and PHP, open PHP default PHP config file and configure you server time zone. To do that, run the commands below
sudo nano /etc/php/7.2/apache2/php.ini
Then change the line below to include your timezone and save.
[Date] ; Defines the default timezone used by the date functions ; http://php.net/date.timezone date.timezone = America/Chicago
sudo systemctl reload apache2
When you’re done, generate the icinga2 setup token using the icingacli command as below.
sudo icingacli setup token create
Take note of the token as displayed below.
The newly generated setup token is: 4d594e662b6dfd54
After that, open your browser and browse to the server name to complete the setup.
Follow the installation wizard until you’re done. Type in the token generated above and continue.
Then select the Monitoring module and continue
After that, validated all requirements are met.
Select database authentication type. and type in the database name, username and password created above and continue.
Validate and continue
Continue with the setup and complete.
Login and enjoy!
Congratulations! You have learned how to install Icinga 2 monitoring and analytics platform on Ubuntu 16.04 | 18.04 LTS servers.
You may also like the post below: