{"id":2760,"date":"2016-09-22T17:21:28","date_gmt":"2016-09-22T21:21:28","guid":{"rendered":"https:\/\/www.globo.tech\/learning-center\/?p=2760"},"modified":"2016-10-02T15:37:38","modified_gmt":"2016-10-02T19:37:38","slug":"install-configure-nagios-ubuntu-16","status":"publish","type":"post","link":"https:\/\/www.globo.tech\/learning-center\/install-configure-nagios-ubuntu-16\/","title":{"rendered":"How to Install and Configure Nagios on Ubuntu 16"},"content":{"rendered":"<p>Nagios is a proven monitoring solution for your IT infrastructure. If you run complex networks of services and hardware, many subtle problems might arise and remain undetected. Unfortunately, when the effects of these issues manifest, they usually do so in ways that negatively impact or take down critical services on which you depend for work or revenue. Often, spotting these issues in advance makes them easier to mitigate, and even when it doesn&#8217;t, it&#8217;s better to detect problems yourself than have your customers do so for you. If you run production infrastructure and are not monitoring it, then you should start doing so today. If unsure of what to use, it is difficult to go wrong with Nagios.<\/p>\n<h2>Getting Started<\/h2>\n<p>Before you begin, make sure you have the following prepared:<br \/>\n\u2022 1 Remote 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 16<br \/>\n\u2022 All commands should be run as the root user<\/p>\n<h2>Tutorial<\/h2>\n<p>Begin by installing the basic packages on which Nagios depends.<\/p>\n<p><code>apt-get install gcc unzip make<\/code><\/p>\n<p>Nagios also needs the Apache web server and PHP programming language. Continue by installing both.<\/p>\n<p><code>apt-get install apache2 php libapache2-mod-php php-mcrypt<\/code><\/p>\n<p>Now that PHP is installed, you&#8217;ll need to tell Apache how to run scripts. Here we configure it to do so.<\/p>\n<p><code>nano \/etc\/apache2\/mods-enabled\/dir.conf<\/code><\/p>\n<p>By default, many PHP apps use the index.php script as an entrypoint. Ensure that index.php is listed first in the below line from your configuration file:<\/p>\n<p><code>&lt;IfModule 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>Apache is now configured to run PHP scripts. Let&#8217;s restart it so the configuration changes take effect.<\/p>\n<p><code>systemctl restart apache2.service<\/code><\/p>\n<p>Next we&#8217;ll add a Nagios user for Apache, and for the nacmd utility.<\/p>\n<p><code>useradd nagios<br \/>\ngroupadd nagcmd<br \/>\nusermod -a -G nagcmd nagios<br \/>\nusermod -a -G nagcmd www-data<\/code><\/p>\n<p>In order to get the latest Nagios, we&#8217;ll download it directly from the official site. We&#8217;ll also retrieve some of the more popular plugins you&#8217;ll likely want running in your installation.<\/p>\n<p><code>cd \/tmp<br \/>\nwget https:\/\/assets.nagios.com\/downloads\/nagioscore\/releases\/nagios-4.2.1.tar.gz<br \/>\nwget https:\/\/nagios-plugins.org\/download\/nagios-plugins-2.1.2.tar.gz<\/code><\/p>\n<p>Unzip the archive you&#8217;ve just downloaded and install Nagios itself.<\/p>\n<p><code>tar -zxvf nagios-4.2.1.tar.gz<br \/>\ncd nagios-4.2.1\/<br \/>\n.\/configure --with-nagios-group=nagios --with-command-group=nagcmd --with-httpd_conf=\/etc\/apache2\/sites-enabled\/<br \/>\nmake all<br \/>\nmake install<br \/>\nmake install-init<br \/>\nmake install-config<br \/>\nmake install-commandmode<br \/>\nmake install-webconf<\/code><\/p>\n<p>You&#8217;ll now need to edit the contact file, changing the email address to one that you monitor.<\/p>\n<p><code>nano \/usr\/local\/nagios\/etc\/objects\/contacts.cfg<\/code><\/p>\n<p><code class=\"gris\">[...]<br \/>\n# This contact definition inherits a lot of default values from the 'generic-contact'<br \/>\n# template which is defined elsewhere.<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 nagios@localhost ; &lt;&lt;***** CHANGE THIS TO YOUR EMAIL ADDRESS ******<br \/>\n}<br \/>\n[...]<\/code><\/p>\n<p>Nagios needs a password to be set in order for you to access the web interface. Since monitoring is a critical aspect of your infrastructure, you&#8217;ll want to pick a strong password and keep it secure. Anyone who has access to Nagios can gain vital insight into how your systems are set up, and might use said knowledge to orchestrate attacks.<\/p>\n<p><code>htpasswd -c \/usr\/local\/nagios\/etc\/htpasswd.users nagiosadmin<br \/>\na2enmod cgi<br \/>\nsystemctl restart apache2.service<\/code><\/p>\n<p>Next, unzip and install the archive containing Nagios&#8217; plugins.<\/p>\n<p><code>cd \/tmp<br \/>\ntar -zxvf nagios-plugins-2.1.2.tar.gz<br \/>\ncd nagios-plugins-2.1.2\/<br \/>\n.\/configure --with-nagios-user=nagios --with-nagios-group=nagios<br \/>\nmake<br \/>\nmake install<\/code><\/p>\n<p>It is easy to make mistakes when editing the Nagios config file. Let&#8217;s ensure that it has no errors.<\/p>\n<p><code>\/usr\/local\/nagios\/bin\/nagios -v \/usr\/local\/nagios\/etc\/nagios.cfg<\/code><\/p>\n<p><code class=\"gris\">Nagios Core 4.2.1<br \/>\nCopyright (c) 2009-present Nagios Core Development Team and Community Contributors<br \/>\nCopyright (c) 1999-2009 Ethan Galstad<br \/>\nLast Modified: 09-06-2016<br \/>\nLicense: GPL<br \/>\nWebsite: https:\/\/www.nagios.org<br \/>\nReading configuration data...<br \/>\nRead main config file okay...<br \/>\nRead object config files okay...<br \/>\nRunning pre-flight check on configuration data...<br \/>\nChecking objects...<br \/>\nChecked 8 services.<br \/>\nChecked 1 hosts.<br \/>\nChecked 1 host groups.<br \/>\nChecked 0 service groups.<br \/>\nChecked 1 contacts.<br \/>\nChecked 1 contact groups.<br \/>\nChecked 24 commands.<br \/>\nChecked 5 time periods.<br \/>\nChecked 0 host escalations.<br \/>\nChecked 0 service escalations.<br \/>\nChecking for circular paths...<br \/>\nChecked 1 hosts<br \/>\nChecked 0 service dependencies<br \/>\nChecked 0 host dependencies<br \/>\nChecked 5 timeperiods<br \/>\nChecking global event handlers...<br \/>\nChecking obsessive compulsive processor commands...<br \/>\nChecking misc settings...<br \/>\nTotal Warnings: 0<br \/>\nTotal Errors: 0<br \/>\nThings look okay - No serious problems were detected during the pre-flight check<\/code><\/p>\n<p>Nagios does not ship a systemd unit file, a specification needed to start and stop Nagios. Create one with these contents.<\/p>\n<p><code>nano \/etc\/systemd\/system\/nagios.service<\/code><\/p>\n<p><code class=\"gris\">[Unit]<br \/>\nDescription=Nagios<br \/>\nBindTo=network.target<br \/>\n[Install]<br \/>\nWantedBy=multi-user.target<br \/>\n[Service]<br \/>\nUser=nagios<br \/>\nGroup=nagios<br \/>\nType=simple<br \/>\nExecStart=\/usr\/local\/nagios\/bin\/nagios \/usr\/local\/nagios\/etc\/nagios.cfg<\/code><\/p>\n<p>With the unit file in place, we can now use systemd to enable Nagios to start on boot. We can also start it immediately.<\/p>\n<p><code>systemctl enable \/etc\/systemd\/system\/nagios.service<br \/>\nsystemctl start nagios.service<\/code><\/p>\n<p>Nagios should be up and running. To check its status, access the built-in web interface. Visit http:\/\/your_ip\/nagios\/ to continue. The default credentials are &#8220;nagiosadmin&#8221; for the username, and your password set previously as the password.<\/p>\n<h2>Conclusion<\/h2>\n<p>That was easy. You&#8217;re now keeping tabs on this server with Nagios, and can detect many significant issues before they become critical. Many system administrators fail to be proactive about watching their servers, so share this article with anyone you know who isn&#8217;t sold on the need for good monitoring. If you found this article helpful, feel free to share it with your friends and let us know in the comments below! <\/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 proven monitoring solution for your IT infrastructure. If you run complex networks of services and hardware, many subtle problems might arise and remain undetected. Unfortunately, when the effects of these issues manifest, they usually do so in ways that negatively impact or take down critical services on which you depend for work<!-- 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-2760","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 16 - Globo.Tech<\/title>\n<meta name=\"description\" content=\"This tutorial will show you how you can install and configure Nagios on your Ubuntu 16 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-16\/\" \/>\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 16 - Globo.Tech\" \/>\n<meta property=\"og:description\" content=\"This tutorial will show you how you can install and configure Nagios on your Ubuntu 16 Server. Read now &amp; Start monitoring today!\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.globo.tech\/learning-center\/install-configure-nagios-ubuntu-16\/\" \/>\n<meta property=\"og:site_name\" content=\"Globo.Tech\" \/>\n<meta property=\"article:published_time\" content=\"2016-09-22T21:21:28+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2016-10-02T19:37:38+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=\"5 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-16\/\",\"url\":\"https:\/\/www.globo.tech\/learning-center\/install-configure-nagios-ubuntu-16\/\",\"name\":\"How to Install and Configure Nagios on Ubuntu 16 - Globo.Tech\",\"isPartOf\":{\"@id\":\"https:\/\/www.globo.tech\/learning-center\/#website\"},\"datePublished\":\"2016-09-22T21:21:28+00:00\",\"dateModified\":\"2016-10-02T19:37:38+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 16 Server. Read now & Start monitoring today!\",\"breadcrumb\":{\"@id\":\"https:\/\/www.globo.tech\/learning-center\/install-configure-nagios-ubuntu-16\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.globo.tech\/learning-center\/install-configure-nagios-ubuntu-16\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.globo.tech\/learning-center\/install-configure-nagios-ubuntu-16\/#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 16\"}]},{\"@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 16 - Globo.Tech","description":"This tutorial will show you how you can install and configure Nagios on your Ubuntu 16 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-16\/","og_locale":"en_US","og_type":"article","og_title":"How to Install and Configure Nagios on Ubuntu 16 - Globo.Tech","og_description":"This tutorial will show you how you can install and configure Nagios on your Ubuntu 16 Server. Read now & Start monitoring today!","og_url":"https:\/\/www.globo.tech\/learning-center\/install-configure-nagios-ubuntu-16\/","og_site_name":"Globo.Tech","article_published_time":"2016-09-22T21:21:28+00:00","article_modified_time":"2016-10-02T19:37:38+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":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.globo.tech\/learning-center\/install-configure-nagios-ubuntu-16\/","url":"https:\/\/www.globo.tech\/learning-center\/install-configure-nagios-ubuntu-16\/","name":"How to Install and Configure Nagios on Ubuntu 16 - Globo.Tech","isPartOf":{"@id":"https:\/\/www.globo.tech\/learning-center\/#website"},"datePublished":"2016-09-22T21:21:28+00:00","dateModified":"2016-10-02T19:37:38+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 16 Server. Read now & Start monitoring today!","breadcrumb":{"@id":"https:\/\/www.globo.tech\/learning-center\/install-configure-nagios-ubuntu-16\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.globo.tech\/learning-center\/install-configure-nagios-ubuntu-16\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.globo.tech\/learning-center\/install-configure-nagios-ubuntu-16\/#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 16"}]},{"@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\/2760","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=2760"}],"version-history":[{"count":3,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/posts\/2760\/revisions"}],"predecessor-version":[{"id":3031,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/posts\/2760\/revisions\/3031"}],"wp:attachment":[{"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/media?parent=2760"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/categories?post=2760"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/tags?post=2760"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}