{"id":3087,"date":"2016-10-07T15:31:32","date_gmt":"2016-10-07T19:31:32","guid":{"rendered":"https:\/\/www.globo.tech\/learning-center\/?p=3087"},"modified":"2016-10-07T15:31:32","modified_gmt":"2016-10-07T19:31:32","slug":"install-configure-nagios-ubuntu-14","status":"publish","type":"post","link":"https:\/\/www.globo.tech\/learning-center\/install-configure-nagios-ubuntu-14\/","title":{"rendered":"How to install and configure Nagios on Ubuntu 14"},"content":{"rendered":"<p>Nagios is a free Unix software that allows you to monitor systems, networks, and infrastructure. It offers both monitoring and alerting services for configured servers, switches, applications, and services. One of the most useful features of Nagios is its double alert system. Not only will the user receive an alert when one of the monitored objects first encounters an error, a second alert will be given when the problem has been resolved. Nagios is a useful software that will give any system administrator some peace of mind when managing their systems, and can be installed on all Linux distributions. Thanks to the extensive capabilities of Nagios, it can even provide other benefits along with its traditional monitoring services such as reduced server downtime and resulting business loss prevention, assistance for IT upgrades and upgrade planning, and security breach detection.<\/p>\n<p>This guide will cover how to install Nagios on Ubuntu 14.<\/p>\n<h2>Getting Started<\/h2>\n<p>In order to complete this tutorial, you will need the following:<br \/>\n\u2022 1 server (<a href=\"https:\/\/www.globo.tech\/cloud-server-pricing\" target=\"_blank\">Cloud Server<\/a> or <a href=\"http:\/\/www.globo.tech\/dedicated-server-hosting\" target=\"_blank\">Dedicated Server<\/a>) running Ubuntu 14<\/p>\n<p>Before proceeding, you will also need to ensure that you are able to execute commands as root. This means that you should either be able to login as the root user, or ideally, execute root commands under a user with superuser privileges.<\/p>\n<h2>Tutorial<\/h2>\n<p>Nagios requires certain prerequisite packages which we can install using the default package manager utility for Ubuntu 14, apt-get. Execute the following command as root. You can either be logged in as the root user, or when using an account with superuser priviliges, append the command sudo to the start of the line.<\/p>\n<p><code>apt-get install wget build-essential libgd2-xpm-dev apache2-utils unzip<\/code><\/p>\n<p>To run Nagios, you will also need to have the Apache web server and PHP. The Apache HTTP server is the most popularly used open-source multi-platform web server, providing the full range of web features such as CGI, SSL, and virtual domains. PHP, which stands for PHP: Hypertext Preprocessor, is another popular open-source tool and is a scripting language that is especially suited for web development. Install Apache and PHP (as well as some prerequisite packages) with apt-get:<\/p>\n<p><code>apt-get install apache2 php5 php5-mysql php5-gd libgd-dev libapache2-mod-php5<\/code><\/p>\n<p>When Apache is installed, you will need to make some modifications to its configuration in order for the web server to be able to handle PHP. First, we will need to modify the serving preferences of Apache. By default, Apache will look for a file called index.html in the webroot directory \/var\/www\/html\/. However, we want it to serve instead the index.php file, even if the HTML file is also present. We can easily modify the preferences of Apache by opening the configuration file from \/etc\/apache2\/mods-enabled\/dir.conf using the text editor nano:<\/p>\n<p><code>nano \/etc\/apache2\/mods-enabled\/dir.conf<\/code><\/p>\n<p>With the file open, you will see the following:<\/p>\n<p><code class=\"gris\">&lt;ifmodule mod_dir.c=\"mod_dir.c\"&gt;<br \/>\nDirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm<br \/>\n&lt;\/ifmodule&gt;<\/code><\/p>\n<p>This file dictates the preference order of Apache web server, and the most preferred files are found to the left, with the least preferred on the right. We will need to move index.php from its current place in the middle of the list to the leftmost side, coming immediately before index.html. The modified final file should look as follows:<\/p>\n<p><code class=\"gris\">&lt;ifmodule mod_dir.c=\"mod_dir.c\"&gt;<br \/>\nDirectoryIndex index.php index.html index.cgi index.pl index.xhtml index.htm<br \/>\n&lt;\/ifmodule&gt;<\/code><\/p>\n<p>Save the file and close nano when you are finished. Next, restart Apache for the changes to take into effect:<\/p>\n<p><code>service apache2 restart<\/code><\/p>\n<p>To run Nagios, you will need to create a specific user to serve as the Nagios user. You can easily create a new user with the useradd command, which will create a user with whichever name is specified after the command (in this case &#8220;nagios&#8221;). Execute the following as root:<\/p>\n<p><code>useradd -m nagios<\/code><\/p>\n<p>After entering the user creation command, you will need to provide the user with a password. Execute the passwd command and when prompted, enter the new password.<\/p>\n<p><code>passwd nagios<\/code><\/p>\n<p>Next, create the &#8220;nagcmd&#8221; group for Nagios. This will allow external commands to be submitted through the web interface. We will add both the Nagios user and the Apache user to the group. The usermod command will allow us to modify various details of a user, such as the group.<\/p>\n<p><code>groupadd nagcmd<br \/>\nusermod -a -G nagcmd nagios<br \/>\nusermod -a -G nagcmd www-data<\/code><\/p>\n<p>To actually install Nagios, you will first to obtain some information about the latest stable release versions from the Nagios downloads page. Check both the versions of Nagios Core and the Nagios Plugins, you will need them. While Nagios Core will provide the base functionality above, the Plugins package is required in order to best take advantage of the Nagios offering by allowing you to monitor hosts, devices, services, protocols, and applications. At the time of writing, the latest stable release of Nagios Core is 4.2.1 and Nagios Plugins is 2.1.2. The following command, which uses the web utility wget, will then download the Nagios Core and Plugins files. Replace the respective version numbers with the latest numbers if they have changed.<\/p>\n<p><code>wget https:\/\/assets.nagios.com\/downloads\/nagioscore\/releases\/nagios-4.2.1.tar.gz<br \/>\nwget http:\/\/www.nagios-plugins.org\/download\/nagios-plugins-2.1.2.tar.gz<\/code><\/p>\n<p>The previous step will have downloaded two archived TAR files to whichever directory you executed the command in. To unarchive the files so that you can use them, use the command tar with the options xzf to extract (x the files, filter the archive through gzip (z, and output the new unpacked directory with the same file name (f). First, start with the Nagios Core:<\/p>\n<p><code>tar xzf nagios-4.2.1.tar.gz<\/code><\/p>\n<p>Next, change to the new unpacked directory:<\/p>\n<p><code>cd nagios-4.2.1\/<\/code><\/p>\n<p>To compile and install Nagios, you will need to build it from source using make. Execute all of the following commands in the Nagios directory as the superuser. Don&#8217;t forget to append sudo to the beginning of each command if you are not directly signed in as root.<\/p>\n<p><code>.\/configure --with-command-group=nagcmd<br \/>\nmake all<br \/>\nmake install<br \/>\nmake install-init<br \/>\nmake install-config<br \/>\nmake install-commandmode<\/code><\/p>\n<p>When the above make commands have completed, you will need to finally install the Nagios web interface using:<\/p>\n<p><code>make install-webconf<\/code><\/p>\n<p>There is a chance that you will receive the following error when installing the web interface:<\/p>\n<p><code class=\"gris\">\/usr\/bin\/install -c -m 644 sample-config\/httpd.conf \/etc\/httpd\/conf.d\/nagios.conf<br \/>\n\/usr\/bin\/install: cannot create regular file \u2018\/etc\/httpd\/conf.d\/nagios.conf\u2019: No such file or directory<br \/>\nMakefile:296: recipe for target 'install-webconf' failed<br \/>\nmake: *** [install-webconf] Error 1<\/code><\/p>\n<p>This issue occurs if Nagios tries to create its configuration file, nagios.conf, inside the \/etc\/httpd.conf\/ directory. However, this file should instead be in the \/etc\/apache2\/sites-enabled directory. We can ensure that the configuration file is placed in the correct directory by executing the following command in place of make install-webconf as root:<\/p>\n<p><code>\/usr\/bin\/install -c -m 644 sample-config\/httpd.conf \/etc\/apache2\/sites-enabled\/nagios.conf<\/code><\/p>\n<p>After the web interface installation completes, double check that the configuration file is where it should be using ls, which will list files in a given directory:<\/p>\n<p><code>ls -l \/etc\/apache2\/sites-enabled\/<\/code><\/p>\n<p>To log into the Nagios web interface, you will have to create a new administrative user account called nagiosadmin. You will use this to log into the Nagios web interface, so remember the password that you provide for this account. Create the user with:<\/p>\n<p><code>sudo htpasswd -c \/usr\/local\/nagios\/etc\/htpasswd.users nagiosadmin<\/code><\/p>\n<p>Restart the Apache web server for the changes made to take into effect with the service command, which allows you to manage all system services:<\/p>\n<p><code>service apache2 restart<\/code><\/p>\n<p>With Nagios and its web interface installed, you will need to then configure the Nagios account to set up the correct email address where you would like to receive alerts. Edit the \/usr\/local\/nagios\/etc\/objects\/contacts.cfg configuration file with the nano text editor to modify the email address associated with the nagiosadmin contact definition:<\/p>\n<p><code>nano \/usr\/local\/nagios\/etc\/objects\/contacts.cfg<\/code><\/p>\n<p>With the file open in nano, search for the following section of code. Locate the field called email in the contact definition for nagiosadmin. When you have found the correct section, edit the field to your email.<\/p>\n<p><code class=\"gris\">[...]<br \/>\ndefine contact{<br \/>\ncontact_name nagiosadmin ; Short name of user<br \/>\nuse generic-contact ; Inherit default values from generic-contact template (defined above)<br \/>\nalias Nagios Admin ; Full name of user<br \/>\nemail<br \/>\n}<br \/>\n[...]<\/code><\/p>\n<p>Save and close the file when you are finished editing.<\/p>\n<p>Now, we are ready to unzip and install the Nagios Plugins. In the directory where you downloaded the TAR archives, unarchive the plugins file nagios-plugins-2.1.2.tar.gz using tar xzf:<\/p>\n<p><code>tar xzf nagios-plugins-2.1.2.tar.gz<\/code><\/p>\n<p>When the unarchiving is done, change to the newly created plugin directory with the command cd:<\/p>\n<p><code>cd nagios-plugins-2.1.2\/<\/code><\/p>\n<p>In the plugin directory, execute the following three commands to compile and install the Nagios Plugins:<\/p>\n<p><code>.\/configure --with-nagios-user=nagios --with-nagios-group=nagios<br \/>\nmake<br \/>\nmake install<\/code><\/p>\n<p>You can easily check if your configuration files have any errors with the following command executed with superuser privileges:<\/p>\n<p><code>\/usr\/local\/nagios\/bin\/nagios -v \/usr\/local\/nagios\/etc\/nagios.cfg<\/code><\/p>\n<p>If there are no configuration errors, you will now be able to start up Nagios. Start it using the service command. As a bonus, add Nagios to run on boot so that you will not need to do it manually each time.<\/p>\n<p><code>service nagios start<br \/>\nln -s \/etc\/init.d\/nagios \/etc\/rcS.d\/S99nagios<\/code><\/p>\n<p>To verify the installation, access the Nagios interface at the following URL, replacing the text with the IP address of your Ubuntu 14 server:<\/p>\n<p>http:\/\/\/nagios<\/p>\n<p>The login details will be nagiosadmin, with the password that you set above. The Nagios administration console will display a variety of details about Nagios, Nagios news, and your system upon successful login.<\/p>\n<h2>Conclusion<\/h2>\n<p>Congratulations! With Nagios set up on your Ubuntu 14 server, you can feel safer knowing that your system is now more secure. With the ability to receive double alerts on a variety of possible desired objects to monitor, your Ubuntu 14 server is better equipped for whatever may happen. Explore the Nagios web interface and the online documentation to see what features will best suit your needs, and if you enjoyed this tutorial, feel free to share it with your friends!<\/p>\n<!-- AddThis Advanced Settings generic via filter on the_content --><!-- AddThis Share Buttons generic via filter on the_content -->","protected":false},"excerpt":{"rendered":"<p>Nagios is a free Unix software that allows you to monitor systems, networks, and infrastructure. It offers both monitoring and alerting services for configured servers, switches, applications, and services. One of the most useful features of Nagios is its double alert system. Not only will the user receive an alert when one of the monitored<!-- AddThis Advanced Settings generic via filter on get_the_excerpt --><!-- AddThis Share Buttons generic via filter on get_the_excerpt --><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[72],"tags":[],"class_list":["post-3087","post","type-post","status-publish","format-standard","hentry","category-monitoring"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.0 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to install and configure Nagios on Ubuntu 14 - Globo.Tech<\/title>\n<meta name=\"description\" content=\"This tutorial will show you how you can install and configure Nagios on your Ubuntu 14 Server. Read now &amp; Start monitoring today!\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.globo.tech\/learning-center\/install-configure-nagios-ubuntu-14\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to install and configure Nagios on Ubuntu 14 - Globo.Tech\" \/>\n<meta property=\"og:description\" content=\"This tutorial will show you how you can install and configure Nagios on your Ubuntu 14 Server. Read now &amp; Start monitoring today!\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.globo.tech\/learning-center\/install-configure-nagios-ubuntu-14\/\" \/>\n<meta property=\"og:site_name\" content=\"Globo.Tech\" \/>\n<meta property=\"article:published_time\" content=\"2016-10-07T19:31:32+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.globo.tech\/learning-center\/wp-content\/uploads\/2016\/09\/GloboTech-Logo.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1920\" \/>\n\t<meta property=\"og:image:height\" content=\"963\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"GloboTech Communications\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"GloboTech Communications\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"9 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.globo.tech\/learning-center\/install-configure-nagios-ubuntu-14\/\",\"url\":\"https:\/\/www.globo.tech\/learning-center\/install-configure-nagios-ubuntu-14\/\",\"name\":\"How to install and configure Nagios on Ubuntu 14 - Globo.Tech\",\"isPartOf\":{\"@id\":\"https:\/\/www.globo.tech\/learning-center\/#website\"},\"datePublished\":\"2016-10-07T19:31:32+00:00\",\"author\":{\"@id\":\"https:\/\/www.globo.tech\/learning-center\/#\/schema\/person\/e17784b37f4a4f49b7bc611847912e87\"},\"description\":\"This tutorial will show you how you can install and configure Nagios on your Ubuntu 14 Server. Read now & Start monitoring today!\",\"breadcrumb\":{\"@id\":\"https:\/\/www.globo.tech\/learning-center\/install-configure-nagios-ubuntu-14\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.globo.tech\/learning-center\/install-configure-nagios-ubuntu-14\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.globo.tech\/learning-center\/install-configure-nagios-ubuntu-14\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.globo.tech\/learning-center\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to install and configure Nagios on Ubuntu 14\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.globo.tech\/learning-center\/#website\",\"url\":\"https:\/\/www.globo.tech\/learning-center\/\",\"name\":\"Globo.Tech\",\"description\":\"Welcome to the Official Globo.Tech Learning Center\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.globo.tech\/learning-center\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.globo.tech\/learning-center\/#\/schema\/person\/e17784b37f4a4f49b7bc611847912e87\",\"name\":\"GloboTech Communications\",\"sameAs\":[\"http:\/\/www.gtcomm.net\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to install and configure Nagios on Ubuntu 14 - Globo.Tech","description":"This tutorial will show you how you can install and configure Nagios on your Ubuntu 14 Server. Read now & Start monitoring today!","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.globo.tech\/learning-center\/install-configure-nagios-ubuntu-14\/","og_locale":"en_US","og_type":"article","og_title":"How to install and configure Nagios on Ubuntu 14 - Globo.Tech","og_description":"This tutorial will show you how you can install and configure Nagios on your Ubuntu 14 Server. Read now & Start monitoring today!","og_url":"https:\/\/www.globo.tech\/learning-center\/install-configure-nagios-ubuntu-14\/","og_site_name":"Globo.Tech","article_published_time":"2016-10-07T19:31:32+00:00","og_image":[{"width":1920,"height":963,"url":"https:\/\/www.globo.tech\/learning-center\/wp-content\/uploads\/2016\/09\/GloboTech-Logo.png","type":"image\/png"}],"author":"GloboTech Communications","twitter_misc":{"Written by":"GloboTech Communications","Est. reading time":"9 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.globo.tech\/learning-center\/install-configure-nagios-ubuntu-14\/","url":"https:\/\/www.globo.tech\/learning-center\/install-configure-nagios-ubuntu-14\/","name":"How to install and configure Nagios on Ubuntu 14 - Globo.Tech","isPartOf":{"@id":"https:\/\/www.globo.tech\/learning-center\/#website"},"datePublished":"2016-10-07T19:31:32+00:00","author":{"@id":"https:\/\/www.globo.tech\/learning-center\/#\/schema\/person\/e17784b37f4a4f49b7bc611847912e87"},"description":"This tutorial will show you how you can install and configure Nagios on your Ubuntu 14 Server. Read now & Start monitoring today!","breadcrumb":{"@id":"https:\/\/www.globo.tech\/learning-center\/install-configure-nagios-ubuntu-14\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.globo.tech\/learning-center\/install-configure-nagios-ubuntu-14\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.globo.tech\/learning-center\/install-configure-nagios-ubuntu-14\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.globo.tech\/learning-center\/"},{"@type":"ListItem","position":2,"name":"How to install and configure Nagios on Ubuntu 14"}]},{"@type":"WebSite","@id":"https:\/\/www.globo.tech\/learning-center\/#website","url":"https:\/\/www.globo.tech\/learning-center\/","name":"Globo.Tech","description":"Welcome to the Official Globo.Tech Learning Center","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.globo.tech\/learning-center\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.globo.tech\/learning-center\/#\/schema\/person\/e17784b37f4a4f49b7bc611847912e87","name":"GloboTech Communications","sameAs":["http:\/\/www.gtcomm.net"]}]}},"_links":{"self":[{"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/posts\/3087","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/comments?post=3087"}],"version-history":[{"count":1,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/posts\/3087\/revisions"}],"predecessor-version":[{"id":3088,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/posts\/3087\/revisions\/3088"}],"wp:attachment":[{"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/media?parent=3087"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/categories?post=3087"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/tags?post=3087"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}