Icinga2 is an open source, scalable and extensible computer system and network monitoring application. You can use it to check the availability of your network, along with generating performance reports.
You can also use it to inform the users about the outages. In addition, you can monitor server resources, like RAM usage, network services, like HTTPS, and network devices, like routers and switches. In this article, you will find the step by step guide for installing and configuring Icinga2 on 18.04 VPS or dedicated server.
Installing Icinga2 on 18.04 VPS or Dedicated Server
- Update the system and get the latest packages by using the following command:
sudo apt-get update sudo apt-getupgrade sudo reboot
- Install web server and PHP by typing these lines:
sudo apt-get install php php-{xml,cli,opcache,gd,intl,readline,mysql,curl,mbstring,ldap,json}
- Install apache2 and libapache2-mod-php module
sudo apt-get install apache2 libapache2-mod-php
- Configure PHP Timezone by typing these lines:
$ sudo vim /etc/php/7.2/apache2/php.ini date.timezone = Africa/Nairobi
- Now, restart apache2 service.
sudo systemctl restart apache2
- Download and install MariaDB database on your Ubuntu 18.04 VPS by following the instructions mentioned here.
- Sign into the database as the root user.
$ mysql -u root -p
- Create a database and a user.
CREATEDATABASE icinga2_db; GRANT ALL PRIVILEGESon icinga2_db.* to'icinga2_user'@'localhost'identifiedby'StrongPassword'; FLUSHPRIVILEGES; quit
- Now, create another database and user for Icinga web 2.
CREATEDATABASE icingaweb2_db; GRANT ALL PRIVILEGESon icingaweb2_db.* to'icingaweb2_user'@'localhost'identifiedby'StrongPassword'; FLUSHPRIVILEGES;
- Import repo GPG key:
curl -sSL https://packages.icinga.com/icinga.key | sudo apt-key add -
- Add apt repository using the following command:
echo"deb https://packages.icinga.com/ubuntu icinga-xenial main" | sudo tee /etc/apt/sources.list.d/icinga.list
- Install Icinga2 packages.
sudo apt-get install icinga2 icingaweb2 icinga2-ido-mysql
- If you are asked to enable Icinga2 for using MySQL, reply YES.
EnableIcinga2's ido-mysql feature? YES Configure database for icinga2-ido-mysql with dbconfig-common? NO
- Activate ido-mysql and command features by typing this line:
sudo icinga2 feature enablecommand ido-mysql
- Restart Icinga2.
sudosystemctlrestarticinga2.service
- Import database schema by using this command:
mysql -u root icinga2_db -p < /usr/share/icinga2-ido-mysql/schema/mysql.sql
- Configure Icinga2 MySQL IDO.
sudo vim /etc/icinga2/features-enabled/ido-mysql.conf
- Type these lines:
/** * The db_ido_mysql library implements IDO functionality * for MySQL. */ library"db_ido_mysql" object IdoMysqlConnection "ido-mysql" { user = "icinga2_user", password = "StrongPassword", host = "localhost", database = "icinga2_db" }
- Save the changes and restart Icinga2 server.
sudo systemctl restart icinga2
Configuring Icinga 2 on Web Interface
- Create a setup token.
$ sudo icingacli setup token create The newly generated setup token is: 75e269c261a15615
- Open your favorite browser and go to http://serverdomain/icingaweb2.
- The configuration wizard page will be displayed. Copy and paste the generated setup token from Step 1. Then click Next.
- Select your desired module. Click Next.
- A new page will appear. Ensure that all the PHP modules have been installed correctly.
- Now, select your desired authentication type, which is being set to MySQL by default.
- Insert your MySQL database settings.
- A page related to monitoring IDO Resource will be displayed. Use the Icinga2 settings that you had configured earlier.
- Insert Transport Name, Transport Type and Command File.
- Configure Monitoring Security and Administration.
- Get into the login page. Insert the admin account username and password. If you are able to sign in, then the configuration of Icinga2 is completed successfully.
Conclusion
In this article, you have learnt about installing Icinga 2 on Ubuntu 18.04 VPS or dedicated server. You have also learned to configure the monitoring tool appropriately. Now, you have the power to monitor massive and complex environments across different locations effectively.