{"id":899,"date":"2018-10-12T17:58:05","date_gmt":"2018-10-12T14:58:05","guid":{"rendered":"http:\/\/kifarunix.com\/?p=899"},"modified":"2024-03-11T20:08:33","modified_gmt":"2024-03-11T17:08:33","slug":"how-to-install-icinga-2-and-icinga-web-2-on-ubuntu-18-04-lts","status":"publish","type":"post","link":"https:\/\/kifarunix.com\/how-to-install-icinga-2-and-icinga-web-2-on-ubuntu-18-04-lts\/","title":{"rendered":"How to Install Icinga 2 and Icinga Web 2 on Ubuntu 18.04 LTS"},"content":{"rendered":"\n
In this tutorial, we are going to learn how to install Icinga 2 and Icinga Web 2 on Ubuntu 18.04 LTS. Icinga<\/a> 2 is an open source monitoring system which checks the availability of your network resources (CPU load, uptime, free disk space, memory consumption), notifies users of outages and generates performance data for reporting. It is scalable and therefore it can be used to monitor large, complex environments across multiple locations.<\/p>\n\n\n\n It has a lightweight and extensible web interface called Icinga Web 2 that enables you to visualize and keep an eye on your environment.<\/span><\/p>\n\n\n\n You need to install Icinga package repository;<\/p>\n\n\n\n Next, run system update.<\/p>\n\n\n\n Now that the repositories are ready, run the command below to install Icinga 2.<\/p>\n\n\n\n The basic installation of icinga 2 enables the following features;<\/p>\n\n\n\n You can verify that these features are enabled by running the command:<\/p>\n\n\n\n In order for Icinga 2 to monitor system metrics such as load averages, processes, or disk space usage or any other system remote checks, it requires the check plugins. Run the command below to install the check plugins.<\/p>\n\n\n\n Now that you have installed icinga 2 and its monitoring plugins, set icinga2 service to start on system reboot. Note that by default, icinga2 starts automatically after installation.<\/p>\n\n\n\n You can check the status using the command below;<\/p>\n\n\n\n If for some reason it is not running, start by running the command below;<\/p>\n\n\n\n Enable it to start on system reboot<\/p>\n\n\n\n Icinga 2 can be used with Icinga Web 2, a powerful PHP framework for web applications that comes in a clean and reduced design. It\u2019s fast, responsive, accessible and easily extensible with modules.<\/p>\n\n\n\n In order to install and setup Icinga Web 2, ensure that the following prerequisites are met.<\/p>\n\n\n\n The DB IDO module for Icinga 2 takes care of exporting all the configuration and status information to the database. The supported database backends include MySQL\/MariaDB and PostgreSQL.<\/p>\n\n\n\n In this tutorial, we will be using MariaDB as our database backend.<\/p>\n\n\n\n In this tutorial, we are going to use MariaDB. To install MariaDB, run the command below.<\/p>\n\n\n\n Once the installation is done, run the following command to improve the security of your MySQL\/MariaDB installation by maybe setting root password and removing test databases, anonymous-user accounts, disallowing remote root login.<\/p>\n\n\n\n Since we have enabled Icinga 2 repositories above, run the command below to install IDO modules.<\/p>\n\n\n\n During installation, the database configuration wizard will prompt you to set some configurations.<\/p>\n\n\n\n To enable ido-mysql feature in the backend, run the command below. ou can also enable a command feature that enables you to manual health checks from the Icinga 2 Web Interface.<\/p>\n\n\n\n The ido-mysql configuration file is \/etc\/icinga2\/features-available\/ido-mysql.conf<\/strong>. You can view the contents of this file by running the command below;<\/p>\n\n\n\n Restart Icinga 2 for these changes to take effect.<\/p>\n\n\n\n Run the command below to install Icinga 2 and its command utility, icingacli. Note that Icinga will install and set up Apache web server by default as well as PHP all the PHP modules required for Icinga Web 2 to run.<\/p>\n\n\n\n Once the installation is done, you need set a timezone to be set for the PHP environment, so edit the PHP config file, \/etc\/php\/7.2\/apache2\/php.ini<\/strong> and set timezone as follows<\/p>\n\n\n\n Restart the Apache service to effect the changes.<\/p>\n\n\n\n Login to MariaDB and create a database and database user for Icinga Web 2;<\/p>\n\n\n\n Most of the Icinga Web 2 configurations will be done from the User Interface but before we get there, set up the Icinga authentication token.<\/p>\n\n\n\n To generate the token, run the following command.<\/p>\n\n\n\n Sample output<\/p>\n\n\n\n Once you have the authentication token, navigate to the browser and access Icinga web 2 using the url, http:\/\/<ip-of-icinga-server>\/icingaweb2\/setup <\/strong>so as to finalize the configurations.<\/p>\n\n\n\n Enter your authentication token generated and click next to proceed.<\/p>\n\n\n\n <\/a>Choose Icinga 2 modules to enable. In this tutorial, we go with the defaults with monitoring modules only enabled.<\/p>\n\n\n\n <\/a>On the next page, the setup wizards verifies if all the required PHP modules are in place.<\/p>\n\n\n\n <\/a>If all is well, click Next to proceed, otherwise install any missing PHP extensions and proceed with setup.<\/p>\n\n\n\n Choose the mode of authentication. We use database authentication in this demo.<\/p>\n\n\n\n Configure Icinga 2 Web database<\/strong> connection settings. Click Validate Configuration to test connection to database.<\/p>\n\n\n\n <\/a>Choose authentication backend database.<\/p>\n\n\n\n <\/a><\/p>\n\n\n\n Create Icinga Web 2 administrative user.<\/p>\n\n\n\n <\/a>Choose your application configuration settings.<\/p>\n\n\n\n Icinga Web 2 application configuration summary.<\/p>\n\n\n\n <\/a>Click Next,Next to proceed. Configure Icinga Web 2 monitoring module.<\/p>\n\n\n\n <\/a>Configure Icinga 2 Database connection settings.<\/p>\n\n\n\n <\/a>If upon validating the configuration you get the error, Configure Icinga Transport commands. Read more on Icinga web 2 command transport<\/a>. Provide the API credentials set before.<\/p>\n\n\n\n <\/a>Configure your protected Custom Variables<\/a> and click next then finish Icinga web 2 setup.<\/p>\n\n\n\n Check the summary and click Finish the setup.<\/p>\n\n\n\nInstalling Icinga 2 and Icinga Web 2 on Ubuntu<\/h2>\n\n\n\n
Installing Icinga Package Repositories<\/h3>\n\n\n\n
apt -y install apt-transport-https<\/code><\/pre>\n\n\n\n
wget -O - https:\/\/packages.icinga.com\/icinga.key | apt-key add -<\/code><\/pre>\n\n\n\n
echo \"deb http:\/\/packages.icinga.com\/ubuntu icinga-bionic main\" > \/etc\/apt\/sources.list.d\/icinga2.list\necho \"deb-src http:\/\/packages.icinga.com\/ubuntu icinga-bionic main\" >> \/etc\/apt\/sources.list.d\/icinga2.list<\/code><\/pre>\n\n\n\n
apt update<\/code><\/pre>\n\n\n\n
Install Icinga 2 on Ubuntu 18.04 LTS<\/h2>\n\n\n\n
apt install icinga2 -y<\/code><\/pre>\n\n\n\n
\n
checker<\/code> for executing checks<\/li>\n\n\n\n
mainlog<\/code> for writing the
icinga2.log<\/code> file<\/li>\n\n\n\n
notification<\/code> for sending notifications<\/li>\n<\/ul>\n\n\n\n
icinga2 feature list | grep -i enabled<\/code><\/pre>\n\n\n\n
Install Icinga 2 Monitoring Plugins<\/h3>\n\n\n\n
apt install monitoring-plugins -y<\/code><\/pre>\n\n\n\n
Run Icinga 2<\/h3>\n\n\n\n
systemctl status icinga2<\/code><\/pre>\n\n\n\n
systemctl start icinga2<\/code><\/pre>\n\n\n\n
systemctl enable icinga2<\/code><\/pre>\n\n\n\n
Install Icinga Web 2 ob Ubuntu 18.04<\/h2>\n\n\n\n
\n
Configure DB IDO MySQL<\/h3>\n\n\n\n
Installing MySQL database server on Ubuntu 18.04<\/h4>\n\n\n\n
apt install mariadb-server mariadb-client -y<\/code><\/pre>\n\n\n\n
mysql_secure_installation<\/code><\/pre>\n\n\n\n
Installing the IDO modules for MySQL<\/h4>\n\n\n\n
apt install icinga2-ido-mysql -y<\/code><\/pre>\n\n\n\n
\n
<\/figure><\/div><\/a><\/div>\n\n\n\n
\n
<\/figure>\n\n\n\n
\n
Enable the IDO MySQL Feature<\/h4>\n\n\n\n
icinga2 feature enable ido-mysql command<\/code><\/pre>\n\n\n\n
less \/etc\/icinga2\/features-available\/ido-mysql.conf<\/code><\/pre>\n\n\n\n
\n\/**\n * The db_ido_mysql library implements IDO functionality\n * for MySQL.\n *\/\n\nlibrary \"db_ido_mysql\"\n\nobject IdoMysqlConnection \"ido-mysql\" {\n user = \"icinga2\",\n password = \"SECUREDPASS\",\n host = \"localhost\",\n database = \"icinga2\"\n}\n<\/code><\/pre>\n\n\n\n
systemctl restart icinga2<\/code><\/pre>\n\n\n\n
Install Icinga Web 2 on Ubuntu 18.04<\/h3>\n\n\n\n
apt install icingaweb2 icingacli -y<\/code><\/pre>\n\n\n\n
vim \/etc\/php\/7.2\/apache2\/php.ini<\/code><\/pre>\n\n\n\n
\n...<\/strong>\n[Date]\n; Defines the default timezone used by the date functions\n; http:\/\/php.net\/date.timezone\n;date.timezone =\ndate.timezone = Africa\/Nairobi\n...<\/strong>\n<\/code><\/pre>\n\n\n\n
systemctl restart apache2<\/code><\/pre>\n\n\n\n
Create Icinga Web 2 Database<\/h3>\n\n\n\n
mysql -u root -p<\/code><\/pre>\n\n\n\n
create database icingawebusers;<\/code><\/pre>\n\n\n\n
grant all privileges on icingawebusers.* to icingaadmin<\/strong>@localhost identified by 'SECUREDPASS';<\/code><\/pre>\n\n\n\n
flush privileges\nquit<\/code><\/pre>\n\n\n\n
Setup Icinga Web 2 on Ubuntu 18.04<\/h3>\n\n\n\n
icingacli setup token create<\/code><\/pre>\n\n\n\n
The newly generated setup token is: 99b7614f6f1bf89e<\/strong><\/code><\/pre>\n\n\n\n
<\/figure>\n\n\n\n
<\/figure>\n\n\n\n
<\/figure>\n\n\n\n
<\/a><\/figure>\n\n\n\n
<\/figure>\n\n\n\n
<\/figure>\n\n\n\n
<\/figure>\n\n\n\n
<\/a><\/figure>\n\n\n\n
<\/figure>\n\n\n\n
<\/figure>\n\n\n\n
<\/figure>\n\n\n\n
There is currently no icinga instance writing to the IDO. Make sure that a icinga instance is configured and able to write to the IDO.<\/strong><\/code>, it simply means ido-mysql feature is not enabled. Enable it and restart Icinga 2.<\/p>\n\n\n\n
<\/figure>\n\n\n\n
<\/a><\/figure>\n\n\n\n
<\/figure>\n\n\n\n