{"id":11524,"date":"2019-03-14T10:51:45","date_gmt":"2019-03-14T10:51:45","guid":{"rendered":"http:\/\/www.appservgrid.com\/paw92\/?p=11524"},"modified":"2019-03-14T10:51:45","modified_gmt":"2019-03-14T10:51:45","slug":"how-to-install-nagios-4-in-ubuntu-and-debian","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/03\/14\/how-to-install-nagios-4-in-ubuntu-and-debian\/","title":{"rendered":"How to Install Nagios 4 in Ubuntu and Debian"},"content":{"rendered":"<p>In this topic we\u2019ll learn how to install and configure the latest official version of\u00a0<strong>Nagios Core<\/strong>\u00a0from sources in Debian and Ubuntu servers.<\/p>\n<p><strong>Nagios Core<\/strong>\u00a0is a free Open Source network monitoring application designed for monitoring network applications, devices and their related services and in a network.<\/p>\n<p><strong>Nagios<\/strong>\u00a0can remotely monitor specific operating system parameters via agents deployed on nodes and send alerts via mail or SMS in order to notify administrators in case critical services in a network, such as SMTP, HTTP, SSH, FTP and other fails.<\/p>\n<h4>Requirements<\/h4>\n<ol>\n<li><a href=\"https:\/\/www.tecmint.com\/installation-of-debian-9-minimal-server\/\" target=\"_blank\" rel=\"noopener\">Debian 9 Minimal Installation<\/a><\/li>\n<li><a href=\"https:\/\/www.tecmint.com\/installation-of-ubuntu-16-04-server-edition\/\" target=\"_blank\" rel=\"noopener\">Ubuntu 16.04 Minimal Installation<\/a><\/li>\n<\/ol>\n<h3>Step 1: Install Pre-requirements for Nagios<\/h3>\n<p><strong>1.<\/strong>\u00a0Before installing Nagios Core from sources in\u00a0<strong>Ubuntu<\/strong>\u00a0or\u00a0<strong>Debian<\/strong>, first install the following LAMP stack components in your system, without\u00a0<strong>MySQL RDBMS<\/strong>\u00a0database component, by issuing the below command.<\/p>\n<pre># apt install apache2 libapache2-mod-php7.0 php7.0<\/pre>\n<p><strong>2.<\/strong>\u00a0On the next step, install the following system dependencies and utilities required to compile and install\u00a0<strong>Nagios Core<\/strong>\u00a0from sources, by issuing the follwoing command.<\/p>\n<pre># apt install wget unzip zip  autoconf gcc libc6 make apache2-utils libgd-dev\r\n<\/pre>\n<h3>Step 2: Install Nagios 4 Core in Ubuntu and Debian<\/h3>\n<p><strong>3.<\/strong>\u00a0On the first step, create\u00a0<strong>nagios<\/strong>\u00a0system user and group and add nagios account to the Apache\u00a0<strong>www-data<\/strong>\u00a0user, by issuing the below commands.<\/p>\n<pre># useradd nagios\r\n# usermod -a -G nagios www-data\r\n<\/pre>\n<p><strong>4.<\/strong>\u00a0After all dependencies, packages and system requirements for compiling Nagios from sources are present in your system, go to Nagios webpage and grab the\u00a0<a href=\"https:\/\/www.nagios.org\/downloads\/nagios-core\/\" target=\"_blank\" rel=\"nofollow noopener\">latest version of Nagios Core<\/a>\u00a0stable source archive by issuing the following command.<\/p>\n<pre># wget https:\/\/assets.nagios.com\/downloads\/nagioscore\/releases\/nagios-4.3.4.tar.gz\r\n<\/pre>\n<p><strong>5.<\/strong>\u00a0Next, extract Nagios tarball and enter the extracted nagios directory, with the following commands. Issue\u00a0<a href=\"https:\/\/www.tecmint.com\/tag\/linux-ls-command\/\" target=\"_blank\" rel=\"noopener\">ls command<\/a>\u00a0to list nagios directory content.<\/p>\n<pre># tar xzf nagios-4.3.4.tar.gz \r\n# cd nagios-4.3.4\/\r\n# ls\r\n<\/pre>\n<div id=\"attachment_27786\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/11\/List-Nagios-Content.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-27786\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/11\/List-Nagios-Content.png\" sizes=\"auto, (max-width: 945px) 100vw, 945px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/11\/List-Nagios-Content.png 945w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/11\/List-Nagios-Content-768x231.png 768w\" alt=\"List Nagios Content\" width=\"945\" height=\"284\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">List Nagios Content<\/p>\n<\/div>\n<p><strong>6.<\/strong>\u00a0Now, start to compile Nagios from sources by issuing the below commands. Make sure you configure Nagios with Apache sites-enabled directory configuration by issuing the below command.<\/p>\n<pre># .\/configure --with-httpd-conf=\/etc\/apache2\/sites-enabled\r\n<\/pre>\n<p><strong>7.<\/strong>\u00a0In the next step, build Nagios files by issuing the following command.<\/p>\n<pre># make all\r\n<\/pre>\n<p><strong>8.<\/strong>\u00a0Now, install Nagios binary files, CGI scripts and HTML files by issuing the following command.<\/p>\n<pre># make install\r\n<\/pre>\n<p><strong>9.<\/strong>\u00a0Next, install Nagios daemon init and external command mode configuration files and make sure you enable nagios daemon system-wide by issuing the following commands.<\/p>\n<pre># make install-init\r\n# make install-commandmode\r\n# systemctl enable nagios.service\r\n<\/pre>\n<p><strong>10.<\/strong>\u00a0Next, run the following command in order to install some Nagios sample configuration files needed by Nagios to run properly by issuing the below command.<\/p>\n<pre># make install-config\r\n<\/pre>\n<p><strong>11.<\/strong>\u00a0Also, install Nagios configuration file for Apacahe web server, which can be fount in\u00a0<strong>\/etc\/apacahe2\/sites-enabled\/<\/strong>\u00a0directory, by executing the below command.<\/p>\n<pre># make install-webconf\r\n<\/pre>\n<p><strong>12.<\/strong>\u00a0Next, create\u00a0<strong>nagiosadmin<\/strong>\u00a0account and a password for this account necessary by Apache server to log in to Nagios web panel by issuing the following command.<\/p>\n<pre># htpasswd -c \/usr\/local\/nagios\/etc\/htpasswd.users nagiosadmin\r\n<\/pre>\n<p><strong>13.<\/strong>\u00a0To allow Apache HTTP server to execute Nagios cgi scripts and to access Nagios admin panel via HTTP, first enable cgi module in Apache and then restart Apache service and start and enable Nagios daemon system-wide by issuing the following commands.<\/p>\n<pre># a2enmod cgi\r\n# systemctl restart apache2\r\n# systemctl start nagios\r\n# systemctl enable nagios\r\n<\/pre>\n<p><strong>14.<\/strong>\u00a0Finally, log in to Nagios Web Interface by pointing a browser to your server\u2019s IP address or domain name at the following URL address via HTTP protocol. Log in to Nagios with nagiosadmin user the password setup with htpasswd script.<\/p>\n<pre>http:\/\/IP-Address\/nagios\r\nOR\r\nhttp:\/\/DOMAIN\/nagios\r\n<\/pre>\n<div id=\"attachment_27787\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/11\/Nagios-Admin-Login.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-27787\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/11\/Nagios-Admin-Login.png\" sizes=\"auto, (max-width: 861px) 100vw, 861px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/11\/Nagios-Admin-Login.png 861w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/11\/Nagios-Admin-Login-768x459.png 768w\" alt=\"Nagios Admin Login\" width=\"861\" height=\"515\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Nagios Admin Login<\/p>\n<\/div>\n<div id=\"attachment_27788\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/11\/Nagios-Core-Dashboard.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-27788\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/11\/Nagios-Core-Dashboard.png\" sizes=\"auto, (max-width: 896px) 100vw, 896px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/11\/Nagios-Core-Dashboard.png 896w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/11\/Nagios-Core-Dashboard-768x539.png 768w\" alt=\"Nagios Core Dashboard\" width=\"896\" height=\"629\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Nagios Core Dashboard<\/p>\n<\/div>\n<p><strong>15.<\/strong>\u00a0To view your hosts status, navigate to\u00a0<strong>Current Status -&gt; Hosts<\/strong>\u00a0menu where you will notice that some errors are displayed for localhost host, as illustrated in the below screenshot. The error appears because Nagios has no plugins installed to check hosts and services status.<\/p>\n<div id=\"attachment_27789\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/11\/Check-Host-Status.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-27789\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/11\/Check-Host-Status.png\" sizes=\"auto, (max-width: 954px) 100vw, 954px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/11\/Check-Host-Status.png 954w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/11\/Check-Host-Status-768x531.png 768w\" alt=\"Check Host Status\" width=\"954\" height=\"659\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Check Host Status<\/p>\n<\/div>\n<h3>Step 3: Install Nagios Plugins in Ubuntu and Debian<\/h3>\n<p><strong>16.<\/strong>\u00a0To compile and install Nagios Plugins from sources in Debian or Ubuntu, at the first stage, install the following dependencies in your system, by issuing the below command.<\/p>\n<pre># apt install libmcrypt-dev make libssl-dev bc gawk dc build-essential snmp libnet-snmp-perl gettext libldap2-dev smbclient fping libmysqlclient-dev qmail-tools libpqxx3-dev libdbi-dev \r\n<\/pre>\n<p><strong>17.<\/strong>\u00a0Next, visit Nagios Plugins repositories page and\u00a0<a href=\"https:\/\/github.com\/nagios-plugins\/nagios-plugins\/releases\" target=\"_blank\" rel=\"nofollow noopener\">download the latest source code tarball<\/a>\u00a0by issuing the following command.<\/p>\n<pre># wget https:\/\/github.com\/nagios-plugins\/nagios-plugins\/archive\/release-2.2.1.tar.gz \r\n<\/pre>\n<p><strong>18.<\/strong>\u00a0Go ahead and extract the Nagios Plugins source code tarball and change path to the extracted nagios-plugins directory by executing the following commands.<\/p>\n<pre># tar xfz release-2.2.1.tar.gz \r\n# cd nagios-plugins-release-2.2.1\/\r\n<\/pre>\n<p><strong>19.<\/strong>\u00a0Now, start to compile and install Nagios Plugins from sources, by executing the following series of commands in your server console.<\/p>\n<pre># .\/tools\/setup \r\n# .\/configure \r\n# make\r\n# make install\r\n<\/pre>\n<p><strong>20.<\/strong>\u00a0The compiled and installed Nagios plugins can be located in\u00a0<strong>\/usr\/local\/nagios\/libexec\/<\/strong>\u00a0directory. List this directory to view all available plugins in your system.<\/p>\n<pre># ls \/usr\/local\/nagios\/libexec\/\r\n<\/pre>\n<div id=\"attachment_27790\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/11\/Nagios-Plugins-Directory.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-27790\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/11\/Nagios-Plugins-Directory.png\" sizes=\"auto, (max-width: 1020px) 100vw, 1020px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/11\/Nagios-Plugins-Directory.png 1020w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/11\/Nagios-Plugins-Directory-768x145.png 768w\" alt=\"Nagios Plugins Directory\" width=\"1020\" height=\"192\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Nagios Plugins Directory<\/p>\n<\/div>\n<p><strong>21.<\/strong>\u00a0Finally, restart Nagios daemon in order to apply the installed plugins, by issuing the below command.<\/p>\n<pre># systemctl restart nagios.service\r\n<\/pre>\n<p><strong>22.<\/strong>\u00a0Next, log in to Nagios web panel and go to\u00a0<strong>Current Status -&gt; Services<\/strong>\u00a0menu and you should notice all hosts services are checked now by Nagios plugins.<\/p>\n<p>From the color code you should see the current services status: green color is for\u00a0<strong>OK<\/strong>\u00a0status, yellow for\u00a0<strong>Warning<\/strong>and red for\u00a0<strong>Critical<\/strong>\u00a0status.<\/p>\n<div id=\"attachment_27791\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/11\/Check-Host-Services.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-27791\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/11\/Check-Host-Services.png\" sizes=\"auto, (max-width: 954px) 100vw, 954px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/11\/Check-Host-Services.png 954w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/11\/Check-Host-Services-768x463.png 768w\" alt=\"Check Host Services\" width=\"954\" height=\"575\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Check Host Services<\/p>\n<\/div>\n<p><strong>23.<\/strong>\u00a0Finally, to access Nagios admin web interface via HTTPS protocol, issue the following commands to enable Apache SSL configurations and restart the Apache daemon to reflect changes.<\/p>\n<pre># a2enmod ssl \r\n# a2ensite default-ssl.conf\r\n# systemctl restart apache2\r\n<\/pre>\n<p><strong>24.<\/strong>\u00a0After you\u2019ve enabled Apache SSL configurations, open\u00a0<strong>\/etc\/apache2\/sites-enabled\/000-default.conf<\/strong>\u00a0file for editing and add the following block of code after\u00a0<strong>DocumentRoot<\/strong>\u00a0statement as shown in the below excerpt.<\/p>\n<pre>RewriteEngine on\r\nRewriteCond %{HTTPS} off\r\nRewriteRule ^(.*) https:\/\/%{HTTP_HOST}\/$1\r\n<\/pre>\n<div id=\"attachment_27792\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/11\/Configure-Apache-for-Nagios.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-27792\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/11\/Configure-Apache-for-Nagios.png\" alt=\"Configure Apache for Nagios\" width=\"720\" height=\"540\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Configure Apache for Nagios<\/p>\n<\/div>\n<p><strong>25.<\/strong>\u00a0You need to restart Apache daemon to apply the configured rules, by issuing the below command.<\/p>\n<pre># systemctl restart apache2.service \r\n<\/pre>\n<p><strong>26.<\/strong>\u00a0Finally, refresh the browser in order to be redirected to Nagios admin panel via HTTPS protocol. Accept the wanting message that gets displayed in the browser and log in to Nagios again with the your credentials.<\/p>\n<div id=\"attachment_27793\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/11\/Nagios-HTTPS-Dashboard.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-27793\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/11\/Nagios-HTTPS-Dashboard.png\" sizes=\"auto, (max-width: 825px) 100vw, 825px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/11\/Nagios-HTTPS-Dashboard.png 825w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/11\/Nagios-HTTPS-Dashboard-768x455.png 768w\" alt=\"Nagios HTTPS Dashboard\" width=\"825\" height=\"489\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Nagios HTTPS Dashboard<\/p>\n<\/div>\n<p>Congratulations! You have successfully install and configured\u00a0<strong>Nagios Core<\/strong>\u00a0monitoring system from sources in\u00a0<strong>Ubuntu<\/strong>\u00a0server or\u00a0<strong>Debian 9<\/strong>.<\/p>\n<p><a href=\"https:\/\/www.tecmint.com\/install-nagios-core-in-ubuntu-and-debian\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this topic we\u2019ll learn how to install and configure the latest official version of\u00a0Nagios Core\u00a0from sources in Debian and Ubuntu servers. Nagios Core\u00a0is a free Open Source network monitoring application designed for monitoring network applications, devices and their related services and in a network. Nagios\u00a0can remotely monitor specific operating system parameters via agents deployed &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/03\/14\/how-to-install-nagios-4-in-ubuntu-and-debian\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;How to Install Nagios 4 in Ubuntu and Debian&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-11524","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/11524","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/comments?post=11524"}],"version-history":[{"count":1,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/11524\/revisions"}],"predecessor-version":[{"id":11525,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/11524\/revisions\/11525"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/media?parent=11524"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/categories?post=11524"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/tags?post=11524"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}