{"id":654,"date":"2017-01-12T10:55:43","date_gmt":"2017-01-12T08:55:43","guid":{"rendered":"http:\/\/helia.ee\/koolitus\/?page_id=654"},"modified":"2017-01-12T10:55:43","modified_gmt":"2017-01-12T08:55:43","slug":"nagios-4-debian-8","status":"publish","type":"page","link":"https:\/\/helia.ee\/koolitus\/?page_id=654","title":{"rendered":"Nagios 4 &#8211; Debian 8"},"content":{"rendered":"<h1 class=\"doc-title\">Install Nagios 4 on Ubuntu and Debian 8<\/h1>\n<p class=\"doc-time doc-modified-time\"><small class=\"updated\">Updated <time datetime=\"2016-04-12T00:00:00+00:00\">Tuesday, April 12th, 2016<\/time> by Edward Angert<\/small><small class=\"contributed-by\">Contributed by <a href=\"http:\/\/github.com\/paulotfilho\">Paulo Telles <i class=\"fa fa-github\"><\/i><\/a><\/small><\/p>\n<div class=\"signup-top\">Use promo code <strong>DOCS10<\/strong> for $10 credit on a new account.<\/p>\n<form action=\"https:\/\/manager.linode.com\/session\/signup\"><button class=\"btn btn-blue btn-sm btn-border\" type=\"submit\">Try this Guide<\/button><\/form>\n<\/div>\n<div class=\"library-github\"><i class=\"fa fa-github\"><\/i> <strong>Contribute on GitHub<\/strong><a href=\"https:\/\/github.com\/linode\/docs\">View Project<\/a> | <a href=\"https:\/\/github.com\/linode\/docs\/blob\/master\/docs\/uptime\/monitoring\/install-nagios-4-on-ubuntu-debian-8.md\">View File<\/a> | <a href=\"https:\/\/github.com\/linode\/docs\/edit\/master\/docs\/uptime\/monitoring\/install-nagios-4-on-ubuntu-debian-8.md\">Edit File<\/a><\/p>\n<\/div>\n<p><em>This is a Linode Community guide. Write for us and earn $250 per published guide.<\/em><\/p>\n<hr \/>\n<p>A monitoring tool is a key application in a production server. Nagios is a popular tool that provides monitoring and alerting services for your servers, applications and services. Using Nagios and a wide variety of available plugins, you can keep track of the status of your critical services like HTTP, SSH and SMTP. In this guide, you\u2019ll learn how to install Nagios 4 on your Linode.<\/p>\n<h2 id=\"before-you-begin\">Before You Begin<\/h2>\n<ol>\n<li>In order to run Nagios on your Linode, follow the configuration steps for Ubuntu or Debian 8 from our <a href=\"https:\/\/www.linode.com\/docs\/getting-started\/\">Getting Started guide<\/a>.<\/li>\n<li>Install and configure a LAMP stack (Linux, Apache, MySQL and PHP stack). Follow the <a href=\"https:\/\/www.linode.com\/docs\/websites\/lamp\/lamp-on-ubuntu-14-04\">LAMP on Ubuntu 14.04<\/a> or <a href=\"https:\/\/www.linode.com\/docs\/websites\/lamp\/lamp-on-debian-8-jessie\">LAMP on Debian 8<\/a> guide for instructions.<\/li>\n<li>Install updates:\n<div class=\"highlight plaintext\">\n<table>\n<tbody>\n<tr>\n<td class=\"gutter gl\">\n<pre class=\"lineno\">1<\/pre>\n<\/td>\n<td class=\"code\">\n<pre>sudo apt-get update &amp;&amp; sudo apt-get upgrade\r\n<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/li>\n<\/ol>\n<blockquote class=\"note\"><p>This guide is written for a non-root user. Commands that require elevated privileges are prefixed with <code>sudo<\/code>. If you\u2019re not familiar with the <code>sudo<\/code> command, you can check our <a href=\"https:\/\/www.linode.com\/docs\/tools-reference\/linux-users-and-groups\">Users and Groups<\/a> guide.<\/p><\/blockquote>\n<h2 id=\"install-nagios\">Install Nagios<\/h2>\n<h3 id=\"create-users-and-groups\">Create Users and Groups<\/h3>\n<p>Create a user, <code>nagios<\/code>, and a distinct group, <code>nagcmd<\/code>. Add <code>nagios<\/code> and the Apache user, <code>www-data<\/code>, to the <code>nagcmd<\/code> group in order to run external commands on Nagios through the web interface:<\/p>\n<div class=\"highlight plaintext\">\n<table>\n<tbody>\n<tr>\n<td class=\"gutter gl\">\n<pre class=\"lineno\">1\r\n2\r\n3<\/pre>\n<\/td>\n<td class=\"code\">\n<pre>sudo useradd nagios\r\nsudo groupadd nagcmd\r\nsudo usermod -a -G nagcmd nagios &amp;&amp; sudo usermod -a -G nagcmd www-data\r\n<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<h3 id=\"build-nagios-4-from-source-code\">Build Nagios 4 from Source Code<\/h3>\n<p>The latest stable version of Nagios 4 is not available in Ubuntu or Debian\u2019s default repositories as of this writing. To install Nagios, download and install it from the source code:<\/p>\n<ol>\n<li>Install dependencies:\n<div class=\"highlight plaintext\">\n<table>\n<tbody>\n<tr>\n<td class=\"gutter gl\">\n<pre class=\"lineno\">1<\/pre>\n<\/td>\n<td class=\"code\">\n<pre>sudo apt-get install build-essential unzip openssl libssl-dev libgd2-xpm-dev xinetd apache2-utils\r\n<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/li>\n<li>In your web browser, go to <a href=\"https:\/\/www.nagios.org\/downloads\/core-stay-informed\/\">the Nagios Core DIY download page<\/a>. If you prefer not to register for updates, click <strong>Skip to download<\/strong>.<\/li>\n<li>Under <strong>Nagios Core<\/strong>, find the release that says <strong>Latest stable release<\/strong> under <strong>Notes<\/strong>, then copy the download link to your clipboard.<\/li>\n<li>Download and extract Nagios to your Linode using <code>wget<\/code>and <code>tar<\/code>, pasting the link from Step 3:\n<div class=\"highlight plaintext\">\n<table>\n<tbody>\n<tr>\n<td class=\"gutter gl\">\n<pre class=\"lineno\">1\r\n2<\/pre>\n<\/td>\n<td class=\"code\">\n<pre>wget https:\/\/assets.nagios.com\/downloads\/nagioscore\/releases\/nagios-4.1.1.tar.gz\r\ntar -xvf nagios-4.*.tar.gz\r\n<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/li>\n<li>Move to the newly created directory:\n<div class=\"highlight plaintext\">\n<table>\n<tbody>\n<tr>\n<td class=\"gutter gl\">\n<pre class=\"lineno\">1<\/pre>\n<\/td>\n<td class=\"code\">\n<pre>cd nagios-4.*\r\n<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/li>\n<li>Configure, compile and install Nagios:\n<div class=\"highlight plaintext\">\n<table>\n<tbody>\n<tr>\n<td class=\"gutter gl\">\n<pre class=\"lineno\">1\r\n2\r\n3\r\n4\r\n5\r\n6<\/pre>\n<\/td>\n<td class=\"code\">\n<pre>.\/configure --with-nagios-group=nagios --with-command-group=nagcmd\r\nmake all\r\nsudo make install\r\nsudo make install-init\r\nsudo make install-config\r\nsudo make install-commandmode\r\n<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/li>\n<\/ol>\n<h2 id=\"prepare-apache-and-configure-nagios-web-interface\">Prepare Apache and Configure Nagios Web Interface<\/h2>\n<ol>\n<li>Make sure Apache has <code>mod_rewrite<\/code> and <code>mod_cgi<\/code> enabled:\n<div class=\"highlight plaintext\">\n<table>\n<tbody>\n<tr>\n<td class=\"gutter gl\">\n<pre class=\"lineno\">1<\/pre>\n<\/td>\n<td class=\"code\">\n<pre>sudo a2enmod rewrite &amp;&amp; sudo a2enmod cgi\r\n<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/li>\n<li>Copy the sample virtual host configuration Nagios provides to <code>sites-available<\/code>:\n<div class=\"highlight plaintext\">\n<table>\n<tbody>\n<tr>\n<td class=\"gutter gl\">\n<pre class=\"lineno\">1<\/pre>\n<\/td>\n<td class=\"code\">\n<pre>sudo cp sample-config\/httpd.conf \/etc\/apache2\/sites-available\/nagios4.conf\r\n<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/li>\n<li>Restrict <code>nagios4.conf<\/code> file permissions:\n<div class=\"highlight plaintext\">\n<table>\n<tbody>\n<tr>\n<td class=\"gutter gl\">\n<pre class=\"lineno\">1<\/pre>\n<\/td>\n<td class=\"code\">\n<pre>sudo chmod 644 \/etc\/apache2\/sites-available\/nagios4.conf\r\n<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/li>\n<li>Enable the new virtual host:\n<div class=\"highlight plaintext\">\n<table>\n<tbody>\n<tr>\n<td class=\"gutter gl\">\n<pre class=\"lineno\">1<\/pre>\n<\/td>\n<td class=\"code\">\n<pre>sudo a2ensite nagios4.conf\r\n<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/li>\n<li>The web interface requires login. Create a <code>nagiosadmin<\/code>account and record the password you assign:\n<div class=\"highlight plaintext\">\n<table>\n<tbody>\n<tr>\n<td class=\"gutter gl\">\n<pre class=\"lineno\">1<\/pre>\n<\/td>\n<td class=\"code\">\n<pre>sudo htpasswd -c \/usr\/local\/nagios\/etc\/htpasswd.users nagiosadmin\r\n<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/li>\n<li>Restart Apache\n<div class=\"highlight plaintext\">\n<table>\n<tbody>\n<tr>\n<td class=\"gutter gl\">\n<pre class=\"lineno\">1<\/pre>\n<\/td>\n<td class=\"code\">\n<pre>sudo service apache2 restart\r\n<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/li>\n<\/ol>\n<h2 id=\"install-nagios-plugins\">Install Nagios Plugins<\/h2>\n<p>Nagios Plugins allow you to monitor services like DHCP, FTP, HTTP and NTP. To use Nagios Plugins, go to <a href=\"https:\/\/nagios-plugins.org\/downloads\/\">the Nagios Plugins downloads page<\/a> and copy the download link for the current stable release (e.g., <code>http:\/\/www.nagios-plugins.org\/download\/nagios-plugins-2.1.1.tar.gz<\/code>):<\/p>\n<ol>\n<li>Download and extract Nagios Plugins to your Linode using <code>wget<\/code> and <code>tar<\/code>, pasting the link you copied:\n<div class=\"highlight plaintext\">\n<table>\n<tbody>\n<tr>\n<td class=\"gutter gl\">\n<pre class=\"lineno\">1\r\n2<\/pre>\n<\/td>\n<td class=\"code\">\n<pre>wget http:\/\/www.nagios-plugins.org\/download\/nagios-plugins-2.1.1.tar.gz\r\ntar -xvf nagios-plugins-2*.tar.gz\r\n<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/li>\n<li>Change to the newly created directory, then configure, compile, and install Plugins:\n<div class=\"highlight plaintext\">\n<table>\n<tbody>\n<tr>\n<td class=\"gutter gl\">\n<pre class=\"lineno\">1\r\n2\r\n3\r\n4<\/pre>\n<\/td>\n<td class=\"code\">\n<pre>cd nagios-plugins-2.*\r\n.\/configure --with-nagios-user=nagios --with-nagios-group=nagios --with-openssl\r\nmake\r\nsudo make install\r\n<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/li>\n<\/ol>\n<h2 id=\"access-the-nagios-web-interface\">Access the Nagios Web Interface<\/h2>\n<ol>\n<li>Before accessing the Nagios Web Interface, start the Nagios service:\n<div class=\"highlight plaintext\">\n<table>\n<tbody>\n<tr>\n<td class=\"gutter gl\">\n<pre class=\"lineno\">1<\/pre>\n<\/td>\n<td class=\"code\">\n<pre>sudo service nagios start\r\n<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<blockquote class=\"note\"><p>For Ubuntu versions after 14.04, see the <a href=\"https:\/\/www.linode.com\/docs\/uptime\/monitoring\/install-nagios-4-on-ubuntu-debian-8#systemd\">Systemd section below<\/a> before running this step.<\/p><\/blockquote>\n<\/li>\n<li>The interface can be accessed in your web browser by appending <code>\/nagios<\/code> to your domain or Public IP. When prompted at login, use <code>nagiosadmin<\/code> as the user and use the password you assigned in the <strong>Configure Nagios Web Interface<\/strong> section.\n<p>You will be greeted with a screen like this one:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.linode.com\/docs\/assets\/greeting_nagios4.png\" alt=\"Nagios 4 Greeting\" \/><\/p>\n<p>To view monitoring status, click the <strong>Hosts<\/strong> link in the menu on the left. This example screenshot shows an active Nagios server called <code>localhost<\/code>:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.linode.com\/docs\/assets\/hosts_nagios4.png\" alt=\"Nagios 4 Hosts\" \/><\/li>\n<\/ol>\n<h3 id=\"systemd\">Systemd<\/h3>\n<p>As of this guide\u2019s publication, the Nagios build process does not create a systemd service file. In order to manage the service with systemd, create a Nagios service file for the system to load on initialization:<\/p>\n<dl class=\"file\">\n<dt>\/etc\/systemd\/system\/nagios.service<\/dt>\n<dd>\n<div class=\"highlight ini\">\n<table>\n<tbody>\n<tr>\n<td class=\"gutter gl\">\n<pre class=\"lineno\">1\r\n2\r\n3\r\n4\r\n5\r\n6\r\n7\r\n8\r\n9\r\n10\r\n11\r\n12<\/pre>\n<\/td>\n<td class=\"code\">\n<pre><span class=\"nn\">[Unit]<\/span>\r\n<span class=\"py\">Description<\/span><span class=\"p\">=<\/span><span class=\"s\">Nagios<\/span>\r\n<span class=\"py\">BindTo<\/span><span class=\"p\">=<\/span><span class=\"s\">network.target<\/span>\r\n\r\n<span class=\"nn\">[Install]<\/span>\r\n<span class=\"py\">WantedBy<\/span><span class=\"p\">=<\/span><span class=\"s\">multi-user.target<\/span>\r\n\r\n<span class=\"nn\">[Service]<\/span>\r\n<span class=\"py\">User<\/span><span class=\"p\">=<\/span><span class=\"s\">nagios<\/span>\r\n<span class=\"py\">Group<\/span><span class=\"p\">=<\/span><span class=\"s\">nagios<\/span>\r\n<span class=\"py\">Type<\/span><span class=\"p\">=<\/span><span class=\"s\">simple<\/span>\r\n<span class=\"py\">ExecStart<\/span><span class=\"p\">=<\/span><span class=\"s\">\/usr\/local\/nagios\/bin\/nagios \/usr\/local\/nagios\/etc\/nagios.cfg<\/span>\r\n<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/dd>\n<\/dl>\n<p>Enable the link, start the Nagios service, and check the status:<\/p>\n<div class=\"highlight plaintext\">\n<table>\n<tbody>\n<tr>\n<td class=\"gutter gl\">\n<pre class=\"lineno\">1\r\n2\r\n3<\/pre>\n<\/td>\n<td class=\"code\">\n<pre>sudo systemctl enable \/etc\/systemd\/system\/nagios.service\r\nsudo systemctl start nagios\r\nsystemctl status nagios\r\n<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>You can now continue at <a href=\"https:\/\/www.linode.com\/docs\/uptime\/monitoring\/install-nagios-4-on-ubuntu-debian-8#access-the-nagios-web-interface\">Access the Nagios Web Interface<\/a><\/p>\n<h2 id=\"next-steps\">Next Steps<\/h2>\n<p>Nagios contains numerous features that are beyond the scope of this document. Explore the Nagios administrative interface as well as the resources listed below to access more information regarding the setup and configuration of Nagios.<\/p>\n<p>Congratulations on your new Nagios monitoring and notification system!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Install Nagios 4 on Ubuntu and Debian 8 Updated Tuesday, April 12th, 2016 by Edward AngertContributed by Paulo Telles Use promo code DOCS10 for $10 credit on a new account. Try this Guide Contribute on GitHubView Project | View File | Edit File This is a Linode Community guide. Write for us and earn $250 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":649,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"class_list":["post-654","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/helia.ee\/koolitus\/index.php?rest_route=\/wp\/v2\/pages\/654","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/helia.ee\/koolitus\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/helia.ee\/koolitus\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/helia.ee\/koolitus\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/helia.ee\/koolitus\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=654"}],"version-history":[{"count":1,"href":"https:\/\/helia.ee\/koolitus\/index.php?rest_route=\/wp\/v2\/pages\/654\/revisions"}],"predecessor-version":[{"id":655,"href":"https:\/\/helia.ee\/koolitus\/index.php?rest_route=\/wp\/v2\/pages\/654\/revisions\/655"}],"up":[{"embeddable":true,"href":"https:\/\/helia.ee\/koolitus\/index.php?rest_route=\/wp\/v2\/pages\/649"}],"wp:attachment":[{"href":"https:\/\/helia.ee\/koolitus\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=654"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}