{"id":382,"date":"2018-08-17T23:40:23","date_gmt":"2018-08-17T20:40:23","guid":{"rendered":"http:\/\/kifarunix.com\/?p=382"},"modified":"2024-03-10T17:44:09","modified_gmt":"2024-03-10T14:44:09","slug":"how-to-install-and-configure-nagios-core-on-ubuntu-18-04","status":"publish","type":"post","link":"https:\/\/kifarunix.com\/how-to-install-and-configure-nagios-core-on-ubuntu-18-04\/","title":{"rendered":"Install and Configure Nagios Core from Repos on Ubuntu 18.04"},"content":{"rendered":"\n<p>In this tutorial we are going to learn how to install and configure <a href=\"https:\/\/www.nagios.org\/projects\/nagios-core\/\" target=\"_blank\" rel=\"noopener noreferrer\">Nagios Core<\/a> from Repos on Ubuntu 18.04. Nagios is an enterprise grade free and open source software that can be used to monitor servers, applications and networks. It also offers alerting services for servers, switches, applications and services. Nagios supports both agentless and agent based monitoring.<\/p>\n\n\n\n<p>Ubuntu 18.04 default APT repos do not provide latest versions of Nagios Core. Nagios Core 4.4.5 is the current stable release version. Ubuntu 18.04 APT repos provide Nagios Core 3.5.1.<\/p>\n\n\n\n<p>Thus, this guide is a bit dated.<\/p>\n\n\n\n<p>To ensure you are running latest version of Nagios Core server on Ubuntu 18.04, check the guide below on how to build Nagios Core from source on Ubuntu 18.04.<\/p>\n\n\n\n<p><a title=\"Install and Configure Nagios Core From Source on Ubuntu 18.04\" href=\"https:\/\/kifarunix.com\/how-to-install-and-configure-nagios-core-from-the-source-ubuntu-18-04\/\" target=\"_blank\" rel=\"bookmark noopener noreferrer\">Install and Configure Nagios Core From Source on Ubuntu 18.04<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Install Nagios Core from Repos on Ubuntu 18.04<\/h2>\n\n\n\n<p>There are two ways in which Nagios can be installed;<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>From the Ubuntu repositories using the package manager (may not contain the latest features and bug fixes)<\/li>\n\n\n\n<li>Can be compiled from the source which ensures an up to-date installation.<\/li>\n<\/ul>\n\n\n\n<p>In this tutorial, we will learn how to install Nagios Core On Ubuntu 18.04 from the repos.<\/p>\n\n\n\n<p>If you want to build Nagios from source code on Ubuntu 18.04, then follow the link below;<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Install and Configure Nagios Core on Ubuntu 18.04<\/h3>\n\n\n\n<p>Run system update<\/p>\n\n\n\n<p>Before you can install Nagios from repos, ensure that apache http server as well as the necessary php modules are already installed. See installation command below:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>apt -y install apache2 php php-cgi libapache2-mod-php php-common php-pear php-mbstring<\/code><\/pre>\n\n\n\n<p>Once the above packages are install, install Nagios and the plugins to monitor Nagios server itself.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>apt -y install nagios3 nagios-plugins-basic<\/code><\/pre>\n\n\n\n<p>During installation you will&nbsp; be required to select the mail server configuration type that best meets your needs as well as the admin password for login in to Nagios web console.<\/p>\n\n\n\n<pre class=\"scroll-box\"><code>\n...\nPlease select the mail server configuration type that best meets your needs.\n\nNo configuration:\nShould be chosen to leave the current configuration unchanged.\nInternet site:\nMail is sent and received directly using SMTP.\nInternet with smarthost:\nMail is received directly using SMTP or by running a utility such\nas fetchmail. Outgoing mail is sent using a smarthost.\nSatellite system:\nAll mail is sent to another machine, called a 'smarthost', for delivery.\nLocal only:\nThe only delivered mail is the mail for local users. There is no network.\n\n1. No configuration 2. Internet Site 3. Internet with smarthost 4. Satellite system 5. Local only\n\nGeneral type of mail configuration: <strong>1<\/strong>\n\n\nConfiguring nagios3-cgi\n-----------------------\n\nPlease provide the password to be created with the \"nagiosadmin\" user.\n\nThis is the username and password you will use to log in to your nagios installation after configuration is complete. If you do not provide a password, you will have to configure access to nagios yourself.\n\nNagios web administration password: <strong>Enter you password<\/strong>\n\nPassword confirmation: <strong>Confirm your password\n...<\/strong>\n<\/code><\/pre>\n\n\n\n<p>After you enter the above details, installation will proceed. Once the installation is complete, configure Nagios as follows:<\/p>\n\n\n\n<p>Configure Nagios to check external commands and enable the use of CGI command interface by editing Nagios configuration file and changing the value of <strong>check_external_commands<\/strong> to 1 as shown below.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>vim \/etc\/nagios3\/nagios.cfg<\/code><\/pre>\n\n\n\n<pre class=\"scroll-box\"><code>\n<strong>...<\/strong>\n# EXTERNAL COMMAND OPTION\n# This option allows you to specify whether or not Nagios should check\n# for external commands (in the command file defined below). By default\n# Nagios will *not* check for external commands, just to be on the\n# cautious side. If you want to be able to use the CGI command interface\n# you will have to enable this.\n# Values: 0 = disable commands, 1 = enable commands\n\n<strong>check_external_commands=1\n...<\/strong>\n<\/code><\/pre>\n\n\n\n<p>To limit access to Nagios Server to specific hosts or networks, open the nagios apache configuration file and comment out the line;&nbsp; <strong>Allow From All<\/strong> and specify the hosts\/networks to allow as shown below.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>vim \/etc\/nagios3\/apache2.conf<\/code><\/pre>\n\n\n\n<pre class=\"scroll-box\"><code>\n ...\n    &lt;IfVersion &lt; 2.3&gt;\n        Order Allow,Deny\n        # <strong>Allow From All\n<\/strong><strong>        Allow From localhost 192.168.0.0\/24\n<\/strong>    &lt;IfVersion&gt;\n...\n<\/code><\/pre>\n\n\n\n<p>For my case since this is just for learning purposes, I will leave the defaults settings, <strong>Allow From All<\/strong>.<\/p>\n\n\n\n<p>Edit the nagios service configuration file and make the changes as follows;<\/p>\n\n\n\n<pre class=\"scroll-box\"><code>\n143&nbsp;&nbsp; if ! check_started; then\n144&nbsp;&nbsp;&nbsp;&nbsp; if ! check_named_pipe; then\n145&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; log_action_msg \"named pipe exists - removing\"\n146&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; rm -f $nagiospipe\n147&nbsp;&nbsp;&nbsp;  fi\n148&nbsp;&nbsp;&nbsp;  if check_config; then\n149&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  start_daemon -n $NICENESS -p $THEPIDFILE $DAEMON -d $NAGIOSCFG\n150&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  <strong>chmod o+rw \/var\/lib\/nagios3\/rw\/nagios.cmd<\/strong>\n151 &nbsp;&nbsp;&nbsp;&nbsp;  ret=$?\n152 &nbsp;&nbsp;  else\n<\/code><\/pre>\n\n\n\n<p>This lines add the read write permissions to the external command file, a file that Nagios checks for external command requests and is also where the command CGI will write commands that are submitted by users. Since the file is deleted every time its contents are processed, this ensures that the permissions are set whenever new file is created.<\/p>\n\n\n\n<p>Change the group of the <strong>\/var\/lib\/nagios3\/<\/strong> to apache <strong>www-data<\/strong> group.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>chgrp -R www-data \/var\/lib\/nagios3\/<\/code><\/pre>\n\n\n\n<p>Set the <strong>read and execute<\/strong> permissions on the group of directory holding the external command files, <strong>\/var\/lib\/nagios3\/rw\/.<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>chmod 750 \/var\/lib\/nagios3\/rw\/<\/code><\/pre>\n\n\n\n<p>Start and enable both apache and nagios to start on boot.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>systemctl enable apache2;systemctl start apache2\nsystemctl enable nagios3;systemctl start nagios3<\/code><\/pre>\n\n\n\n<p>Now access the Nagios web interface using the following URL, <strong>http:\/\/&lt;ip-address&gt;\/nagios3<\/strong>.<\/p>\n\n\n\n<p>You will prompted to enter the basic authentication username and password to access the dashboard.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1101\" height=\"570\" src=\"http:\/\/kifarunix.com\/wp-content\/uploads\/2018\/08\/Screenshot_20180818_095526.png\" alt=\"\" class=\"wp-image-393\" title=\"\" srcset=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2018\/08\/Screenshot_20180818_095526.png?v=1610131973 1101w, https:\/\/kifarunix.com\/wp-content\/uploads\/2018\/08\/Screenshot_20180818_095526-768x398.png?v=1610131973 768w, https:\/\/kifarunix.com\/wp-content\/uploads\/2018\/08\/Screenshot_20180818_095526-150x78.png?v=1610131973 150w, https:\/\/kifarunix.com\/wp-content\/uploads\/2018\/08\/Screenshot_20180818_095526-300x155.png?v=1610131973 300w, https:\/\/kifarunix.com\/wp-content\/uploads\/2018\/08\/Screenshot_20180818_095526-696x360.png?v=1610131973 696w, https:\/\/kifarunix.com\/wp-content\/uploads\/2018\/08\/Screenshot_20180818_095526-1068x553.png?v=1610131973 1068w, https:\/\/kifarunix.com\/wp-content\/uploads\/2018\/08\/Screenshot_20180818_095526-811x420.png?v=1610131973 811w\" sizes=\"(max-width: 1101px) 100vw, 1101px\" \/><\/figure>\n\n\n\n<p>Login as nagiosadmin using the password you set above. When you login, this dashboard below welcomes you.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1214\" height=\"709\" src=\"http:\/\/kifarunix.com\/wp-content\/uploads\/2018\/08\/Screenshot_20180818_100017.png\" alt=\"\" class=\"wp-image-394\" title=\"\" srcset=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2018\/08\/Screenshot_20180818_100017.png?v=1610131976 1214w, https:\/\/kifarunix.com\/wp-content\/uploads\/2018\/08\/Screenshot_20180818_100017-768x449.png?v=1610131976 768w, https:\/\/kifarunix.com\/wp-content\/uploads\/2018\/08\/Screenshot_20180818_100017-150x88.png?v=1610131976 150w, https:\/\/kifarunix.com\/wp-content\/uploads\/2018\/08\/Screenshot_20180818_100017-300x175.png?v=1610131976 300w, https:\/\/kifarunix.com\/wp-content\/uploads\/2018\/08\/Screenshot_20180818_100017-696x406.png?v=1610131976 696w, https:\/\/kifarunix.com\/wp-content\/uploads\/2018\/08\/Screenshot_20180818_100017-1068x624.png?v=1610131976 1068w, https:\/\/kifarunix.com\/wp-content\/uploads\/2018\/08\/Screenshot_20180818_100017-719x420.png?v=1610131976 719w\" sizes=\"(max-width: 1214px) 100vw, 1214px\" \/><\/figure>\n\n\n\n<p>You can view system status by clicking on the <strong>Tactical Overview<\/strong> option on the left panel under <strong>Current Status.<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1330\" height=\"601\" src=\"http:\/\/kifarunix.com\/wp-content\/uploads\/2018\/08\/Screenshot_20180818_100343.png\" alt=\"\" class=\"wp-image-395\" title=\"\" srcset=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2018\/08\/Screenshot_20180818_100343.png?v=1610131979 1330w, https:\/\/kifarunix.com\/wp-content\/uploads\/2018\/08\/Screenshot_20180818_100343-768x347.png?v=1610131979 768w, https:\/\/kifarunix.com\/wp-content\/uploads\/2018\/08\/Screenshot_20180818_100343-150x68.png?v=1610131979 150w, https:\/\/kifarunix.com\/wp-content\/uploads\/2018\/08\/Screenshot_20180818_100343-300x136.png?v=1610131979 300w, https:\/\/kifarunix.com\/wp-content\/uploads\/2018\/08\/Screenshot_20180818_100343-696x315.png?v=1610131979 696w, https:\/\/kifarunix.com\/wp-content\/uploads\/2018\/08\/Screenshot_20180818_100343-1068x483.png?v=1610131979 1068w, https:\/\/kifarunix.com\/wp-content\/uploads\/2018\/08\/Screenshot_20180818_100343-929x420.png?v=1610131979 929w\" sizes=\"(max-width: 1330px) 100vw, 1330px\" \/><\/figure>\n\n\n\n<p>There you go, you have successfully installed and configured Nagios Core on Ubuntu 8.04 and that marks the end of our guide on how to install Nagios Core from Repos on Ubuntu 18.04.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Nagios Related Tutorials<\/h3>\n\n\n\n<p><a title=\"Monitor Linux Hosts using Nagios check_by_ssh Plugin\" href=\"https:\/\/kifarunix.com\/monitor-linux-hosts-using-nagios-check_by_ssh-plugin\/\" target=\"_blank\" rel=\"bookmark noopener noreferrer\">Monitor Linux Hosts using Nagios check_by_ssh Plugin<\/a><\/p>\n\n\n\n<p><a title=\"Add Hosts to Nagios Server For Monitoring\" href=\"https:\/\/kifarunix.com\/add-hosts-to-nagios-server-for-monitoring\/\" target=\"_blank\" rel=\"bookmark noopener noreferrer\">Add Hosts to Nagios Server For Monitoring<\/a><\/p>\n\n\n\n<p><a title=\"Monitor SSL\/TLS Certificates Expiry with Nagios\" href=\"https:\/\/kifarunix.com\/monitor-ssl-tls-certificates-expiry-with-nagios\/\" target=\"_blank\" rel=\"bookmark noopener noreferrer\">Monitor SSL\/TLS Certificates Expiry with Nagios<\/a><\/p>\n\n\n\n<p><a title=\"Install Nagios NRPE Agent on CentOS 8\" href=\"https:\/\/kifarunix.com\/install-nagios-nrpe-agent-on-centos-8\/\" target=\"_blank\" rel=\"bookmark noopener noreferrer\">Install Nagios NRPE Agent on CentOS 8<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial we are going to learn how to install and configure Nagios Core from Repos on Ubuntu 18.04. Nagios is an enterprise grade<\/p>\n","protected":false},"author":1,"featured_media":12562,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_lock_modified_date":false,"footnotes":""},"categories":[72,73],"tags":[1559,1557,74,75,76,1558,77],"class_list":["post-382","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-monitoring","category-nagios","tag-install-nagios-core-on-ubuntu-18-04","tag-install-nagios-from-ubuntu-repos","tag-monitoring","tag-nagios","tag-nagios-core","tag-setup-nagios-on-ubuntu-18-04","tag-ubuntu-18-04-repos","generate-columns","tablet-grid-50","mobile-grid-100","grid-parent","grid-50","resize-featured-image"],"_links":{"self":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/382"}],"collection":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/comments?post=382"}],"version-history":[{"count":10,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/382\/revisions"}],"predecessor-version":[{"id":20954,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/382\/revisions\/20954"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media\/12562"}],"wp:attachment":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media?parent=382"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/categories?post=382"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/tags?post=382"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}