<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.itcollege.ee/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Ishustov</id>
	<title>ICO wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.itcollege.ee/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Ishustov"/>
	<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php/Special:Contributions/Ishustov"/>
	<updated>2026-06-20T20:27:49Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.45.1</generator>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Monitoring_Nagios&amp;diff=114758</id>
		<title>Monitoring Nagios</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Monitoring_Nagios&amp;diff=114758"/>
		<updated>2016-11-17T09:51:08Z</updated>

		<summary type="html">&lt;p&gt;Ishustov: /* Nagios */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Team: &lt;br /&gt;
Ilja Shustov,&lt;br /&gt;
Sheela Raj &lt;br /&gt;
&lt;br /&gt;
Group : Cyber Security Engineering (C21)&lt;br /&gt;
&lt;br /&gt;
Page Created: 10 November 2016&lt;br /&gt;
&lt;br /&gt;
‎Last modified: 12 November 2016&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
In this article, we will cover the installation of &#039;&#039;&#039;Nagios&#039;&#039;&#039;, a very popular open source monitoring system, on Ubuntu. We will cover some basic configuration, so you will be able to monitor host resources via the web interface. We will also utilize the Nagios Remote Plugin Executor (NRPE), that will be installed as an agent on remote hosts, to monitor their local resources.&lt;br /&gt;
&lt;br /&gt;
===Monitoring===&lt;br /&gt;
&lt;br /&gt;
Server monitoring  is basically scanning of the servers and network for detection of any issues, but it also monitors for user load, security and speed, if we are talking about web servers monitoring.&lt;br /&gt;
&lt;br /&gt;
===Why monitoring is important?===&lt;br /&gt;
Monitoring is important because it helps to detect the problem and prevent servers to go down, because any network crashes costs not only money but also time, so monitoring will ensure service availability.&lt;br /&gt;
&lt;br /&gt;
===Nagios===&lt;br /&gt;
Nagios is an open source application for system and networks monitoring and at the same time Nagios is one of the most popular solution for the monitoring.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
With the Nagios you are able to:&lt;br /&gt;
&lt;br /&gt;
*Detect problems&lt;br /&gt;
*Repair Problems&lt;br /&gt;
*Plan system upgrades before outdated system will fail&lt;br /&gt;
*Respond to issues as soon as they appeared&lt;br /&gt;
*Monitor entire infrastructure&lt;br /&gt;
&lt;br /&gt;
= Before You Begin =&lt;br /&gt;
===Check your current Ubuntu version &amp;amp; Upgrade===&lt;br /&gt;
&lt;br /&gt;
You can check your current ubuntu version by the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;lsb_release -a&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If your machine is already running Ubuntu 16.04.1 LTS or higher than that, There is no need for you to upgrade the OS.&lt;br /&gt;
&lt;br /&gt;
Otherwise you need to upgrade the OS by the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get update &amp;amp;&amp;amp; sudo apt-get upgrade&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039;&lt;br /&gt;
This article is written for a non-root user. Commands that require elevated privileges are prefixed with &amp;lt;code&amp;gt;sudo&amp;lt;/code&amp;gt;. If you’re not familiar with the &amp;lt;code&amp;gt;sudo&amp;lt;/code&amp;gt; command, you can check the [https://www.linode.com/docs/tools-reference/linux-users-and-groups Users and Groups] guide.&lt;br /&gt;
&lt;br /&gt;
===Install the required package===&lt;br /&gt;
&lt;br /&gt;
As a prerequisite, Nagios requires the gcc compiler and build-essentials for the compilation, LAMP (Apache, PHP, MySQL) for the Nagios web interface and Sendmail to send alerts from the server. &lt;br /&gt;
&lt;br /&gt;
To install all those packages, run the following command (it&#039;s just 1 line):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install wget build-essential apache2 php apache2-mod-php7.0 php-gd libgd-dev sendmail unzip&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Create Users and Groups===&lt;br /&gt;
&lt;br /&gt;
Create a user &#039;&#039;&#039;nagios&#039;&#039;&#039;, and a distinct group &#039;&#039;&#039;nagcmd&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Add &#039;&#039;&#039;nagios&#039;&#039;&#039; and the Apache user &#039;&#039;&#039;www-data&#039;&#039;&#039;, to the &#039;&#039;&#039;nagcmd&#039;&#039;&#039; group in order to run external commands on Nagios through the web interface&lt;br /&gt;
&lt;br /&gt;
Use the following command to create:&lt;br /&gt;
&lt;br /&gt;
To create user:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo useradd nagios&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To create group:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo groupadd nagcmd&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To add user to the group:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo usermod -a -G nagcmd nagios &amp;amp;&amp;amp; sudo usermod -a -G nagcmd www-data&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Installing Nagios =&lt;br /&gt;
&lt;br /&gt;
===Download and extract Nagios===&lt;br /&gt;
&lt;br /&gt;
In your web browser, go to the [https://www.nagios.org/downloads/core-stay-informed/ Nagios Core DIY download page].It will ask you to register, If you prefer not to register for updates, click Skip to download.&lt;br /&gt;
&lt;br /&gt;
Under Nagios Core, find the release that says Latest stable release under Notes, then copy the download link to your clipboard.&lt;br /&gt;
&lt;br /&gt;
Now using &amp;lt;code&amp;gt;wget&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;tar&amp;lt;/code&amp;gt;, download the Nagios and extract it.&lt;br /&gt;
&lt;br /&gt;
To download, paste the copied link after &amp;lt;code&amp;gt;wget&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.2.0.tar.gz &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Command to extract:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;tar -xzf nagios*.tar.gz&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now move to the newly created directory, by using the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;cd nagios-4.2.0&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Compile Nagios===&lt;br /&gt;
&lt;br /&gt;
Before you build Nagios, you will have to configure it with the user and the group you have created earlier.&lt;br /&gt;
&lt;br /&gt;
command to configure:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;./configure --with-nagios-group=nagios --with-command-group=nagcmd&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For more information please use: &amp;lt;code&amp;gt;./configure --help&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now compile Nagios with this command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;make all&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===To install Nagios===&lt;br /&gt;
&lt;br /&gt;
Now we can run these make commands to install &#039;&#039;&#039;Nagios&#039;&#039;&#039;, init scripts, and sample configuration files:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo make install &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo make install-commandmode &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo make install-init &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo make install-config &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; /usr/bin/install -c -m 644 sample-config/httpd.conf /etc/apache2/sites-available/nagios.conf &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And copy evenhandler directory to the nagios directory:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo cp -R contrib/eventhandlers/ /usr/local/nagios/libexec/ &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo chown -R nagios:nagios /usr/local/nagios/libexec/eventhandlers &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Nagios Plugins =&lt;br /&gt;
&lt;br /&gt;
Nagios Plugins allow you to monitor services like DHCP, FTP, HTTP and NTP.&lt;br /&gt;
&lt;br /&gt;
===Download and extract the Nagios plugins===&lt;br /&gt;
&lt;br /&gt;
To use Nagios Plugins, go to [https://nagios-plugins.org/downloads/ Nagios Plugins downloads] page and copy the download link for the current stable release.&lt;br /&gt;
&lt;br /&gt;
Now using &amp;lt;code&amp;gt;wget&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;tar&amp;lt;/code&amp;gt;, download and extract &#039;&#039;&#039;Nagios plugin&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Use the following command to move back into user&#039;s home directory:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;cd ~&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To download, paste the copied link after &amp;lt;code&amp;gt;wget&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;wget https://nagios-plugins.org/download/nagios-plugins-2.1.2.tar.gz&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Command to extract:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;tar -xzf nagios-plugins*.tar.gz&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now Change to the newly created directory by the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;cd nagios-plugins-2.1.2/&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Install Nagios plugins===&lt;br /&gt;
&lt;br /&gt;
Install the Nagios plugin&#039;s with the following commands:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;./configure --with-nagios-user=nagios --with-nagios-group=nagios --with-openssl&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo make install&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Configure Nagios =&lt;br /&gt;
&lt;br /&gt;
Now let&#039;s perform the initial Nagios configuration.&lt;br /&gt;
&lt;br /&gt;
===Organize Nagios Configuration===&lt;br /&gt;
&lt;br /&gt;
Open the main Nagios configuration file in your favorite text editor(vim/nano). &lt;br /&gt;
&lt;br /&gt;
We&#039;ll use nano to edit the file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo nano /usr/local/nagios/etc/nagios.cfg&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now find and uncomment the following line by deleting the #:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;#cfg_dir=/usr/local/nagios/etc/servers&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
Now create the directory named &#039;&#039;&#039;servers&#039;&#039;&#039; that will store the configuration file for each server that you will monitor:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo mkdir /usr/local/nagios/etc/servers&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Change the user and group for the new folder to nagios:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo chown nagios:nagios /usr/local/nagios/etc/servers&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Nagios3.png|thumb|right|Nagios Email]]&lt;br /&gt;
&lt;br /&gt;
===Configure Nagios Contacts===&lt;br /&gt;
&lt;br /&gt;
Open the Nagios contacts configuration in your favorite text editor(nano/vim).&lt;br /&gt;
&lt;br /&gt;
We&#039;ll use nano to edit the file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo nano /usr/local/nagios/etc/objects/contacts.cfg&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Find the email directive, and replace its value with your own email address&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
= Configuring Apache =&lt;br /&gt;
&lt;br /&gt;
===Enable Apache modules===&lt;br /&gt;
&lt;br /&gt;
Make sure Apache has &amp;lt;code&amp;gt;mod_rewrite&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;mod_cgi&amp;lt;/code&amp;gt; enabled&lt;br /&gt;
&lt;br /&gt;
Enable the Apache rewrite and cgi modules by the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo a2enmod rewrite &amp;amp;&amp;amp; sudo a2enmod cgi&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can use the &amp;lt;code&amp;gt;htpasswd&amp;lt;/code&amp;gt; command to configure a user &#039;&#039;nagiosadmin&#039;&#039; for the nagios web interface&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and type your password.&lt;br /&gt;
&lt;br /&gt;
===Enable the Nagios virtualhost===&lt;br /&gt;
&lt;br /&gt;
You can enable Nagios Virtualhost by the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo ln -s /etc/apache2/sites-available/nagios.conf /etc/apache2/sites-enabled/&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Start Apache and Nagios===&lt;br /&gt;
&lt;br /&gt;
Start the Apache and Nagios by the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo service apache2 restart&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo service nagios start&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When Nagios starts, you may see the following error :&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Starting nagios (via systemctl): nagios.serviceFailed&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
And you can fix it by:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;cd /etc/init.d/&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo cp /etc/init.d/skeleton /etc/init.d/nagios&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now edit the Nagios file by the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo nano /etc/init.d/nagios&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And add the following code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
DESC=&amp;quot;Nagios&amp;quot;&lt;br /&gt;
&lt;br /&gt;
NAME=nagios&lt;br /&gt;
&lt;br /&gt;
DAEMON=/usr/local/nagios/bin/$NAME&lt;br /&gt;
&lt;br /&gt;
DAEMON_ARGS=&amp;quot;-d /usr/local/nagios/etc/nagios.cfg&amp;quot;&lt;br /&gt;
&lt;br /&gt;
PIDFILE=/usr/local/nagios/var/$NAME.lock&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make it executable, restart apache2 and start Nagios:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo chmod +x /etc/init.d/nagios&lt;br /&gt;
&lt;br /&gt;
sudo service apache2 restart&lt;br /&gt;
&lt;br /&gt;
sudo servuce nagios start&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Testing the Nagios Server =&lt;br /&gt;
&lt;br /&gt;
Open your favorite web browser, and go to your Nagios server (substitute the IP address or hostname)&lt;br /&gt;
&lt;br /&gt;
(in my case: http://192.168.56.200/nagios).&lt;br /&gt;
&lt;br /&gt;
Because we configured Apache to use htpasswd, you must enter the login credentials that you created earlier.&lt;br /&gt;
&lt;br /&gt;
We used &amp;quot;nagiosadmin&amp;quot; as the username:&lt;br /&gt;
&lt;br /&gt;
[[File:Htpasswd_prompt.png|thumb|center|Nagios Authentication page]]&lt;br /&gt;
&lt;br /&gt;
After authenticating, you will be see the default Nagios home page: &lt;br /&gt;
&lt;br /&gt;
[[File:Nagios_adminpage.png|thumb|center|Nagios Homepage]]&lt;br /&gt;
&lt;br /&gt;
In the Homepage, click on the Hosts link, in the left navigation bar, to see which hosts Nagios is monitoring:&lt;br /&gt;
&lt;br /&gt;
[[File:Hosts_link.png|thumb|center|Nagios Hostpage]]&lt;br /&gt;
&lt;br /&gt;
As you can see, Nagios is monitoring only &amp;quot;localhost&amp;quot;, or itself.&lt;br /&gt;
&lt;br /&gt;
Let&#039;s monitor another host with Nagios!&lt;br /&gt;
&lt;br /&gt;
= Adding a Host to Monitor =&lt;br /&gt;
&lt;br /&gt;
In this section, you can see how to add a ubuntu host to Nagios server, so it will be monitored.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Note: Here replace the IP with your Nagios server IP and Ubuntu Host IP&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
In my case:&lt;br /&gt;
&lt;br /&gt;
Nagios Server IP : 192.168.56.200 &lt;br /&gt;
&lt;br /&gt;
Ubuntu Host IP : 192.168.56.100&lt;br /&gt;
&lt;br /&gt;
===Connect to ubuntu host===&lt;br /&gt;
&lt;br /&gt;
You can connect to Ubuntu host by using &#039;&#039;ssh&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you are not familiar with ssh use this [http://www.makeuseof.com/tag/beginners-guide-setting-ssh-linux-testing-setup/ Beginner’s Guide To Setting Up SSH On Linux]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;ssh student@192.168.56.100&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Install NRPE Service===&lt;br /&gt;
&lt;br /&gt;
Now install Nagios Plugins and NRPE by following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install nagios-nrpe-server nagios-plugins&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Configure NRPE===&lt;br /&gt;
&lt;br /&gt;
Now, let&#039;s update the NRPE configuration file.&lt;br /&gt;
&lt;br /&gt;
Open it in your favorite editor (we&#039;re using nano):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo nano /etc/nagios/nrpe.cfg&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Find the &#039;&#039;server_address&#039;&#039; directive, and add the private IP address of your Nagios server&lt;br /&gt;
&lt;br /&gt;
In my case:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;server_address=192.168.56.200&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
[[File:5.png|thumb|center|Configure NRPE]]&lt;br /&gt;
&lt;br /&gt;
===Restart NRPE===&lt;br /&gt;
&lt;br /&gt;
Restart NRPE by following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo service nagios-nrpe-server restart&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Add Ubuntu Host to Nagios Server===&lt;br /&gt;
&lt;br /&gt;
connect to the Nagios server:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;ssh student@192.168.56.200&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then create a new file for the host configuration in &#039;&#039;/usr/local/nagios/etc/servers/&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo nano /usr/local/nagios/etc/servers/ubuntu_host.cfg&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add the following lines:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Ubuntu Host configuration file&lt;br /&gt;
&lt;br /&gt;
define host {&lt;br /&gt;
        use                          linux-server&lt;br /&gt;
        host_name                    ubuntu_host&lt;br /&gt;
        alias                        Ubuntu Host&lt;br /&gt;
        address                      192.168.1.100&lt;br /&gt;
        register                     1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
define service {&lt;br /&gt;
      host_name                       ubuntu_host&lt;br /&gt;
      service_description             PING&lt;br /&gt;
      check_command                   check_ping!100.0,20%!500.0,60%&lt;br /&gt;
      max_check_attempts              2&lt;br /&gt;
      check_interval                  2&lt;br /&gt;
      retry_interval                  2&lt;br /&gt;
      check_period                    24x7&lt;br /&gt;
      check_freshness                 1&lt;br /&gt;
      contact_groups                  admins&lt;br /&gt;
      notification_interval           2&lt;br /&gt;
      notification_period             24x7&lt;br /&gt;
      notifications_enabled           1&lt;br /&gt;
      register                        1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
define service {&lt;br /&gt;
      host_name                       ubuntu_host&lt;br /&gt;
      service_description             Check Users&lt;br /&gt;
      check_command           check_local_users!20!50&lt;br /&gt;
      max_check_attempts              2&lt;br /&gt;
      check_interval                  2&lt;br /&gt;
      retry_interval                  2&lt;br /&gt;
      check_period                    24x7&lt;br /&gt;
      check_freshness                 1&lt;br /&gt;
      contact_groups                  admins&lt;br /&gt;
      notification_interval           2&lt;br /&gt;
      notification_period             24x7&lt;br /&gt;
      notifications_enabled           1&lt;br /&gt;
      register                        1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
define service {&lt;br /&gt;
      host_name                       ubuntu_host&lt;br /&gt;
      service_description             Local Disk&lt;br /&gt;
      check_command                   check_local_disk!20%!10%!/&lt;br /&gt;
      max_check_attempts              2&lt;br /&gt;
      check_interval                  2&lt;br /&gt;
      retry_interval                  2&lt;br /&gt;
      check_period                    24x7&lt;br /&gt;
      check_freshness                 1&lt;br /&gt;
      contact_groups                  admins&lt;br /&gt;
      notification_interval           2&lt;br /&gt;
      notification_period             24x7&lt;br /&gt;
      notifications_enabled           1&lt;br /&gt;
      register                        1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
define service {&lt;br /&gt;
      host_name                       ubuntu_host&lt;br /&gt;
      service_description             Check SSH&lt;br /&gt;
      check_command                   check_ssh&lt;br /&gt;
      max_check_attempts              2&lt;br /&gt;
      check_interval                  2&lt;br /&gt;
      retry_interval                  2&lt;br /&gt;
      check_period                    24x7&lt;br /&gt;
      check_freshness                 1&lt;br /&gt;
      contact_groups                  admins&lt;br /&gt;
      notification_interval           2&lt;br /&gt;
      notification_period             24x7&lt;br /&gt;
      notifications_enabled           1&lt;br /&gt;
      register                        1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
define service {&lt;br /&gt;
      host_name                       ubuntu_host&lt;br /&gt;
      service_description             Total Process&lt;br /&gt;
      check_command                   check_local_procs!250!400!RSZDT&lt;br /&gt;
      max_check_attempts              2&lt;br /&gt;
      check_interval                  2&lt;br /&gt;
      retry_interval                  2&lt;br /&gt;
      check_period                    24x7&lt;br /&gt;
      check_freshness                 1&lt;br /&gt;
      contact_groups                  admins&lt;br /&gt;
      notification_interval           2&lt;br /&gt;
      notification_period             24x7&lt;br /&gt;
      notifications_enabled           1&lt;br /&gt;
      register                        1&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can find many check_command in /usr/local/nagios/etc/objects/commands.cfg file. See there if you want to add more services like DHCP, POP etc.&lt;br /&gt;
&lt;br /&gt;
And now check the configuration:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
... to see if the configuration is correct.&lt;br /&gt;
&lt;br /&gt;
[[File:Nagios_check.png|thumb|center|Nagios check]]&lt;br /&gt;
&lt;br /&gt;
===Restart all services===&lt;br /&gt;
&lt;br /&gt;
On the Ubuntu Host start NRPE Service:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo service nagios-nrpe-server restart&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And on the Nagios server, start Apache and Nagios:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo service apache2 restart&lt;br /&gt;
&lt;br /&gt;
sudo service nagios restart&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Testing the Ubuntu Host =&lt;br /&gt;
&lt;br /&gt;
Open the Nagios server from the browser and see the ubuntu_host being monitored.&lt;br /&gt;
&lt;br /&gt;
The Ubuntu host is available on monitored host.&lt;br /&gt;
&lt;br /&gt;
[[File:Nagios.png|thumb|center|Nagios Testing Host]]&lt;br /&gt;
&lt;br /&gt;
All services monitored without error.&lt;br /&gt;
&lt;br /&gt;
[[File:Nagios ubuntu.png|thumb|center|Nagios Testing Host]]&lt;br /&gt;
&lt;br /&gt;
= Summary =&lt;br /&gt;
Nagios is an open application for systems monitoring. &lt;br /&gt;
It has several advantages, but main of them are:&lt;br /&gt;
*Easy to install and configure&lt;br /&gt;
*Easy to to use&lt;br /&gt;
*Supports extensions and plugins&lt;br /&gt;
&lt;br /&gt;
= Reference =&lt;br /&gt;
&lt;br /&gt;
1- [https://www.howtoforge.com/tutorial/ubuntu-nagios/ Nagios Installation]&lt;br /&gt;
&lt;br /&gt;
2- [https://www.linode.com/docs/uptime/monitoring/install-nagios-4-on-ubuntu-debian-8 Nagios tutorial]&lt;br /&gt;
&lt;br /&gt;
3- [https://www.digitalocean.com/community/tutorials/how-to-install-nagios-4-and-monitor-your-servers-on-ubuntu-14-04 Install Nagios and monitor your servers on ubuntu]&lt;br /&gt;
&lt;br /&gt;
4- [https://blog.serverdensity.com/howto-install-nagios-in-30-minutes-and-jumpstart-your-monitoring/ Nagios in 30 minutes and jumpstart your monitoring]&lt;br /&gt;
&lt;br /&gt;
5- [https://nagios-plugins.org/doc/guidelines.html Nagios Plugins]&lt;br /&gt;
&lt;br /&gt;
6- [http://www.monitance.com/en/product-news/what-is-server-monitoring-and-why-is-it-important/ Introduction Monitoring ]&lt;br /&gt;
&lt;br /&gt;
7- [https://www.nagios.org/about/overview/ Introduction Nagios ]&lt;br /&gt;
 &lt;br /&gt;
------&lt;br /&gt;
&lt;br /&gt;
[[Category:Monitoring]]&lt;/div&gt;</summary>
		<author><name>Ishustov</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Monitoring_Nagios&amp;diff=114757</id>
		<title>Monitoring Nagios</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Monitoring_Nagios&amp;diff=114757"/>
		<updated>2016-11-17T09:33:13Z</updated>

		<summary type="html">&lt;p&gt;Ishustov: /* Why monitoring is important? */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Team: &lt;br /&gt;
Ilja Shustov,&lt;br /&gt;
Sheela Raj &lt;br /&gt;
&lt;br /&gt;
Group : Cyber Security Engineering (C21)&lt;br /&gt;
&lt;br /&gt;
Page Created: 10 November 2016&lt;br /&gt;
&lt;br /&gt;
‎Last modified: 12 November 2016&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
In this article, we will cover the installation of &#039;&#039;&#039;Nagios&#039;&#039;&#039;, a very popular open source monitoring system, on Ubuntu. We will cover some basic configuration, so you will be able to monitor host resources via the web interface. We will also utilize the Nagios Remote Plugin Executor (NRPE), that will be installed as an agent on remote hosts, to monitor their local resources.&lt;br /&gt;
&lt;br /&gt;
===Monitoring===&lt;br /&gt;
&lt;br /&gt;
Server monitoring  is basically scanning of the servers and network for detection of any issues, but it also monitors for user load, security and speed, if we are talking about web servers monitoring.&lt;br /&gt;
&lt;br /&gt;
===Why monitoring is important?===&lt;br /&gt;
Monitoring is important because it helps to detect the problem and prevent servers to go down, because any network crashes costs not only money but also time, so monitoring will ensure service availability.&lt;br /&gt;
&lt;br /&gt;
===Nagios===&lt;br /&gt;
Nagios is an open source computer-software application that monitors systems, networks and infrastructure. Nagios offers monitoring and alerting services for servers, switches, applications and services. It alerts users when things go wrong and alerts them a second time when the problem has been resolved.&lt;br /&gt;
&lt;br /&gt;
By using Nagios, you can:&lt;br /&gt;
&lt;br /&gt;
*Plan for infrastructure upgrades before outdated systems cause failures&lt;br /&gt;
*Respond to issues at the first sign of a problem&lt;br /&gt;
*Automatically fix problems when they are detected&lt;br /&gt;
*Coordinate technical team responses&lt;br /&gt;
*Ensure your organization’s SLAs are being met&lt;br /&gt;
*Ensure IT infrastructure outages have a minimal effect on your organization’s bottom line&lt;br /&gt;
*Monitor your entire infrastructure and business processes&lt;br /&gt;
&lt;br /&gt;
= Before You Begin =&lt;br /&gt;
===Check your current Ubuntu version &amp;amp; Upgrade===&lt;br /&gt;
&lt;br /&gt;
You can check your current ubuntu version by the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;lsb_release -a&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If your machine is already running Ubuntu 16.04.1 LTS or higher than that, There is no need for you to upgrade the OS.&lt;br /&gt;
&lt;br /&gt;
Otherwise you need to upgrade the OS by the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get update &amp;amp;&amp;amp; sudo apt-get upgrade&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039;&lt;br /&gt;
This article is written for a non-root user. Commands that require elevated privileges are prefixed with &amp;lt;code&amp;gt;sudo&amp;lt;/code&amp;gt;. If you’re not familiar with the &amp;lt;code&amp;gt;sudo&amp;lt;/code&amp;gt; command, you can check the [https://www.linode.com/docs/tools-reference/linux-users-and-groups Users and Groups] guide.&lt;br /&gt;
&lt;br /&gt;
===Install the required package===&lt;br /&gt;
&lt;br /&gt;
As a prerequisite, Nagios requires the gcc compiler and build-essentials for the compilation, LAMP (Apache, PHP, MySQL) for the Nagios web interface and Sendmail to send alerts from the server. &lt;br /&gt;
&lt;br /&gt;
To install all those packages, run the following command (it&#039;s just 1 line):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install wget build-essential apache2 php apache2-mod-php7.0 php-gd libgd-dev sendmail unzip&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Create Users and Groups===&lt;br /&gt;
&lt;br /&gt;
Create a user &#039;&#039;&#039;nagios&#039;&#039;&#039;, and a distinct group &#039;&#039;&#039;nagcmd&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Add &#039;&#039;&#039;nagios&#039;&#039;&#039; and the Apache user &#039;&#039;&#039;www-data&#039;&#039;&#039;, to the &#039;&#039;&#039;nagcmd&#039;&#039;&#039; group in order to run external commands on Nagios through the web interface&lt;br /&gt;
&lt;br /&gt;
Use the following command to create:&lt;br /&gt;
&lt;br /&gt;
To create user:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo useradd nagios&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To create group:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo groupadd nagcmd&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To add user to the group:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo usermod -a -G nagcmd nagios &amp;amp;&amp;amp; sudo usermod -a -G nagcmd www-data&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Installing Nagios =&lt;br /&gt;
&lt;br /&gt;
===Download and extract Nagios===&lt;br /&gt;
&lt;br /&gt;
In your web browser, go to the [https://www.nagios.org/downloads/core-stay-informed/ Nagios Core DIY download page].It will ask you to register, If you prefer not to register for updates, click Skip to download.&lt;br /&gt;
&lt;br /&gt;
Under Nagios Core, find the release that says Latest stable release under Notes, then copy the download link to your clipboard.&lt;br /&gt;
&lt;br /&gt;
Now using &amp;lt;code&amp;gt;wget&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;tar&amp;lt;/code&amp;gt;, download the Nagios and extract it.&lt;br /&gt;
&lt;br /&gt;
To download, paste the copied link after &amp;lt;code&amp;gt;wget&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.2.0.tar.gz &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Command to extract:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;tar -xzf nagios*.tar.gz&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now move to the newly created directory, by using the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;cd nagios-4.2.0&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Compile Nagios===&lt;br /&gt;
&lt;br /&gt;
Before you build Nagios, you will have to configure it with the user and the group you have created earlier.&lt;br /&gt;
&lt;br /&gt;
command to configure:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;./configure --with-nagios-group=nagios --with-command-group=nagcmd&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For more information please use: &amp;lt;code&amp;gt;./configure --help&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now compile Nagios with this command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;make all&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===To install Nagios===&lt;br /&gt;
&lt;br /&gt;
Now we can run these make commands to install &#039;&#039;&#039;Nagios&#039;&#039;&#039;, init scripts, and sample configuration files:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo make install &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo make install-commandmode &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo make install-init &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo make install-config &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; /usr/bin/install -c -m 644 sample-config/httpd.conf /etc/apache2/sites-available/nagios.conf &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And copy evenhandler directory to the nagios directory:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo cp -R contrib/eventhandlers/ /usr/local/nagios/libexec/ &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo chown -R nagios:nagios /usr/local/nagios/libexec/eventhandlers &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Nagios Plugins =&lt;br /&gt;
&lt;br /&gt;
Nagios Plugins allow you to monitor services like DHCP, FTP, HTTP and NTP.&lt;br /&gt;
&lt;br /&gt;
===Download and extract the Nagios plugins===&lt;br /&gt;
&lt;br /&gt;
To use Nagios Plugins, go to [https://nagios-plugins.org/downloads/ Nagios Plugins downloads] page and copy the download link for the current stable release.&lt;br /&gt;
&lt;br /&gt;
Now using &amp;lt;code&amp;gt;wget&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;tar&amp;lt;/code&amp;gt;, download and extract &#039;&#039;&#039;Nagios plugin&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Use the following command to move back into user&#039;s home directory:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;cd ~&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To download, paste the copied link after &amp;lt;code&amp;gt;wget&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;wget https://nagios-plugins.org/download/nagios-plugins-2.1.2.tar.gz&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Command to extract:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;tar -xzf nagios-plugins*.tar.gz&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now Change to the newly created directory by the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;cd nagios-plugins-2.1.2/&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Install Nagios plugins===&lt;br /&gt;
&lt;br /&gt;
Install the Nagios plugin&#039;s with the following commands:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;./configure --with-nagios-user=nagios --with-nagios-group=nagios --with-openssl&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo make install&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Configure Nagios =&lt;br /&gt;
&lt;br /&gt;
Now let&#039;s perform the initial Nagios configuration.&lt;br /&gt;
&lt;br /&gt;
===Organize Nagios Configuration===&lt;br /&gt;
&lt;br /&gt;
Open the main Nagios configuration file in your favorite text editor(vim/nano). &lt;br /&gt;
&lt;br /&gt;
We&#039;ll use nano to edit the file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo nano /usr/local/nagios/etc/nagios.cfg&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now find and uncomment the following line by deleting the #:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;#cfg_dir=/usr/local/nagios/etc/servers&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
Now create the directory named &#039;&#039;&#039;servers&#039;&#039;&#039; that will store the configuration file for each server that you will monitor:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo mkdir /usr/local/nagios/etc/servers&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Change the user and group for the new folder to nagios:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo chown nagios:nagios /usr/local/nagios/etc/servers&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Nagios3.png|thumb|right|Nagios Email]]&lt;br /&gt;
&lt;br /&gt;
===Configure Nagios Contacts===&lt;br /&gt;
&lt;br /&gt;
Open the Nagios contacts configuration in your favorite text editor(nano/vim).&lt;br /&gt;
&lt;br /&gt;
We&#039;ll use nano to edit the file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo nano /usr/local/nagios/etc/objects/contacts.cfg&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Find the email directive, and replace its value with your own email address&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
= Configuring Apache =&lt;br /&gt;
&lt;br /&gt;
===Enable Apache modules===&lt;br /&gt;
&lt;br /&gt;
Make sure Apache has &amp;lt;code&amp;gt;mod_rewrite&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;mod_cgi&amp;lt;/code&amp;gt; enabled&lt;br /&gt;
&lt;br /&gt;
Enable the Apache rewrite and cgi modules by the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo a2enmod rewrite &amp;amp;&amp;amp; sudo a2enmod cgi&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can use the &amp;lt;code&amp;gt;htpasswd&amp;lt;/code&amp;gt; command to configure a user &#039;&#039;nagiosadmin&#039;&#039; for the nagios web interface&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and type your password.&lt;br /&gt;
&lt;br /&gt;
===Enable the Nagios virtualhost===&lt;br /&gt;
&lt;br /&gt;
You can enable Nagios Virtualhost by the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo ln -s /etc/apache2/sites-available/nagios.conf /etc/apache2/sites-enabled/&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Start Apache and Nagios===&lt;br /&gt;
&lt;br /&gt;
Start the Apache and Nagios by the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo service apache2 restart&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo service nagios start&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When Nagios starts, you may see the following error :&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Starting nagios (via systemctl): nagios.serviceFailed&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
And you can fix it by:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;cd /etc/init.d/&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo cp /etc/init.d/skeleton /etc/init.d/nagios&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now edit the Nagios file by the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo nano /etc/init.d/nagios&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And add the following code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
DESC=&amp;quot;Nagios&amp;quot;&lt;br /&gt;
&lt;br /&gt;
NAME=nagios&lt;br /&gt;
&lt;br /&gt;
DAEMON=/usr/local/nagios/bin/$NAME&lt;br /&gt;
&lt;br /&gt;
DAEMON_ARGS=&amp;quot;-d /usr/local/nagios/etc/nagios.cfg&amp;quot;&lt;br /&gt;
&lt;br /&gt;
PIDFILE=/usr/local/nagios/var/$NAME.lock&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make it executable, restart apache2 and start Nagios:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo chmod +x /etc/init.d/nagios&lt;br /&gt;
&lt;br /&gt;
sudo service apache2 restart&lt;br /&gt;
&lt;br /&gt;
sudo servuce nagios start&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Testing the Nagios Server =&lt;br /&gt;
&lt;br /&gt;
Open your favorite web browser, and go to your Nagios server (substitute the IP address or hostname)&lt;br /&gt;
&lt;br /&gt;
(in my case: http://192.168.56.200/nagios).&lt;br /&gt;
&lt;br /&gt;
Because we configured Apache to use htpasswd, you must enter the login credentials that you created earlier.&lt;br /&gt;
&lt;br /&gt;
We used &amp;quot;nagiosadmin&amp;quot; as the username:&lt;br /&gt;
&lt;br /&gt;
[[File:Htpasswd_prompt.png|thumb|center|Nagios Authentication page]]&lt;br /&gt;
&lt;br /&gt;
After authenticating, you will be see the default Nagios home page: &lt;br /&gt;
&lt;br /&gt;
[[File:Nagios_adminpage.png|thumb|center|Nagios Homepage]]&lt;br /&gt;
&lt;br /&gt;
In the Homepage, click on the Hosts link, in the left navigation bar, to see which hosts Nagios is monitoring:&lt;br /&gt;
&lt;br /&gt;
[[File:Hosts_link.png|thumb|center|Nagios Hostpage]]&lt;br /&gt;
&lt;br /&gt;
As you can see, Nagios is monitoring only &amp;quot;localhost&amp;quot;, or itself.&lt;br /&gt;
&lt;br /&gt;
Let&#039;s monitor another host with Nagios!&lt;br /&gt;
&lt;br /&gt;
= Adding a Host to Monitor =&lt;br /&gt;
&lt;br /&gt;
In this section, you can see how to add a ubuntu host to Nagios server, so it will be monitored.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Note: Here replace the IP with your Nagios server IP and Ubuntu Host IP&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
In my case:&lt;br /&gt;
&lt;br /&gt;
Nagios Server IP : 192.168.56.200 &lt;br /&gt;
&lt;br /&gt;
Ubuntu Host IP : 192.168.56.100&lt;br /&gt;
&lt;br /&gt;
===Connect to ubuntu host===&lt;br /&gt;
&lt;br /&gt;
You can connect to Ubuntu host by using &#039;&#039;ssh&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you are not familiar with ssh use this [http://www.makeuseof.com/tag/beginners-guide-setting-ssh-linux-testing-setup/ Beginner’s Guide To Setting Up SSH On Linux]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;ssh student@192.168.56.100&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Install NRPE Service===&lt;br /&gt;
&lt;br /&gt;
Now install Nagios Plugins and NRPE by following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install nagios-nrpe-server nagios-plugins&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Configure NRPE===&lt;br /&gt;
&lt;br /&gt;
Now, let&#039;s update the NRPE configuration file.&lt;br /&gt;
&lt;br /&gt;
Open it in your favorite editor (we&#039;re using nano):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo nano /etc/nagios/nrpe.cfg&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Find the &#039;&#039;server_address&#039;&#039; directive, and add the private IP address of your Nagios server&lt;br /&gt;
&lt;br /&gt;
In my case:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;server_address=192.168.56.200&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
[[File:5.png|thumb|center|Configure NRPE]]&lt;br /&gt;
&lt;br /&gt;
===Restart NRPE===&lt;br /&gt;
&lt;br /&gt;
Restart NRPE by following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo service nagios-nrpe-server restart&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Add Ubuntu Host to Nagios Server===&lt;br /&gt;
&lt;br /&gt;
connect to the Nagios server:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;ssh student@192.168.56.200&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then create a new file for the host configuration in &#039;&#039;/usr/local/nagios/etc/servers/&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo nano /usr/local/nagios/etc/servers/ubuntu_host.cfg&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add the following lines:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Ubuntu Host configuration file&lt;br /&gt;
&lt;br /&gt;
define host {&lt;br /&gt;
        use                          linux-server&lt;br /&gt;
        host_name                    ubuntu_host&lt;br /&gt;
        alias                        Ubuntu Host&lt;br /&gt;
        address                      192.168.1.100&lt;br /&gt;
        register                     1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
define service {&lt;br /&gt;
      host_name                       ubuntu_host&lt;br /&gt;
      service_description             PING&lt;br /&gt;
      check_command                   check_ping!100.0,20%!500.0,60%&lt;br /&gt;
      max_check_attempts              2&lt;br /&gt;
      check_interval                  2&lt;br /&gt;
      retry_interval                  2&lt;br /&gt;
      check_period                    24x7&lt;br /&gt;
      check_freshness                 1&lt;br /&gt;
      contact_groups                  admins&lt;br /&gt;
      notification_interval           2&lt;br /&gt;
      notification_period             24x7&lt;br /&gt;
      notifications_enabled           1&lt;br /&gt;
      register                        1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
define service {&lt;br /&gt;
      host_name                       ubuntu_host&lt;br /&gt;
      service_description             Check Users&lt;br /&gt;
      check_command           check_local_users!20!50&lt;br /&gt;
      max_check_attempts              2&lt;br /&gt;
      check_interval                  2&lt;br /&gt;
      retry_interval                  2&lt;br /&gt;
      check_period                    24x7&lt;br /&gt;
      check_freshness                 1&lt;br /&gt;
      contact_groups                  admins&lt;br /&gt;
      notification_interval           2&lt;br /&gt;
      notification_period             24x7&lt;br /&gt;
      notifications_enabled           1&lt;br /&gt;
      register                        1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
define service {&lt;br /&gt;
      host_name                       ubuntu_host&lt;br /&gt;
      service_description             Local Disk&lt;br /&gt;
      check_command                   check_local_disk!20%!10%!/&lt;br /&gt;
      max_check_attempts              2&lt;br /&gt;
      check_interval                  2&lt;br /&gt;
      retry_interval                  2&lt;br /&gt;
      check_period                    24x7&lt;br /&gt;
      check_freshness                 1&lt;br /&gt;
      contact_groups                  admins&lt;br /&gt;
      notification_interval           2&lt;br /&gt;
      notification_period             24x7&lt;br /&gt;
      notifications_enabled           1&lt;br /&gt;
      register                        1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
define service {&lt;br /&gt;
      host_name                       ubuntu_host&lt;br /&gt;
      service_description             Check SSH&lt;br /&gt;
      check_command                   check_ssh&lt;br /&gt;
      max_check_attempts              2&lt;br /&gt;
      check_interval                  2&lt;br /&gt;
      retry_interval                  2&lt;br /&gt;
      check_period                    24x7&lt;br /&gt;
      check_freshness                 1&lt;br /&gt;
      contact_groups                  admins&lt;br /&gt;
      notification_interval           2&lt;br /&gt;
      notification_period             24x7&lt;br /&gt;
      notifications_enabled           1&lt;br /&gt;
      register                        1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
define service {&lt;br /&gt;
      host_name                       ubuntu_host&lt;br /&gt;
      service_description             Total Process&lt;br /&gt;
      check_command                   check_local_procs!250!400!RSZDT&lt;br /&gt;
      max_check_attempts              2&lt;br /&gt;
      check_interval                  2&lt;br /&gt;
      retry_interval                  2&lt;br /&gt;
      check_period                    24x7&lt;br /&gt;
      check_freshness                 1&lt;br /&gt;
      contact_groups                  admins&lt;br /&gt;
      notification_interval           2&lt;br /&gt;
      notification_period             24x7&lt;br /&gt;
      notifications_enabled           1&lt;br /&gt;
      register                        1&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can find many check_command in /usr/local/nagios/etc/objects/commands.cfg file. See there if you want to add more services like DHCP, POP etc.&lt;br /&gt;
&lt;br /&gt;
And now check the configuration:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
... to see if the configuration is correct.&lt;br /&gt;
&lt;br /&gt;
[[File:Nagios_check.png|thumb|center|Nagios check]]&lt;br /&gt;
&lt;br /&gt;
===Restart all services===&lt;br /&gt;
&lt;br /&gt;
On the Ubuntu Host start NRPE Service:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo service nagios-nrpe-server restart&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And on the Nagios server, start Apache and Nagios:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo service apache2 restart&lt;br /&gt;
&lt;br /&gt;
sudo service nagios restart&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Testing the Ubuntu Host =&lt;br /&gt;
&lt;br /&gt;
Open the Nagios server from the browser and see the ubuntu_host being monitored.&lt;br /&gt;
&lt;br /&gt;
The Ubuntu host is available on monitored host.&lt;br /&gt;
&lt;br /&gt;
[[File:Nagios.png|thumb|center|Nagios Testing Host]]&lt;br /&gt;
&lt;br /&gt;
All services monitored without error.&lt;br /&gt;
&lt;br /&gt;
[[File:Nagios ubuntu.png|thumb|center|Nagios Testing Host]]&lt;br /&gt;
&lt;br /&gt;
= Summary =&lt;br /&gt;
Nagios is an open application for systems monitoring. &lt;br /&gt;
It has several advantages, but main of them are:&lt;br /&gt;
*Easy to install and configure&lt;br /&gt;
*Easy to to use&lt;br /&gt;
*Supports extensions and plugins&lt;br /&gt;
&lt;br /&gt;
= Reference =&lt;br /&gt;
&lt;br /&gt;
1- [https://www.howtoforge.com/tutorial/ubuntu-nagios/ Nagios Installation]&lt;br /&gt;
&lt;br /&gt;
2- [https://www.linode.com/docs/uptime/monitoring/install-nagios-4-on-ubuntu-debian-8 Nagios tutorial]&lt;br /&gt;
&lt;br /&gt;
3- [https://www.digitalocean.com/community/tutorials/how-to-install-nagios-4-and-monitor-your-servers-on-ubuntu-14-04 Install Nagios and monitor your servers on ubuntu]&lt;br /&gt;
&lt;br /&gt;
4- [https://blog.serverdensity.com/howto-install-nagios-in-30-minutes-and-jumpstart-your-monitoring/ Nagios in 30 minutes and jumpstart your monitoring]&lt;br /&gt;
&lt;br /&gt;
5- [https://nagios-plugins.org/doc/guidelines.html Nagios Plugins]&lt;br /&gt;
&lt;br /&gt;
6- [http://www.monitance.com/en/product-news/what-is-server-monitoring-and-why-is-it-important/ Introduction Monitoring ]&lt;br /&gt;
&lt;br /&gt;
7- [https://www.nagios.org/about/overview/ Introduction Nagios ]&lt;br /&gt;
 &lt;br /&gt;
------&lt;br /&gt;
&lt;br /&gt;
[[Category:Monitoring]]&lt;/div&gt;</summary>
		<author><name>Ishustov</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Monitoring_Nagios&amp;diff=114756</id>
		<title>Monitoring Nagios</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Monitoring_Nagios&amp;diff=114756"/>
		<updated>2016-11-17T09:25:10Z</updated>

		<summary type="html">&lt;p&gt;Ishustov: /* Monitoring */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Team: &lt;br /&gt;
Ilja Shustov,&lt;br /&gt;
Sheela Raj &lt;br /&gt;
&lt;br /&gt;
Group : Cyber Security Engineering (C21)&lt;br /&gt;
&lt;br /&gt;
Page Created: 10 November 2016&lt;br /&gt;
&lt;br /&gt;
‎Last modified: 12 November 2016&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
In this article, we will cover the installation of &#039;&#039;&#039;Nagios&#039;&#039;&#039;, a very popular open source monitoring system, on Ubuntu. We will cover some basic configuration, so you will be able to monitor host resources via the web interface. We will also utilize the Nagios Remote Plugin Executor (NRPE), that will be installed as an agent on remote hosts, to monitor their local resources.&lt;br /&gt;
&lt;br /&gt;
===Monitoring===&lt;br /&gt;
&lt;br /&gt;
Server monitoring  is basically scanning of the servers and network for detection of any issues, but it also monitors for user load, security and speed, if we are talking about web servers monitoring.&lt;br /&gt;
&lt;br /&gt;
===Why monitoring is important?===&lt;br /&gt;
Any network crashes costs time and money to fix.  At a time of downtime that is already costing your business money and hurting your reputation, it will be difficult to have to fork out more cash to get things back up and running again.  Server monitoring is important so that you can pick up any small issues before they evolve into anything major.  Server monitoring is essential in ensuring service availability.&lt;br /&gt;
&lt;br /&gt;
===Nagios===&lt;br /&gt;
Nagios is an open source computer-software application that monitors systems, networks and infrastructure. Nagios offers monitoring and alerting services for servers, switches, applications and services. It alerts users when things go wrong and alerts them a second time when the problem has been resolved.&lt;br /&gt;
&lt;br /&gt;
By using Nagios, you can:&lt;br /&gt;
&lt;br /&gt;
*Plan for infrastructure upgrades before outdated systems cause failures&lt;br /&gt;
*Respond to issues at the first sign of a problem&lt;br /&gt;
*Automatically fix problems when they are detected&lt;br /&gt;
*Coordinate technical team responses&lt;br /&gt;
*Ensure your organization’s SLAs are being met&lt;br /&gt;
*Ensure IT infrastructure outages have a minimal effect on your organization’s bottom line&lt;br /&gt;
*Monitor your entire infrastructure and business processes&lt;br /&gt;
&lt;br /&gt;
= Before You Begin =&lt;br /&gt;
===Check your current Ubuntu version &amp;amp; Upgrade===&lt;br /&gt;
&lt;br /&gt;
You can check your current ubuntu version by the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;lsb_release -a&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If your machine is already running Ubuntu 16.04.1 LTS or higher than that, There is no need for you to upgrade the OS.&lt;br /&gt;
&lt;br /&gt;
Otherwise you need to upgrade the OS by the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get update &amp;amp;&amp;amp; sudo apt-get upgrade&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039;&lt;br /&gt;
This article is written for a non-root user. Commands that require elevated privileges are prefixed with &amp;lt;code&amp;gt;sudo&amp;lt;/code&amp;gt;. If you’re not familiar with the &amp;lt;code&amp;gt;sudo&amp;lt;/code&amp;gt; command, you can check the [https://www.linode.com/docs/tools-reference/linux-users-and-groups Users and Groups] guide.&lt;br /&gt;
&lt;br /&gt;
===Install the required package===&lt;br /&gt;
&lt;br /&gt;
As a prerequisite, Nagios requires the gcc compiler and build-essentials for the compilation, LAMP (Apache, PHP, MySQL) for the Nagios web interface and Sendmail to send alerts from the server. &lt;br /&gt;
&lt;br /&gt;
To install all those packages, run the following command (it&#039;s just 1 line):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install wget build-essential apache2 php apache2-mod-php7.0 php-gd libgd-dev sendmail unzip&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Create Users and Groups===&lt;br /&gt;
&lt;br /&gt;
Create a user &#039;&#039;&#039;nagios&#039;&#039;&#039;, and a distinct group &#039;&#039;&#039;nagcmd&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Add &#039;&#039;&#039;nagios&#039;&#039;&#039; and the Apache user &#039;&#039;&#039;www-data&#039;&#039;&#039;, to the &#039;&#039;&#039;nagcmd&#039;&#039;&#039; group in order to run external commands on Nagios through the web interface&lt;br /&gt;
&lt;br /&gt;
Use the following command to create:&lt;br /&gt;
&lt;br /&gt;
To create user:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo useradd nagios&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To create group:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo groupadd nagcmd&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To add user to the group:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo usermod -a -G nagcmd nagios &amp;amp;&amp;amp; sudo usermod -a -G nagcmd www-data&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Installing Nagios =&lt;br /&gt;
&lt;br /&gt;
===Download and extract Nagios===&lt;br /&gt;
&lt;br /&gt;
In your web browser, go to the [https://www.nagios.org/downloads/core-stay-informed/ Nagios Core DIY download page].It will ask you to register, If you prefer not to register for updates, click Skip to download.&lt;br /&gt;
&lt;br /&gt;
Under Nagios Core, find the release that says Latest stable release under Notes, then copy the download link to your clipboard.&lt;br /&gt;
&lt;br /&gt;
Now using &amp;lt;code&amp;gt;wget&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;tar&amp;lt;/code&amp;gt;, download the Nagios and extract it.&lt;br /&gt;
&lt;br /&gt;
To download, paste the copied link after &amp;lt;code&amp;gt;wget&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.2.0.tar.gz &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Command to extract:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;tar -xzf nagios*.tar.gz&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now move to the newly created directory, by using the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;cd nagios-4.2.0&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Compile Nagios===&lt;br /&gt;
&lt;br /&gt;
Before you build Nagios, you will have to configure it with the user and the group you have created earlier.&lt;br /&gt;
&lt;br /&gt;
command to configure:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;./configure --with-nagios-group=nagios --with-command-group=nagcmd&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For more information please use: &amp;lt;code&amp;gt;./configure --help&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now compile Nagios with this command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;make all&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===To install Nagios===&lt;br /&gt;
&lt;br /&gt;
Now we can run these make commands to install &#039;&#039;&#039;Nagios&#039;&#039;&#039;, init scripts, and sample configuration files:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo make install &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo make install-commandmode &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo make install-init &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo make install-config &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; /usr/bin/install -c -m 644 sample-config/httpd.conf /etc/apache2/sites-available/nagios.conf &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And copy evenhandler directory to the nagios directory:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo cp -R contrib/eventhandlers/ /usr/local/nagios/libexec/ &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo chown -R nagios:nagios /usr/local/nagios/libexec/eventhandlers &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Nagios Plugins =&lt;br /&gt;
&lt;br /&gt;
Nagios Plugins allow you to monitor services like DHCP, FTP, HTTP and NTP.&lt;br /&gt;
&lt;br /&gt;
===Download and extract the Nagios plugins===&lt;br /&gt;
&lt;br /&gt;
To use Nagios Plugins, go to [https://nagios-plugins.org/downloads/ Nagios Plugins downloads] page and copy the download link for the current stable release.&lt;br /&gt;
&lt;br /&gt;
Now using &amp;lt;code&amp;gt;wget&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;tar&amp;lt;/code&amp;gt;, download and extract &#039;&#039;&#039;Nagios plugin&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Use the following command to move back into user&#039;s home directory:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;cd ~&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To download, paste the copied link after &amp;lt;code&amp;gt;wget&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;wget https://nagios-plugins.org/download/nagios-plugins-2.1.2.tar.gz&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Command to extract:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;tar -xzf nagios-plugins*.tar.gz&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now Change to the newly created directory by the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;cd nagios-plugins-2.1.2/&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Install Nagios plugins===&lt;br /&gt;
&lt;br /&gt;
Install the Nagios plugin&#039;s with the following commands:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;./configure --with-nagios-user=nagios --with-nagios-group=nagios --with-openssl&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo make install&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Configure Nagios =&lt;br /&gt;
&lt;br /&gt;
Now let&#039;s perform the initial Nagios configuration.&lt;br /&gt;
&lt;br /&gt;
===Organize Nagios Configuration===&lt;br /&gt;
&lt;br /&gt;
Open the main Nagios configuration file in your favorite text editor(vim/nano). &lt;br /&gt;
&lt;br /&gt;
We&#039;ll use nano to edit the file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo nano /usr/local/nagios/etc/nagios.cfg&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now find and uncomment the following line by deleting the #:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;#cfg_dir=/usr/local/nagios/etc/servers&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
Now create the directory named &#039;&#039;&#039;servers&#039;&#039;&#039; that will store the configuration file for each server that you will monitor:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo mkdir /usr/local/nagios/etc/servers&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Change the user and group for the new folder to nagios:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo chown nagios:nagios /usr/local/nagios/etc/servers&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Nagios3.png|thumb|right|Nagios Email]]&lt;br /&gt;
&lt;br /&gt;
===Configure Nagios Contacts===&lt;br /&gt;
&lt;br /&gt;
Open the Nagios contacts configuration in your favorite text editor(nano/vim).&lt;br /&gt;
&lt;br /&gt;
We&#039;ll use nano to edit the file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo nano /usr/local/nagios/etc/objects/contacts.cfg&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Find the email directive, and replace its value with your own email address&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
= Configuring Apache =&lt;br /&gt;
&lt;br /&gt;
===Enable Apache modules===&lt;br /&gt;
&lt;br /&gt;
Make sure Apache has &amp;lt;code&amp;gt;mod_rewrite&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;mod_cgi&amp;lt;/code&amp;gt; enabled&lt;br /&gt;
&lt;br /&gt;
Enable the Apache rewrite and cgi modules by the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo a2enmod rewrite &amp;amp;&amp;amp; sudo a2enmod cgi&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can use the &amp;lt;code&amp;gt;htpasswd&amp;lt;/code&amp;gt; command to configure a user &#039;&#039;nagiosadmin&#039;&#039; for the nagios web interface&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and type your password.&lt;br /&gt;
&lt;br /&gt;
===Enable the Nagios virtualhost===&lt;br /&gt;
&lt;br /&gt;
You can enable Nagios Virtualhost by the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo ln -s /etc/apache2/sites-available/nagios.conf /etc/apache2/sites-enabled/&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Start Apache and Nagios===&lt;br /&gt;
&lt;br /&gt;
Start the Apache and Nagios by the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo service apache2 restart&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo service nagios start&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When Nagios starts, you may see the following error :&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Starting nagios (via systemctl): nagios.serviceFailed&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
And you can fix it by:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;cd /etc/init.d/&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo cp /etc/init.d/skeleton /etc/init.d/nagios&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now edit the Nagios file by the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo nano /etc/init.d/nagios&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And add the following code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
DESC=&amp;quot;Nagios&amp;quot;&lt;br /&gt;
&lt;br /&gt;
NAME=nagios&lt;br /&gt;
&lt;br /&gt;
DAEMON=/usr/local/nagios/bin/$NAME&lt;br /&gt;
&lt;br /&gt;
DAEMON_ARGS=&amp;quot;-d /usr/local/nagios/etc/nagios.cfg&amp;quot;&lt;br /&gt;
&lt;br /&gt;
PIDFILE=/usr/local/nagios/var/$NAME.lock&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make it executable, restart apache2 and start Nagios:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo chmod +x /etc/init.d/nagios&lt;br /&gt;
&lt;br /&gt;
sudo service apache2 restart&lt;br /&gt;
&lt;br /&gt;
sudo servuce nagios start&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Testing the Nagios Server =&lt;br /&gt;
&lt;br /&gt;
Open your favorite web browser, and go to your Nagios server (substitute the IP address or hostname)&lt;br /&gt;
&lt;br /&gt;
(in my case: http://192.168.56.200/nagios).&lt;br /&gt;
&lt;br /&gt;
Because we configured Apache to use htpasswd, you must enter the login credentials that you created earlier.&lt;br /&gt;
&lt;br /&gt;
We used &amp;quot;nagiosadmin&amp;quot; as the username:&lt;br /&gt;
&lt;br /&gt;
[[File:Htpasswd_prompt.png|thumb|center|Nagios Authentication page]]&lt;br /&gt;
&lt;br /&gt;
After authenticating, you will be see the default Nagios home page: &lt;br /&gt;
&lt;br /&gt;
[[File:Nagios_adminpage.png|thumb|center|Nagios Homepage]]&lt;br /&gt;
&lt;br /&gt;
In the Homepage, click on the Hosts link, in the left navigation bar, to see which hosts Nagios is monitoring:&lt;br /&gt;
&lt;br /&gt;
[[File:Hosts_link.png|thumb|center|Nagios Hostpage]]&lt;br /&gt;
&lt;br /&gt;
As you can see, Nagios is monitoring only &amp;quot;localhost&amp;quot;, or itself.&lt;br /&gt;
&lt;br /&gt;
Let&#039;s monitor another host with Nagios!&lt;br /&gt;
&lt;br /&gt;
= Adding a Host to Monitor =&lt;br /&gt;
&lt;br /&gt;
In this section, you can see how to add a ubuntu host to Nagios server, so it will be monitored.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Note: Here replace the IP with your Nagios server IP and Ubuntu Host IP&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
In my case:&lt;br /&gt;
&lt;br /&gt;
Nagios Server IP : 192.168.56.200 &lt;br /&gt;
&lt;br /&gt;
Ubuntu Host IP : 192.168.56.100&lt;br /&gt;
&lt;br /&gt;
===Connect to ubuntu host===&lt;br /&gt;
&lt;br /&gt;
You can connect to Ubuntu host by using &#039;&#039;ssh&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you are not familiar with ssh use this [http://www.makeuseof.com/tag/beginners-guide-setting-ssh-linux-testing-setup/ Beginner’s Guide To Setting Up SSH On Linux]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;ssh student@192.168.56.100&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Install NRPE Service===&lt;br /&gt;
&lt;br /&gt;
Now install Nagios Plugins and NRPE by following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install nagios-nrpe-server nagios-plugins&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Configure NRPE===&lt;br /&gt;
&lt;br /&gt;
Now, let&#039;s update the NRPE configuration file.&lt;br /&gt;
&lt;br /&gt;
Open it in your favorite editor (we&#039;re using nano):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo nano /etc/nagios/nrpe.cfg&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Find the &#039;&#039;server_address&#039;&#039; directive, and add the private IP address of your Nagios server&lt;br /&gt;
&lt;br /&gt;
In my case:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;server_address=192.168.56.200&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
[[File:5.png|thumb|center|Configure NRPE]]&lt;br /&gt;
&lt;br /&gt;
===Restart NRPE===&lt;br /&gt;
&lt;br /&gt;
Restart NRPE by following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo service nagios-nrpe-server restart&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Add Ubuntu Host to Nagios Server===&lt;br /&gt;
&lt;br /&gt;
connect to the Nagios server:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;ssh student@192.168.56.200&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then create a new file for the host configuration in &#039;&#039;/usr/local/nagios/etc/servers/&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo nano /usr/local/nagios/etc/servers/ubuntu_host.cfg&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add the following lines:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Ubuntu Host configuration file&lt;br /&gt;
&lt;br /&gt;
define host {&lt;br /&gt;
        use                          linux-server&lt;br /&gt;
        host_name                    ubuntu_host&lt;br /&gt;
        alias                        Ubuntu Host&lt;br /&gt;
        address                      192.168.1.100&lt;br /&gt;
        register                     1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
define service {&lt;br /&gt;
      host_name                       ubuntu_host&lt;br /&gt;
      service_description             PING&lt;br /&gt;
      check_command                   check_ping!100.0,20%!500.0,60%&lt;br /&gt;
      max_check_attempts              2&lt;br /&gt;
      check_interval                  2&lt;br /&gt;
      retry_interval                  2&lt;br /&gt;
      check_period                    24x7&lt;br /&gt;
      check_freshness                 1&lt;br /&gt;
      contact_groups                  admins&lt;br /&gt;
      notification_interval           2&lt;br /&gt;
      notification_period             24x7&lt;br /&gt;
      notifications_enabled           1&lt;br /&gt;
      register                        1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
define service {&lt;br /&gt;
      host_name                       ubuntu_host&lt;br /&gt;
      service_description             Check Users&lt;br /&gt;
      check_command           check_local_users!20!50&lt;br /&gt;
      max_check_attempts              2&lt;br /&gt;
      check_interval                  2&lt;br /&gt;
      retry_interval                  2&lt;br /&gt;
      check_period                    24x7&lt;br /&gt;
      check_freshness                 1&lt;br /&gt;
      contact_groups                  admins&lt;br /&gt;
      notification_interval           2&lt;br /&gt;
      notification_period             24x7&lt;br /&gt;
      notifications_enabled           1&lt;br /&gt;
      register                        1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
define service {&lt;br /&gt;
      host_name                       ubuntu_host&lt;br /&gt;
      service_description             Local Disk&lt;br /&gt;
      check_command                   check_local_disk!20%!10%!/&lt;br /&gt;
      max_check_attempts              2&lt;br /&gt;
      check_interval                  2&lt;br /&gt;
      retry_interval                  2&lt;br /&gt;
      check_period                    24x7&lt;br /&gt;
      check_freshness                 1&lt;br /&gt;
      contact_groups                  admins&lt;br /&gt;
      notification_interval           2&lt;br /&gt;
      notification_period             24x7&lt;br /&gt;
      notifications_enabled           1&lt;br /&gt;
      register                        1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
define service {&lt;br /&gt;
      host_name                       ubuntu_host&lt;br /&gt;
      service_description             Check SSH&lt;br /&gt;
      check_command                   check_ssh&lt;br /&gt;
      max_check_attempts              2&lt;br /&gt;
      check_interval                  2&lt;br /&gt;
      retry_interval                  2&lt;br /&gt;
      check_period                    24x7&lt;br /&gt;
      check_freshness                 1&lt;br /&gt;
      contact_groups                  admins&lt;br /&gt;
      notification_interval           2&lt;br /&gt;
      notification_period             24x7&lt;br /&gt;
      notifications_enabled           1&lt;br /&gt;
      register                        1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
define service {&lt;br /&gt;
      host_name                       ubuntu_host&lt;br /&gt;
      service_description             Total Process&lt;br /&gt;
      check_command                   check_local_procs!250!400!RSZDT&lt;br /&gt;
      max_check_attempts              2&lt;br /&gt;
      check_interval                  2&lt;br /&gt;
      retry_interval                  2&lt;br /&gt;
      check_period                    24x7&lt;br /&gt;
      check_freshness                 1&lt;br /&gt;
      contact_groups                  admins&lt;br /&gt;
      notification_interval           2&lt;br /&gt;
      notification_period             24x7&lt;br /&gt;
      notifications_enabled           1&lt;br /&gt;
      register                        1&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can find many check_command in /usr/local/nagios/etc/objects/commands.cfg file. See there if you want to add more services like DHCP, POP etc.&lt;br /&gt;
&lt;br /&gt;
And now check the configuration:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
... to see if the configuration is correct.&lt;br /&gt;
&lt;br /&gt;
[[File:Nagios_check.png|thumb|center|Nagios check]]&lt;br /&gt;
&lt;br /&gt;
===Restart all services===&lt;br /&gt;
&lt;br /&gt;
On the Ubuntu Host start NRPE Service:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo service nagios-nrpe-server restart&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And on the Nagios server, start Apache and Nagios:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo service apache2 restart&lt;br /&gt;
&lt;br /&gt;
sudo service nagios restart&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Testing the Ubuntu Host =&lt;br /&gt;
&lt;br /&gt;
Open the Nagios server from the browser and see the ubuntu_host being monitored.&lt;br /&gt;
&lt;br /&gt;
The Ubuntu host is available on monitored host.&lt;br /&gt;
&lt;br /&gt;
[[File:Nagios.png|thumb|center|Nagios Testing Host]]&lt;br /&gt;
&lt;br /&gt;
All services monitored without error.&lt;br /&gt;
&lt;br /&gt;
[[File:Nagios ubuntu.png|thumb|center|Nagios Testing Host]]&lt;br /&gt;
&lt;br /&gt;
= Summary =&lt;br /&gt;
Nagios is an open application for systems monitoring. &lt;br /&gt;
It has several advantages, but main of them are:&lt;br /&gt;
*Easy to install and configure&lt;br /&gt;
*Easy to to use&lt;br /&gt;
*Supports extensions and plugins&lt;br /&gt;
&lt;br /&gt;
= Reference =&lt;br /&gt;
&lt;br /&gt;
1- [https://www.howtoforge.com/tutorial/ubuntu-nagios/ Nagios Installation]&lt;br /&gt;
&lt;br /&gt;
2- [https://www.linode.com/docs/uptime/monitoring/install-nagios-4-on-ubuntu-debian-8 Nagios tutorial]&lt;br /&gt;
&lt;br /&gt;
3- [https://www.digitalocean.com/community/tutorials/how-to-install-nagios-4-and-monitor-your-servers-on-ubuntu-14-04 Install Nagios and monitor your servers on ubuntu]&lt;br /&gt;
&lt;br /&gt;
4- [https://blog.serverdensity.com/howto-install-nagios-in-30-minutes-and-jumpstart-your-monitoring/ Nagios in 30 minutes and jumpstart your monitoring]&lt;br /&gt;
&lt;br /&gt;
5- [https://nagios-plugins.org/doc/guidelines.html Nagios Plugins]&lt;br /&gt;
&lt;br /&gt;
6- [http://www.monitance.com/en/product-news/what-is-server-monitoring-and-why-is-it-important/ Introduction Monitoring ]&lt;br /&gt;
&lt;br /&gt;
7- [https://www.nagios.org/about/overview/ Introduction Nagios ]&lt;br /&gt;
 &lt;br /&gt;
------&lt;br /&gt;
&lt;br /&gt;
[[Category:Monitoring]]&lt;/div&gt;</summary>
		<author><name>Ishustov</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Monitoring_Nagios&amp;diff=114755</id>
		<title>Monitoring Nagios</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Monitoring_Nagios&amp;diff=114755"/>
		<updated>2016-11-17T09:14:10Z</updated>

		<summary type="html">&lt;p&gt;Ishustov: /* Add Ubuntu Host to Nagios Server */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Team: &lt;br /&gt;
Ilja Shustov,&lt;br /&gt;
Sheela Raj &lt;br /&gt;
&lt;br /&gt;
Group : Cyber Security Engineering (C21)&lt;br /&gt;
&lt;br /&gt;
Page Created: 10 November 2016&lt;br /&gt;
&lt;br /&gt;
‎Last modified: 12 November 2016&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
In this article, we will cover the installation of &#039;&#039;&#039;Nagios&#039;&#039;&#039;, a very popular open source monitoring system, on Ubuntu. We will cover some basic configuration, so you will be able to monitor host resources via the web interface. We will also utilize the Nagios Remote Plugin Executor (NRPE), that will be installed as an agent on remote hosts, to monitor their local resources.&lt;br /&gt;
&lt;br /&gt;
===Monitoring===&lt;br /&gt;
&lt;br /&gt;
Server monitoring is basically a preventative measure to help you detect any issues before they cause any major issues that affect your productivity and your customer.&lt;br /&gt;
&lt;br /&gt;
Server monitoring is a process of continuously scanning servers on a designated network and scans the network for any failures or any irregularities that are detected by server monitoring software.&lt;br /&gt;
&lt;br /&gt;
===Why monitoring is important?===&lt;br /&gt;
Any network crashes costs time and money to fix.  At a time of downtime that is already costing your business money and hurting your reputation, it will be difficult to have to fork out more cash to get things back up and running again.  Server monitoring is important so that you can pick up any small issues before they evolve into anything major.  Server monitoring is essential in ensuring service availability.&lt;br /&gt;
&lt;br /&gt;
===Nagios===&lt;br /&gt;
Nagios is an open source computer-software application that monitors systems, networks and infrastructure. Nagios offers monitoring and alerting services for servers, switches, applications and services. It alerts users when things go wrong and alerts them a second time when the problem has been resolved.&lt;br /&gt;
&lt;br /&gt;
By using Nagios, you can:&lt;br /&gt;
&lt;br /&gt;
*Plan for infrastructure upgrades before outdated systems cause failures&lt;br /&gt;
*Respond to issues at the first sign of a problem&lt;br /&gt;
*Automatically fix problems when they are detected&lt;br /&gt;
*Coordinate technical team responses&lt;br /&gt;
*Ensure your organization’s SLAs are being met&lt;br /&gt;
*Ensure IT infrastructure outages have a minimal effect on your organization’s bottom line&lt;br /&gt;
*Monitor your entire infrastructure and business processes&lt;br /&gt;
&lt;br /&gt;
= Before You Begin =&lt;br /&gt;
===Check your current Ubuntu version &amp;amp; Upgrade===&lt;br /&gt;
&lt;br /&gt;
You can check your current ubuntu version by the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;lsb_release -a&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If your machine is already running Ubuntu 16.04.1 LTS or higher than that, There is no need for you to upgrade the OS.&lt;br /&gt;
&lt;br /&gt;
Otherwise you need to upgrade the OS by the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get update &amp;amp;&amp;amp; sudo apt-get upgrade&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039;&lt;br /&gt;
This article is written for a non-root user. Commands that require elevated privileges are prefixed with &amp;lt;code&amp;gt;sudo&amp;lt;/code&amp;gt;. If you’re not familiar with the &amp;lt;code&amp;gt;sudo&amp;lt;/code&amp;gt; command, you can check the [https://www.linode.com/docs/tools-reference/linux-users-and-groups Users and Groups] guide.&lt;br /&gt;
&lt;br /&gt;
===Install the required package===&lt;br /&gt;
&lt;br /&gt;
As a prerequisite, Nagios requires the gcc compiler and build-essentials for the compilation, LAMP (Apache, PHP, MySQL) for the Nagios web interface and Sendmail to send alerts from the server. &lt;br /&gt;
&lt;br /&gt;
To install all those packages, run the following command (it&#039;s just 1 line):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install wget build-essential apache2 php apache2-mod-php7.0 php-gd libgd-dev sendmail unzip&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Create Users and Groups===&lt;br /&gt;
&lt;br /&gt;
Create a user &#039;&#039;&#039;nagios&#039;&#039;&#039;, and a distinct group &#039;&#039;&#039;nagcmd&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Add &#039;&#039;&#039;nagios&#039;&#039;&#039; and the Apache user &#039;&#039;&#039;www-data&#039;&#039;&#039;, to the &#039;&#039;&#039;nagcmd&#039;&#039;&#039; group in order to run external commands on Nagios through the web interface&lt;br /&gt;
&lt;br /&gt;
Use the following command to create:&lt;br /&gt;
&lt;br /&gt;
To create user:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo useradd nagios&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To create group:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo groupadd nagcmd&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To add user to the group:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo usermod -a -G nagcmd nagios &amp;amp;&amp;amp; sudo usermod -a -G nagcmd www-data&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Installing Nagios =&lt;br /&gt;
&lt;br /&gt;
===Download and extract Nagios===&lt;br /&gt;
&lt;br /&gt;
In your web browser, go to the [https://www.nagios.org/downloads/core-stay-informed/ Nagios Core DIY download page].It will ask you to register, If you prefer not to register for updates, click Skip to download.&lt;br /&gt;
&lt;br /&gt;
Under Nagios Core, find the release that says Latest stable release under Notes, then copy the download link to your clipboard.&lt;br /&gt;
&lt;br /&gt;
Now using &amp;lt;code&amp;gt;wget&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;tar&amp;lt;/code&amp;gt;, download the Nagios and extract it.&lt;br /&gt;
&lt;br /&gt;
To download, paste the copied link after &amp;lt;code&amp;gt;wget&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.2.0.tar.gz &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Command to extract:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;tar -xzf nagios*.tar.gz&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now move to the newly created directory, by using the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;cd nagios-4.2.0&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Compile Nagios===&lt;br /&gt;
&lt;br /&gt;
Before you build Nagios, you will have to configure it with the user and the group you have created earlier.&lt;br /&gt;
&lt;br /&gt;
command to configure:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;./configure --with-nagios-group=nagios --with-command-group=nagcmd&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For more information please use: &amp;lt;code&amp;gt;./configure --help&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now compile Nagios with this command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;make all&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===To install Nagios===&lt;br /&gt;
&lt;br /&gt;
Now we can run these make commands to install &#039;&#039;&#039;Nagios&#039;&#039;&#039;, init scripts, and sample configuration files:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo make install &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo make install-commandmode &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo make install-init &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo make install-config &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; /usr/bin/install -c -m 644 sample-config/httpd.conf /etc/apache2/sites-available/nagios.conf &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And copy evenhandler directory to the nagios directory:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo cp -R contrib/eventhandlers/ /usr/local/nagios/libexec/ &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo chown -R nagios:nagios /usr/local/nagios/libexec/eventhandlers &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Nagios Plugins =&lt;br /&gt;
&lt;br /&gt;
Nagios Plugins allow you to monitor services like DHCP, FTP, HTTP and NTP.&lt;br /&gt;
&lt;br /&gt;
===Download and extract the Nagios plugins===&lt;br /&gt;
&lt;br /&gt;
To use Nagios Plugins, go to [https://nagios-plugins.org/downloads/ Nagios Plugins downloads] page and copy the download link for the current stable release.&lt;br /&gt;
&lt;br /&gt;
Now using &amp;lt;code&amp;gt;wget&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;tar&amp;lt;/code&amp;gt;, download and extract &#039;&#039;&#039;Nagios plugin&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Use the following command to move back into user&#039;s home directory:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;cd ~&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To download, paste the copied link after &amp;lt;code&amp;gt;wget&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;wget https://nagios-plugins.org/download/nagios-plugins-2.1.2.tar.gz&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Command to extract:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;tar -xzf nagios-plugins*.tar.gz&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now Change to the newly created directory by the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;cd nagios-plugins-2.1.2/&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Install Nagios plugins===&lt;br /&gt;
&lt;br /&gt;
Install the Nagios plugin&#039;s with the following commands:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;./configure --with-nagios-user=nagios --with-nagios-group=nagios --with-openssl&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo make install&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Configure Nagios =&lt;br /&gt;
&lt;br /&gt;
Now let&#039;s perform the initial Nagios configuration.&lt;br /&gt;
&lt;br /&gt;
===Organize Nagios Configuration===&lt;br /&gt;
&lt;br /&gt;
Open the main Nagios configuration file in your favorite text editor(vim/nano). &lt;br /&gt;
&lt;br /&gt;
We&#039;ll use nano to edit the file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo nano /usr/local/nagios/etc/nagios.cfg&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now find and uncomment the following line by deleting the #:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;#cfg_dir=/usr/local/nagios/etc/servers&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
Now create the directory named &#039;&#039;&#039;servers&#039;&#039;&#039; that will store the configuration file for each server that you will monitor:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo mkdir /usr/local/nagios/etc/servers&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Change the user and group for the new folder to nagios:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo chown nagios:nagios /usr/local/nagios/etc/servers&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Nagios3.png|thumb|right|Nagios Email]]&lt;br /&gt;
&lt;br /&gt;
===Configure Nagios Contacts===&lt;br /&gt;
&lt;br /&gt;
Open the Nagios contacts configuration in your favorite text editor(nano/vim).&lt;br /&gt;
&lt;br /&gt;
We&#039;ll use nano to edit the file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo nano /usr/local/nagios/etc/objects/contacts.cfg&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Find the email directive, and replace its value with your own email address&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
= Configuring Apache =&lt;br /&gt;
&lt;br /&gt;
===Enable Apache modules===&lt;br /&gt;
&lt;br /&gt;
Make sure Apache has &amp;lt;code&amp;gt;mod_rewrite&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;mod_cgi&amp;lt;/code&amp;gt; enabled&lt;br /&gt;
&lt;br /&gt;
Enable the Apache rewrite and cgi modules by the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo a2enmod rewrite &amp;amp;&amp;amp; sudo a2enmod cgi&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can use the &amp;lt;code&amp;gt;htpasswd&amp;lt;/code&amp;gt; command to configure a user &#039;&#039;nagiosadmin&#039;&#039; for the nagios web interface&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and type your password.&lt;br /&gt;
&lt;br /&gt;
===Enable the Nagios virtualhost===&lt;br /&gt;
&lt;br /&gt;
You can enable Nagios Virtualhost by the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo ln -s /etc/apache2/sites-available/nagios.conf /etc/apache2/sites-enabled/&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Start Apache and Nagios===&lt;br /&gt;
&lt;br /&gt;
Start the Apache and Nagios by the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo service apache2 restart&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo service nagios start&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When Nagios starts, you may see the following error :&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Starting nagios (via systemctl): nagios.serviceFailed&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
And you can fix it by:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;cd /etc/init.d/&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo cp /etc/init.d/skeleton /etc/init.d/nagios&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now edit the Nagios file by the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo nano /etc/init.d/nagios&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And add the following code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
DESC=&amp;quot;Nagios&amp;quot;&lt;br /&gt;
&lt;br /&gt;
NAME=nagios&lt;br /&gt;
&lt;br /&gt;
DAEMON=/usr/local/nagios/bin/$NAME&lt;br /&gt;
&lt;br /&gt;
DAEMON_ARGS=&amp;quot;-d /usr/local/nagios/etc/nagios.cfg&amp;quot;&lt;br /&gt;
&lt;br /&gt;
PIDFILE=/usr/local/nagios/var/$NAME.lock&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make it executable, restart apache2 and start Nagios:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo chmod +x /etc/init.d/nagios&lt;br /&gt;
&lt;br /&gt;
sudo service apache2 restart&lt;br /&gt;
&lt;br /&gt;
sudo servuce nagios start&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Testing the Nagios Server =&lt;br /&gt;
&lt;br /&gt;
Open your favorite web browser, and go to your Nagios server (substitute the IP address or hostname)&lt;br /&gt;
&lt;br /&gt;
(in my case: http://192.168.56.200/nagios).&lt;br /&gt;
&lt;br /&gt;
Because we configured Apache to use htpasswd, you must enter the login credentials that you created earlier.&lt;br /&gt;
&lt;br /&gt;
We used &amp;quot;nagiosadmin&amp;quot; as the username:&lt;br /&gt;
&lt;br /&gt;
[[File:Htpasswd_prompt.png|thumb|center|Nagios Authentication page]]&lt;br /&gt;
&lt;br /&gt;
After authenticating, you will be see the default Nagios home page: &lt;br /&gt;
&lt;br /&gt;
[[File:Nagios_adminpage.png|thumb|center|Nagios Homepage]]&lt;br /&gt;
&lt;br /&gt;
In the Homepage, click on the Hosts link, in the left navigation bar, to see which hosts Nagios is monitoring:&lt;br /&gt;
&lt;br /&gt;
[[File:Hosts_link.png|thumb|center|Nagios Hostpage]]&lt;br /&gt;
&lt;br /&gt;
As you can see, Nagios is monitoring only &amp;quot;localhost&amp;quot;, or itself.&lt;br /&gt;
&lt;br /&gt;
Let&#039;s monitor another host with Nagios!&lt;br /&gt;
&lt;br /&gt;
= Adding a Host to Monitor =&lt;br /&gt;
&lt;br /&gt;
In this section, you can see how to add a ubuntu host to Nagios server, so it will be monitored.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Note: Here replace the IP with your Nagios server IP and Ubuntu Host IP&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
In my case:&lt;br /&gt;
&lt;br /&gt;
Nagios Server IP : 192.168.56.200 &lt;br /&gt;
&lt;br /&gt;
Ubuntu Host IP : 192.168.56.100&lt;br /&gt;
&lt;br /&gt;
===Connect to ubuntu host===&lt;br /&gt;
&lt;br /&gt;
You can connect to Ubuntu host by using &#039;&#039;ssh&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you are not familiar with ssh use this [http://www.makeuseof.com/tag/beginners-guide-setting-ssh-linux-testing-setup/ Beginner’s Guide To Setting Up SSH On Linux]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;ssh student@192.168.56.100&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Install NRPE Service===&lt;br /&gt;
&lt;br /&gt;
Now install Nagios Plugins and NRPE by following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install nagios-nrpe-server nagios-plugins&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Configure NRPE===&lt;br /&gt;
&lt;br /&gt;
Now, let&#039;s update the NRPE configuration file.&lt;br /&gt;
&lt;br /&gt;
Open it in your favorite editor (we&#039;re using nano):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo nano /etc/nagios/nrpe.cfg&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Find the &#039;&#039;server_address&#039;&#039; directive, and add the private IP address of your Nagios server&lt;br /&gt;
&lt;br /&gt;
In my case:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;server_address=192.168.56.200&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
[[File:5.png|thumb|center|Configure NRPE]]&lt;br /&gt;
&lt;br /&gt;
===Restart NRPE===&lt;br /&gt;
&lt;br /&gt;
Restart NRPE by following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo service nagios-nrpe-server restart&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Add Ubuntu Host to Nagios Server===&lt;br /&gt;
&lt;br /&gt;
connect to the Nagios server:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;ssh student@192.168.56.200&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then create a new file for the host configuration in &#039;&#039;/usr/local/nagios/etc/servers/&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo nano /usr/local/nagios/etc/servers/ubuntu_host.cfg&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add the following lines:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Ubuntu Host configuration file&lt;br /&gt;
&lt;br /&gt;
define host {&lt;br /&gt;
        use                          linux-server&lt;br /&gt;
        host_name                    ubuntu_host&lt;br /&gt;
        alias                        Ubuntu Host&lt;br /&gt;
        address                      192.168.1.100&lt;br /&gt;
        register                     1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
define service {&lt;br /&gt;
      host_name                       ubuntu_host&lt;br /&gt;
      service_description             PING&lt;br /&gt;
      check_command                   check_ping!100.0,20%!500.0,60%&lt;br /&gt;
      max_check_attempts              2&lt;br /&gt;
      check_interval                  2&lt;br /&gt;
      retry_interval                  2&lt;br /&gt;
      check_period                    24x7&lt;br /&gt;
      check_freshness                 1&lt;br /&gt;
      contact_groups                  admins&lt;br /&gt;
      notification_interval           2&lt;br /&gt;
      notification_period             24x7&lt;br /&gt;
      notifications_enabled           1&lt;br /&gt;
      register                        1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
define service {&lt;br /&gt;
      host_name                       ubuntu_host&lt;br /&gt;
      service_description             Check Users&lt;br /&gt;
      check_command           check_local_users!20!50&lt;br /&gt;
      max_check_attempts              2&lt;br /&gt;
      check_interval                  2&lt;br /&gt;
      retry_interval                  2&lt;br /&gt;
      check_period                    24x7&lt;br /&gt;
      check_freshness                 1&lt;br /&gt;
      contact_groups                  admins&lt;br /&gt;
      notification_interval           2&lt;br /&gt;
      notification_period             24x7&lt;br /&gt;
      notifications_enabled           1&lt;br /&gt;
      register                        1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
define service {&lt;br /&gt;
      host_name                       ubuntu_host&lt;br /&gt;
      service_description             Local Disk&lt;br /&gt;
      check_command                   check_local_disk!20%!10%!/&lt;br /&gt;
      max_check_attempts              2&lt;br /&gt;
      check_interval                  2&lt;br /&gt;
      retry_interval                  2&lt;br /&gt;
      check_period                    24x7&lt;br /&gt;
      check_freshness                 1&lt;br /&gt;
      contact_groups                  admins&lt;br /&gt;
      notification_interval           2&lt;br /&gt;
      notification_period             24x7&lt;br /&gt;
      notifications_enabled           1&lt;br /&gt;
      register                        1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
define service {&lt;br /&gt;
      host_name                       ubuntu_host&lt;br /&gt;
      service_description             Check SSH&lt;br /&gt;
      check_command                   check_ssh&lt;br /&gt;
      max_check_attempts              2&lt;br /&gt;
      check_interval                  2&lt;br /&gt;
      retry_interval                  2&lt;br /&gt;
      check_period                    24x7&lt;br /&gt;
      check_freshness                 1&lt;br /&gt;
      contact_groups                  admins&lt;br /&gt;
      notification_interval           2&lt;br /&gt;
      notification_period             24x7&lt;br /&gt;
      notifications_enabled           1&lt;br /&gt;
      register                        1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
define service {&lt;br /&gt;
      host_name                       ubuntu_host&lt;br /&gt;
      service_description             Total Process&lt;br /&gt;
      check_command                   check_local_procs!250!400!RSZDT&lt;br /&gt;
      max_check_attempts              2&lt;br /&gt;
      check_interval                  2&lt;br /&gt;
      retry_interval                  2&lt;br /&gt;
      check_period                    24x7&lt;br /&gt;
      check_freshness                 1&lt;br /&gt;
      contact_groups                  admins&lt;br /&gt;
      notification_interval           2&lt;br /&gt;
      notification_period             24x7&lt;br /&gt;
      notifications_enabled           1&lt;br /&gt;
      register                        1&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can find many check_command in /usr/local/nagios/etc/objects/commands.cfg file. See there if you want to add more services like DHCP, POP etc.&lt;br /&gt;
&lt;br /&gt;
And now check the configuration:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
... to see if the configuration is correct.&lt;br /&gt;
&lt;br /&gt;
[[File:Nagios_check.png|thumb|center|Nagios check]]&lt;br /&gt;
&lt;br /&gt;
===Restart all services===&lt;br /&gt;
&lt;br /&gt;
On the Ubuntu Host start NRPE Service:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo service nagios-nrpe-server restart&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And on the Nagios server, start Apache and Nagios:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo service apache2 restart&lt;br /&gt;
&lt;br /&gt;
sudo service nagios restart&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Testing the Ubuntu Host =&lt;br /&gt;
&lt;br /&gt;
Open the Nagios server from the browser and see the ubuntu_host being monitored.&lt;br /&gt;
&lt;br /&gt;
The Ubuntu host is available on monitored host.&lt;br /&gt;
&lt;br /&gt;
[[File:Nagios.png|thumb|center|Nagios Testing Host]]&lt;br /&gt;
&lt;br /&gt;
All services monitored without error.&lt;br /&gt;
&lt;br /&gt;
[[File:Nagios ubuntu.png|thumb|center|Nagios Testing Host]]&lt;br /&gt;
&lt;br /&gt;
= Summary =&lt;br /&gt;
Nagios is an open application for systems monitoring. &lt;br /&gt;
It has several advantages, but main of them are:&lt;br /&gt;
*Easy to install and configure&lt;br /&gt;
*Easy to to use&lt;br /&gt;
*Supports extensions and plugins&lt;br /&gt;
&lt;br /&gt;
= Reference =&lt;br /&gt;
&lt;br /&gt;
1- [https://www.howtoforge.com/tutorial/ubuntu-nagios/ Nagios Installation]&lt;br /&gt;
&lt;br /&gt;
2- [https://www.linode.com/docs/uptime/monitoring/install-nagios-4-on-ubuntu-debian-8 Nagios tutorial]&lt;br /&gt;
&lt;br /&gt;
3- [https://www.digitalocean.com/community/tutorials/how-to-install-nagios-4-and-monitor-your-servers-on-ubuntu-14-04 Install Nagios and monitor your servers on ubuntu]&lt;br /&gt;
&lt;br /&gt;
4- [https://blog.serverdensity.com/howto-install-nagios-in-30-minutes-and-jumpstart-your-monitoring/ Nagios in 30 minutes and jumpstart your monitoring]&lt;br /&gt;
&lt;br /&gt;
5- [https://nagios-plugins.org/doc/guidelines.html Nagios Plugins]&lt;br /&gt;
&lt;br /&gt;
6- [http://www.monitance.com/en/product-news/what-is-server-monitoring-and-why-is-it-important/ Introduction Monitoring ]&lt;br /&gt;
&lt;br /&gt;
7- [https://www.nagios.org/about/overview/ Introduction Nagios ]&lt;br /&gt;
 &lt;br /&gt;
------&lt;br /&gt;
&lt;br /&gt;
[[Category:Monitoring]]&lt;/div&gt;</summary>
		<author><name>Ishustov</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Monitoring_Nagios&amp;diff=114754</id>
		<title>Monitoring Nagios</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Monitoring_Nagios&amp;diff=114754"/>
		<updated>2016-11-17T09:13:49Z</updated>

		<summary type="html">&lt;p&gt;Ishustov: /* Configure NRPE */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Team: &lt;br /&gt;
Ilja Shustov,&lt;br /&gt;
Sheela Raj &lt;br /&gt;
&lt;br /&gt;
Group : Cyber Security Engineering (C21)&lt;br /&gt;
&lt;br /&gt;
Page Created: 10 November 2016&lt;br /&gt;
&lt;br /&gt;
‎Last modified: 12 November 2016&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
In this article, we will cover the installation of &#039;&#039;&#039;Nagios&#039;&#039;&#039;, a very popular open source monitoring system, on Ubuntu. We will cover some basic configuration, so you will be able to monitor host resources via the web interface. We will also utilize the Nagios Remote Plugin Executor (NRPE), that will be installed as an agent on remote hosts, to monitor their local resources.&lt;br /&gt;
&lt;br /&gt;
===Monitoring===&lt;br /&gt;
&lt;br /&gt;
Server monitoring is basically a preventative measure to help you detect any issues before they cause any major issues that affect your productivity and your customer.&lt;br /&gt;
&lt;br /&gt;
Server monitoring is a process of continuously scanning servers on a designated network and scans the network for any failures or any irregularities that are detected by server monitoring software.&lt;br /&gt;
&lt;br /&gt;
===Why monitoring is important?===&lt;br /&gt;
Any network crashes costs time and money to fix.  At a time of downtime that is already costing your business money and hurting your reputation, it will be difficult to have to fork out more cash to get things back up and running again.  Server monitoring is important so that you can pick up any small issues before they evolve into anything major.  Server monitoring is essential in ensuring service availability.&lt;br /&gt;
&lt;br /&gt;
===Nagios===&lt;br /&gt;
Nagios is an open source computer-software application that monitors systems, networks and infrastructure. Nagios offers monitoring and alerting services for servers, switches, applications and services. It alerts users when things go wrong and alerts them a second time when the problem has been resolved.&lt;br /&gt;
&lt;br /&gt;
By using Nagios, you can:&lt;br /&gt;
&lt;br /&gt;
*Plan for infrastructure upgrades before outdated systems cause failures&lt;br /&gt;
*Respond to issues at the first sign of a problem&lt;br /&gt;
*Automatically fix problems when they are detected&lt;br /&gt;
*Coordinate technical team responses&lt;br /&gt;
*Ensure your organization’s SLAs are being met&lt;br /&gt;
*Ensure IT infrastructure outages have a minimal effect on your organization’s bottom line&lt;br /&gt;
*Monitor your entire infrastructure and business processes&lt;br /&gt;
&lt;br /&gt;
= Before You Begin =&lt;br /&gt;
===Check your current Ubuntu version &amp;amp; Upgrade===&lt;br /&gt;
&lt;br /&gt;
You can check your current ubuntu version by the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;lsb_release -a&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If your machine is already running Ubuntu 16.04.1 LTS or higher than that, There is no need for you to upgrade the OS.&lt;br /&gt;
&lt;br /&gt;
Otherwise you need to upgrade the OS by the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get update &amp;amp;&amp;amp; sudo apt-get upgrade&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039;&lt;br /&gt;
This article is written for a non-root user. Commands that require elevated privileges are prefixed with &amp;lt;code&amp;gt;sudo&amp;lt;/code&amp;gt;. If you’re not familiar with the &amp;lt;code&amp;gt;sudo&amp;lt;/code&amp;gt; command, you can check the [https://www.linode.com/docs/tools-reference/linux-users-and-groups Users and Groups] guide.&lt;br /&gt;
&lt;br /&gt;
===Install the required package===&lt;br /&gt;
&lt;br /&gt;
As a prerequisite, Nagios requires the gcc compiler and build-essentials for the compilation, LAMP (Apache, PHP, MySQL) for the Nagios web interface and Sendmail to send alerts from the server. &lt;br /&gt;
&lt;br /&gt;
To install all those packages, run the following command (it&#039;s just 1 line):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install wget build-essential apache2 php apache2-mod-php7.0 php-gd libgd-dev sendmail unzip&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Create Users and Groups===&lt;br /&gt;
&lt;br /&gt;
Create a user &#039;&#039;&#039;nagios&#039;&#039;&#039;, and a distinct group &#039;&#039;&#039;nagcmd&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Add &#039;&#039;&#039;nagios&#039;&#039;&#039; and the Apache user &#039;&#039;&#039;www-data&#039;&#039;&#039;, to the &#039;&#039;&#039;nagcmd&#039;&#039;&#039; group in order to run external commands on Nagios through the web interface&lt;br /&gt;
&lt;br /&gt;
Use the following command to create:&lt;br /&gt;
&lt;br /&gt;
To create user:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo useradd nagios&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To create group:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo groupadd nagcmd&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To add user to the group:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo usermod -a -G nagcmd nagios &amp;amp;&amp;amp; sudo usermod -a -G nagcmd www-data&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Installing Nagios =&lt;br /&gt;
&lt;br /&gt;
===Download and extract Nagios===&lt;br /&gt;
&lt;br /&gt;
In your web browser, go to the [https://www.nagios.org/downloads/core-stay-informed/ Nagios Core DIY download page].It will ask you to register, If you prefer not to register for updates, click Skip to download.&lt;br /&gt;
&lt;br /&gt;
Under Nagios Core, find the release that says Latest stable release under Notes, then copy the download link to your clipboard.&lt;br /&gt;
&lt;br /&gt;
Now using &amp;lt;code&amp;gt;wget&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;tar&amp;lt;/code&amp;gt;, download the Nagios and extract it.&lt;br /&gt;
&lt;br /&gt;
To download, paste the copied link after &amp;lt;code&amp;gt;wget&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.2.0.tar.gz &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Command to extract:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;tar -xzf nagios*.tar.gz&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now move to the newly created directory, by using the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;cd nagios-4.2.0&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Compile Nagios===&lt;br /&gt;
&lt;br /&gt;
Before you build Nagios, you will have to configure it with the user and the group you have created earlier.&lt;br /&gt;
&lt;br /&gt;
command to configure:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;./configure --with-nagios-group=nagios --with-command-group=nagcmd&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For more information please use: &amp;lt;code&amp;gt;./configure --help&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now compile Nagios with this command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;make all&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===To install Nagios===&lt;br /&gt;
&lt;br /&gt;
Now we can run these make commands to install &#039;&#039;&#039;Nagios&#039;&#039;&#039;, init scripts, and sample configuration files:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo make install &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo make install-commandmode &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo make install-init &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo make install-config &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; /usr/bin/install -c -m 644 sample-config/httpd.conf /etc/apache2/sites-available/nagios.conf &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And copy evenhandler directory to the nagios directory:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo cp -R contrib/eventhandlers/ /usr/local/nagios/libexec/ &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo chown -R nagios:nagios /usr/local/nagios/libexec/eventhandlers &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Nagios Plugins =&lt;br /&gt;
&lt;br /&gt;
Nagios Plugins allow you to monitor services like DHCP, FTP, HTTP and NTP.&lt;br /&gt;
&lt;br /&gt;
===Download and extract the Nagios plugins===&lt;br /&gt;
&lt;br /&gt;
To use Nagios Plugins, go to [https://nagios-plugins.org/downloads/ Nagios Plugins downloads] page and copy the download link for the current stable release.&lt;br /&gt;
&lt;br /&gt;
Now using &amp;lt;code&amp;gt;wget&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;tar&amp;lt;/code&amp;gt;, download and extract &#039;&#039;&#039;Nagios plugin&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Use the following command to move back into user&#039;s home directory:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;cd ~&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To download, paste the copied link after &amp;lt;code&amp;gt;wget&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;wget https://nagios-plugins.org/download/nagios-plugins-2.1.2.tar.gz&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Command to extract:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;tar -xzf nagios-plugins*.tar.gz&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now Change to the newly created directory by the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;cd nagios-plugins-2.1.2/&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Install Nagios plugins===&lt;br /&gt;
&lt;br /&gt;
Install the Nagios plugin&#039;s with the following commands:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;./configure --with-nagios-user=nagios --with-nagios-group=nagios --with-openssl&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo make install&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Configure Nagios =&lt;br /&gt;
&lt;br /&gt;
Now let&#039;s perform the initial Nagios configuration.&lt;br /&gt;
&lt;br /&gt;
===Organize Nagios Configuration===&lt;br /&gt;
&lt;br /&gt;
Open the main Nagios configuration file in your favorite text editor(vim/nano). &lt;br /&gt;
&lt;br /&gt;
We&#039;ll use nano to edit the file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo nano /usr/local/nagios/etc/nagios.cfg&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now find and uncomment the following line by deleting the #:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;#cfg_dir=/usr/local/nagios/etc/servers&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
Now create the directory named &#039;&#039;&#039;servers&#039;&#039;&#039; that will store the configuration file for each server that you will monitor:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo mkdir /usr/local/nagios/etc/servers&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Change the user and group for the new folder to nagios:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo chown nagios:nagios /usr/local/nagios/etc/servers&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Nagios3.png|thumb|right|Nagios Email]]&lt;br /&gt;
&lt;br /&gt;
===Configure Nagios Contacts===&lt;br /&gt;
&lt;br /&gt;
Open the Nagios contacts configuration in your favorite text editor(nano/vim).&lt;br /&gt;
&lt;br /&gt;
We&#039;ll use nano to edit the file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo nano /usr/local/nagios/etc/objects/contacts.cfg&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Find the email directive, and replace its value with your own email address&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
= Configuring Apache =&lt;br /&gt;
&lt;br /&gt;
===Enable Apache modules===&lt;br /&gt;
&lt;br /&gt;
Make sure Apache has &amp;lt;code&amp;gt;mod_rewrite&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;mod_cgi&amp;lt;/code&amp;gt; enabled&lt;br /&gt;
&lt;br /&gt;
Enable the Apache rewrite and cgi modules by the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo a2enmod rewrite &amp;amp;&amp;amp; sudo a2enmod cgi&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can use the &amp;lt;code&amp;gt;htpasswd&amp;lt;/code&amp;gt; command to configure a user &#039;&#039;nagiosadmin&#039;&#039; for the nagios web interface&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and type your password.&lt;br /&gt;
&lt;br /&gt;
===Enable the Nagios virtualhost===&lt;br /&gt;
&lt;br /&gt;
You can enable Nagios Virtualhost by the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo ln -s /etc/apache2/sites-available/nagios.conf /etc/apache2/sites-enabled/&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Start Apache and Nagios===&lt;br /&gt;
&lt;br /&gt;
Start the Apache and Nagios by the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo service apache2 restart&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo service nagios start&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When Nagios starts, you may see the following error :&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Starting nagios (via systemctl): nagios.serviceFailed&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
And you can fix it by:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;cd /etc/init.d/&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo cp /etc/init.d/skeleton /etc/init.d/nagios&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now edit the Nagios file by the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo nano /etc/init.d/nagios&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And add the following code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
DESC=&amp;quot;Nagios&amp;quot;&lt;br /&gt;
&lt;br /&gt;
NAME=nagios&lt;br /&gt;
&lt;br /&gt;
DAEMON=/usr/local/nagios/bin/$NAME&lt;br /&gt;
&lt;br /&gt;
DAEMON_ARGS=&amp;quot;-d /usr/local/nagios/etc/nagios.cfg&amp;quot;&lt;br /&gt;
&lt;br /&gt;
PIDFILE=/usr/local/nagios/var/$NAME.lock&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make it executable, restart apache2 and start Nagios:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo chmod +x /etc/init.d/nagios&lt;br /&gt;
&lt;br /&gt;
sudo service apache2 restart&lt;br /&gt;
&lt;br /&gt;
sudo servuce nagios start&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Testing the Nagios Server =&lt;br /&gt;
&lt;br /&gt;
Open your favorite web browser, and go to your Nagios server (substitute the IP address or hostname)&lt;br /&gt;
&lt;br /&gt;
(in my case: http://192.168.56.200/nagios).&lt;br /&gt;
&lt;br /&gt;
Because we configured Apache to use htpasswd, you must enter the login credentials that you created earlier.&lt;br /&gt;
&lt;br /&gt;
We used &amp;quot;nagiosadmin&amp;quot; as the username:&lt;br /&gt;
&lt;br /&gt;
[[File:Htpasswd_prompt.png|thumb|center|Nagios Authentication page]]&lt;br /&gt;
&lt;br /&gt;
After authenticating, you will be see the default Nagios home page: &lt;br /&gt;
&lt;br /&gt;
[[File:Nagios_adminpage.png|thumb|center|Nagios Homepage]]&lt;br /&gt;
&lt;br /&gt;
In the Homepage, click on the Hosts link, in the left navigation bar, to see which hosts Nagios is monitoring:&lt;br /&gt;
&lt;br /&gt;
[[File:Hosts_link.png|thumb|center|Nagios Hostpage]]&lt;br /&gt;
&lt;br /&gt;
As you can see, Nagios is monitoring only &amp;quot;localhost&amp;quot;, or itself.&lt;br /&gt;
&lt;br /&gt;
Let&#039;s monitor another host with Nagios!&lt;br /&gt;
&lt;br /&gt;
= Adding a Host to Monitor =&lt;br /&gt;
&lt;br /&gt;
In this section, you can see how to add a ubuntu host to Nagios server, so it will be monitored.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Note: Here replace the IP with your Nagios server IP and Ubuntu Host IP&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
In my case:&lt;br /&gt;
&lt;br /&gt;
Nagios Server IP : 192.168.56.200 &lt;br /&gt;
&lt;br /&gt;
Ubuntu Host IP : 192.168.56.100&lt;br /&gt;
&lt;br /&gt;
===Connect to ubuntu host===&lt;br /&gt;
&lt;br /&gt;
You can connect to Ubuntu host by using &#039;&#039;ssh&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you are not familiar with ssh use this [http://www.makeuseof.com/tag/beginners-guide-setting-ssh-linux-testing-setup/ Beginner’s Guide To Setting Up SSH On Linux]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;ssh student@192.168.56.100&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Install NRPE Service===&lt;br /&gt;
&lt;br /&gt;
Now install Nagios Plugins and NRPE by following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install nagios-nrpe-server nagios-plugins&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Configure NRPE===&lt;br /&gt;
&lt;br /&gt;
Now, let&#039;s update the NRPE configuration file.&lt;br /&gt;
&lt;br /&gt;
Open it in your favorite editor (we&#039;re using nano):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo nano /etc/nagios/nrpe.cfg&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Find the &#039;&#039;server_address&#039;&#039; directive, and add the private IP address of your Nagios server&lt;br /&gt;
&lt;br /&gt;
In my case:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;server_address=192.168.56.200&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
[[File:5.png|thumb|center|Configure NRPE]]&lt;br /&gt;
&lt;br /&gt;
===Restart NRPE===&lt;br /&gt;
&lt;br /&gt;
Restart NRPE by following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo service nagios-nrpe-server restart&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Add Ubuntu Host to Nagios Server===&lt;br /&gt;
&lt;br /&gt;
connect to the Nagios server:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;ssh student@192.168.56.200&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then create a new file for the host configuration in &#039;&#039;/usr/local/nagios/etc/servers/&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;nano /usr/local/nagios/etc/servers/ubuntu_host.cfg&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add the following lines:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Ubuntu Host configuration file&lt;br /&gt;
&lt;br /&gt;
define host {&lt;br /&gt;
        use                          linux-server&lt;br /&gt;
        host_name                    ubuntu_host&lt;br /&gt;
        alias                        Ubuntu Host&lt;br /&gt;
        address                      192.168.1.100&lt;br /&gt;
        register                     1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
define service {&lt;br /&gt;
      host_name                       ubuntu_host&lt;br /&gt;
      service_description             PING&lt;br /&gt;
      check_command                   check_ping!100.0,20%!500.0,60%&lt;br /&gt;
      max_check_attempts              2&lt;br /&gt;
      check_interval                  2&lt;br /&gt;
      retry_interval                  2&lt;br /&gt;
      check_period                    24x7&lt;br /&gt;
      check_freshness                 1&lt;br /&gt;
      contact_groups                  admins&lt;br /&gt;
      notification_interval           2&lt;br /&gt;
      notification_period             24x7&lt;br /&gt;
      notifications_enabled           1&lt;br /&gt;
      register                        1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
define service {&lt;br /&gt;
      host_name                       ubuntu_host&lt;br /&gt;
      service_description             Check Users&lt;br /&gt;
      check_command           check_local_users!20!50&lt;br /&gt;
      max_check_attempts              2&lt;br /&gt;
      check_interval                  2&lt;br /&gt;
      retry_interval                  2&lt;br /&gt;
      check_period                    24x7&lt;br /&gt;
      check_freshness                 1&lt;br /&gt;
      contact_groups                  admins&lt;br /&gt;
      notification_interval           2&lt;br /&gt;
      notification_period             24x7&lt;br /&gt;
      notifications_enabled           1&lt;br /&gt;
      register                        1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
define service {&lt;br /&gt;
      host_name                       ubuntu_host&lt;br /&gt;
      service_description             Local Disk&lt;br /&gt;
      check_command                   check_local_disk!20%!10%!/&lt;br /&gt;
      max_check_attempts              2&lt;br /&gt;
      check_interval                  2&lt;br /&gt;
      retry_interval                  2&lt;br /&gt;
      check_period                    24x7&lt;br /&gt;
      check_freshness                 1&lt;br /&gt;
      contact_groups                  admins&lt;br /&gt;
      notification_interval           2&lt;br /&gt;
      notification_period             24x7&lt;br /&gt;
      notifications_enabled           1&lt;br /&gt;
      register                        1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
define service {&lt;br /&gt;
      host_name                       ubuntu_host&lt;br /&gt;
      service_description             Check SSH&lt;br /&gt;
      check_command                   check_ssh&lt;br /&gt;
      max_check_attempts              2&lt;br /&gt;
      check_interval                  2&lt;br /&gt;
      retry_interval                  2&lt;br /&gt;
      check_period                    24x7&lt;br /&gt;
      check_freshness                 1&lt;br /&gt;
      contact_groups                  admins&lt;br /&gt;
      notification_interval           2&lt;br /&gt;
      notification_period             24x7&lt;br /&gt;
      notifications_enabled           1&lt;br /&gt;
      register                        1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
define service {&lt;br /&gt;
      host_name                       ubuntu_host&lt;br /&gt;
      service_description             Total Process&lt;br /&gt;
      check_command                   check_local_procs!250!400!RSZDT&lt;br /&gt;
      max_check_attempts              2&lt;br /&gt;
      check_interval                  2&lt;br /&gt;
      retry_interval                  2&lt;br /&gt;
      check_period                    24x7&lt;br /&gt;
      check_freshness                 1&lt;br /&gt;
      contact_groups                  admins&lt;br /&gt;
      notification_interval           2&lt;br /&gt;
      notification_period             24x7&lt;br /&gt;
      notifications_enabled           1&lt;br /&gt;
      register                        1&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can find many check_command in /usr/local/nagios/etc/objects/commands.cfg file. See there if you want to add more services like DHCP, POP etc.&lt;br /&gt;
&lt;br /&gt;
And now check the configuration:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
... to see if the configuration is correct.&lt;br /&gt;
&lt;br /&gt;
[[File:Nagios_check.png|thumb|center|Nagios check]]&lt;br /&gt;
&lt;br /&gt;
===Restart all services===&lt;br /&gt;
&lt;br /&gt;
On the Ubuntu Host start NRPE Service:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo service nagios-nrpe-server restart&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And on the Nagios server, start Apache and Nagios:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo service apache2 restart&lt;br /&gt;
&lt;br /&gt;
sudo service nagios restart&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Testing the Ubuntu Host =&lt;br /&gt;
&lt;br /&gt;
Open the Nagios server from the browser and see the ubuntu_host being monitored.&lt;br /&gt;
&lt;br /&gt;
The Ubuntu host is available on monitored host.&lt;br /&gt;
&lt;br /&gt;
[[File:Nagios.png|thumb|center|Nagios Testing Host]]&lt;br /&gt;
&lt;br /&gt;
All services monitored without error.&lt;br /&gt;
&lt;br /&gt;
[[File:Nagios ubuntu.png|thumb|center|Nagios Testing Host]]&lt;br /&gt;
&lt;br /&gt;
= Summary =&lt;br /&gt;
Nagios is an open application for systems monitoring. &lt;br /&gt;
It has several advantages, but main of them are:&lt;br /&gt;
*Easy to install and configure&lt;br /&gt;
*Easy to to use&lt;br /&gt;
*Supports extensions and plugins&lt;br /&gt;
&lt;br /&gt;
= Reference =&lt;br /&gt;
&lt;br /&gt;
1- [https://www.howtoforge.com/tutorial/ubuntu-nagios/ Nagios Installation]&lt;br /&gt;
&lt;br /&gt;
2- [https://www.linode.com/docs/uptime/monitoring/install-nagios-4-on-ubuntu-debian-8 Nagios tutorial]&lt;br /&gt;
&lt;br /&gt;
3- [https://www.digitalocean.com/community/tutorials/how-to-install-nagios-4-and-monitor-your-servers-on-ubuntu-14-04 Install Nagios and monitor your servers on ubuntu]&lt;br /&gt;
&lt;br /&gt;
4- [https://blog.serverdensity.com/howto-install-nagios-in-30-minutes-and-jumpstart-your-monitoring/ Nagios in 30 minutes and jumpstart your monitoring]&lt;br /&gt;
&lt;br /&gt;
5- [https://nagios-plugins.org/doc/guidelines.html Nagios Plugins]&lt;br /&gt;
&lt;br /&gt;
6- [http://www.monitance.com/en/product-news/what-is-server-monitoring-and-why-is-it-important/ Introduction Monitoring ]&lt;br /&gt;
&lt;br /&gt;
7- [https://www.nagios.org/about/overview/ Introduction Nagios ]&lt;br /&gt;
 &lt;br /&gt;
------&lt;br /&gt;
&lt;br /&gt;
[[Category:Monitoring]]&lt;/div&gt;</summary>
		<author><name>Ishustov</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Monitoring_Nagios&amp;diff=114678</id>
		<title>Monitoring Nagios</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Monitoring_Nagios&amp;diff=114678"/>
		<updated>2016-11-14T13:53:05Z</updated>

		<summary type="html">&lt;p&gt;Ishustov: /* Summary */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Team: &lt;br /&gt;
Ilja Shustov,&lt;br /&gt;
Sheela Raj &lt;br /&gt;
&lt;br /&gt;
Group : Cyber Security Engineering (C21)&lt;br /&gt;
&lt;br /&gt;
Page Created: 10 November 2016&lt;br /&gt;
&lt;br /&gt;
‎Last modified: 12 November 2016&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
In this article, we will cover the installation of &#039;&#039;&#039;Nagios&#039;&#039;&#039;, a very popular open source monitoring system, on Ubuntu. We will cover some basic configuration, so you will be able to monitor host resources via the web interface. We will also utilize the Nagios Remote Plugin Executor (NRPE), that will be installed as an agent on remote hosts, to monitor their local resources.&lt;br /&gt;
&lt;br /&gt;
===Monitoring===&lt;br /&gt;
&lt;br /&gt;
Server monitoring is basically a preventative measure to help you detect any issues before they cause any major issues that affect your productivity and your customer.&lt;br /&gt;
&lt;br /&gt;
Server monitoring is a process of continuously scanning servers on a designated network and scans the network for any failures or any irregularities that are detected by server monitoring software.&lt;br /&gt;
&lt;br /&gt;
===Why monitoring is important?===&lt;br /&gt;
Any network crashes costs time and money to fix.  At a time of downtime that is already costing your business money and hurting your reputation, it will be difficult to have to fork out more cash to get things back up and running again.  Server monitoring is important so that you can pick up any small issues before they evolve into anything major.  Server monitoring is essential in ensuring service availability.&lt;br /&gt;
&lt;br /&gt;
===Nagios===&lt;br /&gt;
Nagios is an open source computer-software application that monitors systems, networks and infrastructure. Nagios offers monitoring and alerting services for servers, switches, applications and services. It alerts users when things go wrong and alerts them a second time when the problem has been resolved.&lt;br /&gt;
&lt;br /&gt;
By using Nagios, you can:&lt;br /&gt;
&lt;br /&gt;
*Plan for infrastructure upgrades before outdated systems cause failures&lt;br /&gt;
*Respond to issues at the first sign of a problem&lt;br /&gt;
*Automatically fix problems when they are detected&lt;br /&gt;
*Coordinate technical team responses&lt;br /&gt;
*Ensure your organization’s SLAs are being met&lt;br /&gt;
*Ensure IT infrastructure outages have a minimal effect on your organization’s bottom line&lt;br /&gt;
*Monitor your entire infrastructure and business processes&lt;br /&gt;
&lt;br /&gt;
= Before You Begin =&lt;br /&gt;
===Check your current Ubuntu version &amp;amp; Upgrade===&lt;br /&gt;
&lt;br /&gt;
You can check your current ubuntu version by the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;lsb_release -a&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If your machine is already running Ubuntu 16.04.1 LTS or higher than that, There is no need for you to upgrade the OS.&lt;br /&gt;
&lt;br /&gt;
Otherwise you need to upgrade the OS by the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get update &amp;amp;&amp;amp; sudo apt-get upgrade&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039;&lt;br /&gt;
This article is written for a non-root user. Commands that require elevated privileges are prefixed with &amp;lt;code&amp;gt;sudo&amp;lt;/code&amp;gt;. If you’re not familiar with the &amp;lt;code&amp;gt;sudo&amp;lt;/code&amp;gt; command, you can check the [https://www.linode.com/docs/tools-reference/linux-users-and-groups Users and Groups] guide.&lt;br /&gt;
&lt;br /&gt;
===Install the required package===&lt;br /&gt;
&lt;br /&gt;
As a prerequisite, Nagios requires the gcc compiler and build-essentials for the compilation, LAMP (Apache, PHP, MySQL) for the Nagios web interface and Sendmail to send alerts from the server. &lt;br /&gt;
&lt;br /&gt;
To install all those packages, run the following command (it&#039;s just 1 line):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install wget build-essential apache2 php apache2-mod-php7.0 php-gd libgd-dev sendmail unzip&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Create Users and Groups===&lt;br /&gt;
&lt;br /&gt;
Create a user &#039;&#039;&#039;nagios&#039;&#039;&#039;, and a distinct group &#039;&#039;&#039;nagcmd&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Add &#039;&#039;&#039;nagios&#039;&#039;&#039; and the Apache user &#039;&#039;&#039;www-data&#039;&#039;&#039;, to the &#039;&#039;&#039;nagcmd&#039;&#039;&#039; group in order to run external commands on Nagios through the web interface&lt;br /&gt;
&lt;br /&gt;
Use the following command to create:&lt;br /&gt;
&lt;br /&gt;
To create user:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo useradd nagios&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To create group:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo groupadd nagcmd&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To add user to the group:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo usermod -a -G nagcmd nagios &amp;amp;&amp;amp; sudo usermod -a -G nagcmd www-data&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Installing Nagios =&lt;br /&gt;
&lt;br /&gt;
===Download and extract Nagios===&lt;br /&gt;
&lt;br /&gt;
In your web browser, go to the [https://www.nagios.org/downloads/core-stay-informed/ Nagios Core DIY download page].It will ask you to register, If you prefer not to register for updates, click Skip to download.&lt;br /&gt;
&lt;br /&gt;
Under Nagios Core, find the release that says Latest stable release under Notes, then copy the download link to your clipboard.&lt;br /&gt;
&lt;br /&gt;
Now using &amp;lt;code&amp;gt;wget&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;tar&amp;lt;/code&amp;gt;, download the Nagios and extract it.&lt;br /&gt;
&lt;br /&gt;
To download, paste the copied link after &amp;lt;code&amp;gt;wget&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.2.0.tar.gz &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Command to extract:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;tar -xzf nagios*.tar.gz&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now move to the newly created directory, by using the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;cd nagios-4.2.0&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Compile Nagios===&lt;br /&gt;
&lt;br /&gt;
Before you build Nagios, you will have to configure it with the user and the group you have created earlier.&lt;br /&gt;
&lt;br /&gt;
command to configure:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;./configure --with-nagios-group=nagios --with-command-group=nagcmd&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For more information please use: &amp;lt;code&amp;gt;./configure --help&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now compile Nagios with this command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;make all&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===To install Nagios===&lt;br /&gt;
&lt;br /&gt;
Now we can run these make commands to install &#039;&#039;&#039;Nagios&#039;&#039;&#039;, init scripts, and sample configuration files:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo make install &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo make install-commandmode &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo make install-init &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo make install-config &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; /usr/bin/install -c -m 644 sample-config/httpd.conf /etc/apache2/sites-available/nagios.conf &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And copy evenhandler directory to the nagios directory:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo cp -R contrib/eventhandlers/ /usr/local/nagios/libexec/ &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo chown -R nagios:nagios /usr/local/nagios/libexec/eventhandlers &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Nagios Plugins =&lt;br /&gt;
&lt;br /&gt;
Nagios Plugins allow you to monitor services like DHCP, FTP, HTTP and NTP.&lt;br /&gt;
&lt;br /&gt;
===Download and extract the Nagios plugins===&lt;br /&gt;
&lt;br /&gt;
To use Nagios Plugins, go to [https://nagios-plugins.org/downloads/ Nagios Plugins downloads] page and copy the download link for the current stable release.&lt;br /&gt;
&lt;br /&gt;
Now using &amp;lt;code&amp;gt;wget&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;tar&amp;lt;/code&amp;gt;, download and extract &#039;&#039;&#039;Nagios plugin&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Use the following command to move back into user&#039;s home directory:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;cd ~&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To download, paste the copied link after &amp;lt;code&amp;gt;wget&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;wget https://nagios-plugins.org/download/nagios-plugins-2.1.2.tar.gz&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Command to extract:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;tar -xzf nagios-plugins*.tar.gz&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now Change to the newly created directory by the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;cd nagios-plugins-2.1.2/&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Install Nagios plugins===&lt;br /&gt;
&lt;br /&gt;
Install the Nagios plugin&#039;s with the following commands:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;./configure --with-nagios-user=nagios --with-nagios-group=nagios --with-openssl&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo make install&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Configure Nagios =&lt;br /&gt;
&lt;br /&gt;
Now let&#039;s perform the initial Nagios configuration.&lt;br /&gt;
&lt;br /&gt;
===Organize Nagios Configuration===&lt;br /&gt;
&lt;br /&gt;
Open the main Nagios configuration file in your favorite text editor(vim/nano). &lt;br /&gt;
&lt;br /&gt;
We&#039;ll use nano to edit the file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo nano /usr/local/nagios/etc/nagios.cfg&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now find and uncomment the following line by deleting the #:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;#cfg_dir=/usr/local/nagios/etc/servers&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
Now create the directory named &#039;&#039;&#039;servers&#039;&#039;&#039; that will store the configuration file for each server that you will monitor:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo mkdir /usr/local/nagios/etc/servers&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Change the user and group for the new folder to nagios:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo chown nagios:nagios /usr/local/nagios/etc/servers&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Nagios3.png|thumb|right|Nagios Email]]&lt;br /&gt;
&lt;br /&gt;
===Configure Nagios Contacts===&lt;br /&gt;
&lt;br /&gt;
Open the Nagios contacts configuration in your favorite text editor(nano/vim).&lt;br /&gt;
&lt;br /&gt;
We&#039;ll use nano to edit the file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo nano /usr/local/nagios/etc/objects/contacts.cfg&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Find the email directive, and replace its value with your own email address&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
= Configuring Apache =&lt;br /&gt;
&lt;br /&gt;
===Enable Apache modules===&lt;br /&gt;
&lt;br /&gt;
Make sure Apache has &amp;lt;code&amp;gt;mod_rewrite&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;mod_cgi&amp;lt;/code&amp;gt; enabled&lt;br /&gt;
&lt;br /&gt;
Enable the Apache rewrite and cgi modules by the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo a2enmod rewrite &amp;amp;&amp;amp; sudo a2enmod cgi&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can use the &amp;lt;code&amp;gt;htpasswd&amp;lt;/code&amp;gt; command to configure a user &#039;&#039;nagiosadmin&#039;&#039; for the nagios web interface&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and type your password.&lt;br /&gt;
&lt;br /&gt;
===Enable the Nagios virtualhost===&lt;br /&gt;
&lt;br /&gt;
You can enable Nagios Virtualhost by the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo ln -s /etc/apache2/sites-available/nagios.conf /etc/apache2/sites-enabled/&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Start Apache and Nagios===&lt;br /&gt;
&lt;br /&gt;
Start the Apache and Nagios by the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo service apache2 restart&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo service nagios start&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When Nagios starts, you may see the following error :&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Starting nagios (via systemctl): nagios.serviceFailed&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
And you can fix it by:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;cd /etc/init.d/&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo cp /etc/init.d/skeleton /etc/init.d/nagios&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now edit the Nagios file by the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo nano /etc/init.d/nagios&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And add the following code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
DESC=&amp;quot;Nagios&amp;quot;&lt;br /&gt;
&lt;br /&gt;
NAME=nagios&lt;br /&gt;
&lt;br /&gt;
DAEMON=/usr/local/nagios/bin/$NAME&lt;br /&gt;
&lt;br /&gt;
DAEMON_ARGS=&amp;quot;-d /usr/local/nagios/etc/nagios.cfg&amp;quot;&lt;br /&gt;
&lt;br /&gt;
PIDFILE=/usr/local/nagios/var/$NAME.lock&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make it executable, restart apache2 and start Nagios:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo chmod +x /etc/init.d/nagios&lt;br /&gt;
&lt;br /&gt;
sudo service apache2 restart&lt;br /&gt;
&lt;br /&gt;
sudo servuce nagios start&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Testing the Nagios Server =&lt;br /&gt;
&lt;br /&gt;
Open your favorite web browser, and go to your Nagios server (substitute the IP address or hostname)&lt;br /&gt;
&lt;br /&gt;
(in my case: http://192.168.56.200/nagios).&lt;br /&gt;
&lt;br /&gt;
Because we configured Apache to use htpasswd, you must enter the login credentials that you created earlier.&lt;br /&gt;
&lt;br /&gt;
We used &amp;quot;nagiosadmin&amp;quot; as the username:&lt;br /&gt;
&lt;br /&gt;
[[File:Htpasswd_prompt.png|thumb|center|Nagios Authentication page]]&lt;br /&gt;
&lt;br /&gt;
After authenticating, you will be see the default Nagios home page: &lt;br /&gt;
&lt;br /&gt;
[[File:Nagios_adminpage.png|thumb|center|Nagios Homepage]]&lt;br /&gt;
&lt;br /&gt;
In the Homepage, click on the Hosts link, in the left navigation bar, to see which hosts Nagios is monitoring:&lt;br /&gt;
&lt;br /&gt;
[[File:Hosts_link.png|thumb|center|Nagios Hostpage]]&lt;br /&gt;
&lt;br /&gt;
As you can see, Nagios is monitoring only &amp;quot;localhost&amp;quot;, or itself.&lt;br /&gt;
&lt;br /&gt;
Let&#039;s monitor another host with Nagios!&lt;br /&gt;
&lt;br /&gt;
= Adding a Host to Monitor =&lt;br /&gt;
&lt;br /&gt;
In this section, you can see how to add a ubuntu host to Nagios server, so it will be monitored.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Note: Here replace the IP with your Nagios server IP and Ubuntu Host IP&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
In my case:&lt;br /&gt;
&lt;br /&gt;
Nagios Server IP : 192.168.56.200 &lt;br /&gt;
&lt;br /&gt;
Ubuntu Host IP : 192.168.56.100&lt;br /&gt;
&lt;br /&gt;
===Connect to ubuntu host===&lt;br /&gt;
&lt;br /&gt;
You can connect to Ubuntu host by using &#039;&#039;ssh&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you are not familiar with ssh use this [http://www.makeuseof.com/tag/beginners-guide-setting-ssh-linux-testing-setup/ Beginner’s Guide To Setting Up SSH On Linux]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;ssh student@192.168.56.100&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Install NRPE Service===&lt;br /&gt;
&lt;br /&gt;
Now install Nagios Plugins and NRPE by following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install nagios-nrpe-server nagios-plugins&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Configure NRPE===&lt;br /&gt;
&lt;br /&gt;
Now, let&#039;s update the NRPE configuration file.&lt;br /&gt;
&lt;br /&gt;
Open it in your favorite editor (we&#039;re using nano):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;nano /etc/nagios/nrpe.cfg&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Find the &#039;&#039;server_address&#039;&#039; directive, and add the private IP address of your Nagios server&lt;br /&gt;
&lt;br /&gt;
In my case:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;server_address=192.168.56.200&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
[[File:5.png|thumb|center|Configure NRPE]]&lt;br /&gt;
&lt;br /&gt;
===Restart NRPE===&lt;br /&gt;
&lt;br /&gt;
Restart NRPE by following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo service nagios-nrpe-server restart&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Add Ubuntu Host to Nagios Server===&lt;br /&gt;
&lt;br /&gt;
connect to the Nagios server:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;ssh student@192.168.56.200&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then create a new file for the host configuration in &#039;&#039;/usr/local/nagios/etc/servers/&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;nano /usr/local/nagios/etc/servers/ubuntu_host.cfg&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add the following lines:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Ubuntu Host configuration file&lt;br /&gt;
&lt;br /&gt;
define host {&lt;br /&gt;
        use                          linux-server&lt;br /&gt;
        host_name                    ubuntu_host&lt;br /&gt;
        alias                        Ubuntu Host&lt;br /&gt;
        address                      192.168.1.100&lt;br /&gt;
        register                     1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
define service {&lt;br /&gt;
      host_name                       ubuntu_host&lt;br /&gt;
      service_description             PING&lt;br /&gt;
      check_command                   check_ping!100.0,20%!500.0,60%&lt;br /&gt;
      max_check_attempts              2&lt;br /&gt;
      check_interval                  2&lt;br /&gt;
      retry_interval                  2&lt;br /&gt;
      check_period                    24x7&lt;br /&gt;
      check_freshness                 1&lt;br /&gt;
      contact_groups                  admins&lt;br /&gt;
      notification_interval           2&lt;br /&gt;
      notification_period             24x7&lt;br /&gt;
      notifications_enabled           1&lt;br /&gt;
      register                        1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
define service {&lt;br /&gt;
      host_name                       ubuntu_host&lt;br /&gt;
      service_description             Check Users&lt;br /&gt;
      check_command           check_local_users!20!50&lt;br /&gt;
      max_check_attempts              2&lt;br /&gt;
      check_interval                  2&lt;br /&gt;
      retry_interval                  2&lt;br /&gt;
      check_period                    24x7&lt;br /&gt;
      check_freshness                 1&lt;br /&gt;
      contact_groups                  admins&lt;br /&gt;
      notification_interval           2&lt;br /&gt;
      notification_period             24x7&lt;br /&gt;
      notifications_enabled           1&lt;br /&gt;
      register                        1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
define service {&lt;br /&gt;
      host_name                       ubuntu_host&lt;br /&gt;
      service_description             Local Disk&lt;br /&gt;
      check_command                   check_local_disk!20%!10%!/&lt;br /&gt;
      max_check_attempts              2&lt;br /&gt;
      check_interval                  2&lt;br /&gt;
      retry_interval                  2&lt;br /&gt;
      check_period                    24x7&lt;br /&gt;
      check_freshness                 1&lt;br /&gt;
      contact_groups                  admins&lt;br /&gt;
      notification_interval           2&lt;br /&gt;
      notification_period             24x7&lt;br /&gt;
      notifications_enabled           1&lt;br /&gt;
      register                        1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
define service {&lt;br /&gt;
      host_name                       ubuntu_host&lt;br /&gt;
      service_description             Check SSH&lt;br /&gt;
      check_command                   check_ssh&lt;br /&gt;
      max_check_attempts              2&lt;br /&gt;
      check_interval                  2&lt;br /&gt;
      retry_interval                  2&lt;br /&gt;
      check_period                    24x7&lt;br /&gt;
      check_freshness                 1&lt;br /&gt;
      contact_groups                  admins&lt;br /&gt;
      notification_interval           2&lt;br /&gt;
      notification_period             24x7&lt;br /&gt;
      notifications_enabled           1&lt;br /&gt;
      register                        1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
define service {&lt;br /&gt;
      host_name                       ubuntu_host&lt;br /&gt;
      service_description             Total Process&lt;br /&gt;
      check_command                   check_local_procs!250!400!RSZDT&lt;br /&gt;
      max_check_attempts              2&lt;br /&gt;
      check_interval                  2&lt;br /&gt;
      retry_interval                  2&lt;br /&gt;
      check_period                    24x7&lt;br /&gt;
      check_freshness                 1&lt;br /&gt;
      contact_groups                  admins&lt;br /&gt;
      notification_interval           2&lt;br /&gt;
      notification_period             24x7&lt;br /&gt;
      notifications_enabled           1&lt;br /&gt;
      register                        1&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can find many check_command in /usr/local/nagios/etc/objects/commands.cfg file. See there if you want to add more services like DHCP, POP etc.&lt;br /&gt;
&lt;br /&gt;
And now check the configuration:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
... to see if the configuration is correct.&lt;br /&gt;
&lt;br /&gt;
[[File:Nagios_check.png|thumb|center|Nagios check]]&lt;br /&gt;
&lt;br /&gt;
===Restart all services===&lt;br /&gt;
&lt;br /&gt;
On the Ubuntu Host start NRPE Service:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo service nagios-nrpe-server restart&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And on the Nagios server, start Apache and Nagios:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo service apache2 restart&lt;br /&gt;
&lt;br /&gt;
sudo service nagios restart&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Testing the Ubuntu Host =&lt;br /&gt;
&lt;br /&gt;
Open the Nagios server from the browser and see the ubuntu_host being monitored.&lt;br /&gt;
&lt;br /&gt;
The Ubuntu host is available on monitored host.&lt;br /&gt;
&lt;br /&gt;
[[File:Nagios.png|thumb|center|Nagios Testing Host]]&lt;br /&gt;
&lt;br /&gt;
All services monitored without error.&lt;br /&gt;
&lt;br /&gt;
[[File:Nagios ubuntu.png|thumb|center|Nagios Testing Host]]&lt;br /&gt;
&lt;br /&gt;
= Summary =&lt;br /&gt;
Nagios is an open application for systems monitoring. &lt;br /&gt;
It has several advantages, but main of them are:&lt;br /&gt;
*Easy to install and configure&lt;br /&gt;
*Easy to to use&lt;br /&gt;
*Supports extensions and plugins&lt;br /&gt;
&lt;br /&gt;
= Reference =&lt;br /&gt;
&lt;br /&gt;
1- [https://www.howtoforge.com/tutorial/ubuntu-nagios/ Nagios Installation]&lt;br /&gt;
&lt;br /&gt;
2- [https://www.linode.com/docs/uptime/monitoring/install-nagios-4-on-ubuntu-debian-8 Nagios tutorial]&lt;br /&gt;
&lt;br /&gt;
3- [https://www.digitalocean.com/community/tutorials/how-to-install-nagios-4-and-monitor-your-servers-on-ubuntu-14-04 Install Nagios and monitor your servers on ubuntu]&lt;br /&gt;
&lt;br /&gt;
4- [https://blog.serverdensity.com/howto-install-nagios-in-30-minutes-and-jumpstart-your-monitoring/ Nagios in 30 minutes and jumpstart your monitoring]&lt;br /&gt;
&lt;br /&gt;
5- [https://nagios-plugins.org/doc/guidelines.html Nagios Plugins]&lt;br /&gt;
&lt;br /&gt;
6- [http://www.monitance.com/en/product-news/what-is-server-monitoring-and-why-is-it-important/ Introduction Monitoring ]&lt;br /&gt;
&lt;br /&gt;
7- [https://www.nagios.org/about/overview/ Introduction Nagios ]&lt;br /&gt;
 &lt;br /&gt;
------&lt;br /&gt;
&lt;br /&gt;
[[Category:Monitoring]]&lt;/div&gt;</summary>
		<author><name>Ishustov</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Monitoring_Nagios&amp;diff=114677</id>
		<title>Monitoring Nagios</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Monitoring_Nagios&amp;diff=114677"/>
		<updated>2016-11-14T13:39:59Z</updated>

		<summary type="html">&lt;p&gt;Ishustov: /* Nagios */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Team: &lt;br /&gt;
Ilja Shustov,&lt;br /&gt;
Sheela Raj &lt;br /&gt;
&lt;br /&gt;
Group : Cyber Security Engineering (C21)&lt;br /&gt;
&lt;br /&gt;
Page Created: 10 November 2016&lt;br /&gt;
&lt;br /&gt;
‎Last modified: 12 November 2016&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
In this article, we will cover the installation of &#039;&#039;&#039;Nagios&#039;&#039;&#039;, a very popular open source monitoring system, on Ubuntu. We will cover some basic configuration, so you will be able to monitor host resources via the web interface. We will also utilize the Nagios Remote Plugin Executor (NRPE), that will be installed as an agent on remote hosts, to monitor their local resources.&lt;br /&gt;
&lt;br /&gt;
===Monitoring===&lt;br /&gt;
&lt;br /&gt;
Server monitoring is basically a preventative measure to help you detect any issues before they cause any major issues that affect your productivity and your customer.&lt;br /&gt;
&lt;br /&gt;
Server monitoring is a process of continuously scanning servers on a designated network and scans the network for any failures or any irregularities that are detected by server monitoring software.&lt;br /&gt;
&lt;br /&gt;
===Why monitoring is important?===&lt;br /&gt;
Any network crashes costs time and money to fix.  At a time of downtime that is already costing your business money and hurting your reputation, it will be difficult to have to fork out more cash to get things back up and running again.  Server monitoring is important so that you can pick up any small issues before they evolve into anything major.  Server monitoring is essential in ensuring service availability.&lt;br /&gt;
&lt;br /&gt;
===Nagios===&lt;br /&gt;
Nagios is an open source computer-software application that monitors systems, networks and infrastructure. Nagios offers monitoring and alerting services for servers, switches, applications and services. It alerts users when things go wrong and alerts them a second time when the problem has been resolved.&lt;br /&gt;
&lt;br /&gt;
By using Nagios, you can:&lt;br /&gt;
&lt;br /&gt;
*Plan for infrastructure upgrades before outdated systems cause failures&lt;br /&gt;
*Respond to issues at the first sign of a problem&lt;br /&gt;
*Automatically fix problems when they are detected&lt;br /&gt;
*Coordinate technical team responses&lt;br /&gt;
*Ensure your organization’s SLAs are being met&lt;br /&gt;
*Ensure IT infrastructure outages have a minimal effect on your organization’s bottom line&lt;br /&gt;
*Monitor your entire infrastructure and business processes&lt;br /&gt;
&lt;br /&gt;
= Before You Begin =&lt;br /&gt;
===Check your current Ubuntu version &amp;amp; Upgrade===&lt;br /&gt;
&lt;br /&gt;
You can check your current ubuntu version by the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;lsb_release -a&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If your machine is already running Ubuntu 16.04.1 LTS or higher than that, There is no need for you to upgrade the OS.&lt;br /&gt;
&lt;br /&gt;
Otherwise you need to upgrade the OS by the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get update &amp;amp;&amp;amp; sudo apt-get upgrade&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039;&lt;br /&gt;
This article is written for a non-root user. Commands that require elevated privileges are prefixed with &amp;lt;code&amp;gt;sudo&amp;lt;/code&amp;gt;. If you’re not familiar with the &amp;lt;code&amp;gt;sudo&amp;lt;/code&amp;gt; command, you can check the [https://www.linode.com/docs/tools-reference/linux-users-and-groups Users and Groups] guide.&lt;br /&gt;
&lt;br /&gt;
===Install the required package===&lt;br /&gt;
&lt;br /&gt;
As a prerequisite, Nagios requires the gcc compiler and build-essentials for the compilation, LAMP (Apache, PHP, MySQL) for the Nagios web interface and Sendmail to send alerts from the server. &lt;br /&gt;
&lt;br /&gt;
To install all those packages, run the following command (it&#039;s just 1 line):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install wget build-essential apache2 php apache2-mod-php7.0 php-gd libgd-dev sendmail unzip&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Create Users and Groups===&lt;br /&gt;
&lt;br /&gt;
Create a user &#039;&#039;&#039;nagios&#039;&#039;&#039;, and a distinct group &#039;&#039;&#039;nagcmd&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Add &#039;&#039;&#039;nagios&#039;&#039;&#039; and the Apache user &#039;&#039;&#039;www-data&#039;&#039;&#039;, to the &#039;&#039;&#039;nagcmd&#039;&#039;&#039; group in order to run external commands on Nagios through the web interface&lt;br /&gt;
&lt;br /&gt;
Use the following command to create:&lt;br /&gt;
&lt;br /&gt;
To create user:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo useradd nagios&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To create group:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo groupadd nagcmd&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To add user to the group:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo usermod -a -G nagcmd nagios &amp;amp;&amp;amp; sudo usermod -a -G nagcmd www-data&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Installing Nagios =&lt;br /&gt;
&lt;br /&gt;
===Download and extract Nagios===&lt;br /&gt;
&lt;br /&gt;
In your web browser, go to the [https://www.nagios.org/downloads/core-stay-informed/ Nagios Core DIY download page].It will ask you to register, If you prefer not to register for updates, click Skip to download.&lt;br /&gt;
&lt;br /&gt;
Under Nagios Core, find the release that says Latest stable release under Notes, then copy the download link to your clipboard.&lt;br /&gt;
&lt;br /&gt;
Now using &amp;lt;code&amp;gt;wget&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;tar&amp;lt;/code&amp;gt;, download the Nagios and extract it.&lt;br /&gt;
&lt;br /&gt;
To download, paste the copied link after &amp;lt;code&amp;gt;wget&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.2.0.tar.gz &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Command to extract:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;tar -xzf nagios*.tar.gz&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now move to the newly created directory, by using the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;cd nagios-4.2.0&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Compile Nagios===&lt;br /&gt;
&lt;br /&gt;
Before you build Nagios, you will have to configure it with the user and the group you have created earlier.&lt;br /&gt;
&lt;br /&gt;
command to configure:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;./configure --with-nagios-group=nagios --with-command-group=nagcmd&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For more information please use: &amp;lt;code&amp;gt;./configure --help&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now compile Nagios with this command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;make all&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===To install Nagios===&lt;br /&gt;
&lt;br /&gt;
Now we can run these make commands to install &#039;&#039;&#039;Nagios&#039;&#039;&#039;, init scripts, and sample configuration files:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo make install &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo make install-commandmode &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo make install-init &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo make install-config &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; /usr/bin/install -c -m 644 sample-config/httpd.conf /etc/apache2/sites-available/nagios.conf &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And copy evenhandler directory to the nagios directory:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo cp -R contrib/eventhandlers/ /usr/local/nagios/libexec/ &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo chown -R nagios:nagios /usr/local/nagios/libexec/eventhandlers &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Nagios Plugins =&lt;br /&gt;
&lt;br /&gt;
Nagios Plugins allow you to monitor services like DHCP, FTP, HTTP and NTP.&lt;br /&gt;
&lt;br /&gt;
===Download and extract the Nagios plugins===&lt;br /&gt;
&lt;br /&gt;
To use Nagios Plugins, go to [https://nagios-plugins.org/downloads/ Nagios Plugins downloads] page and copy the download link for the current stable release.&lt;br /&gt;
&lt;br /&gt;
Now using &amp;lt;code&amp;gt;wget&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;tar&amp;lt;/code&amp;gt;, download and extract &#039;&#039;&#039;Nagios plugin&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Use the following command to move back into user&#039;s home directory:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;cd ~&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To download, paste the copied link after &amp;lt;code&amp;gt;wget&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;wget https://nagios-plugins.org/download/nagios-plugins-2.1.2.tar.gz&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Command to extract:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;tar -xzf nagios-plugins*.tar.gz&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now Change to the newly created directory by the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;cd nagios-plugins-2.1.2/&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Install Nagios plugins===&lt;br /&gt;
&lt;br /&gt;
Install the Nagios plugin&#039;s with the following commands:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;./configure --with-nagios-user=nagios --with-nagios-group=nagios --with-openssl&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo make install&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Configure Nagios =&lt;br /&gt;
&lt;br /&gt;
Now let&#039;s perform the initial Nagios configuration.&lt;br /&gt;
&lt;br /&gt;
===Organize Nagios Configuration===&lt;br /&gt;
&lt;br /&gt;
Open the main Nagios configuration file in your favorite text editor(vim/nano). &lt;br /&gt;
&lt;br /&gt;
We&#039;ll use nano to edit the file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo nano /usr/local/nagios/etc/nagios.cfg&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now find and uncomment the following line by deleting the #:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;#cfg_dir=/usr/local/nagios/etc/servers&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
Now create the directory named &#039;&#039;&#039;servers&#039;&#039;&#039; that will store the configuration file for each server that you will monitor:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo mkdir /usr/local/nagios/etc/servers&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Change the user and group for the new folder to nagios:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo chown nagios:nagios /usr/local/nagios/etc/servers&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Nagios3.png|thumb|right|Nagios Email]]&lt;br /&gt;
&lt;br /&gt;
===Configure Nagios Contacts===&lt;br /&gt;
&lt;br /&gt;
Open the Nagios contacts configuration in your favorite text editor(nano/vim).&lt;br /&gt;
&lt;br /&gt;
We&#039;ll use nano to edit the file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo nano /usr/local/nagios/etc/objects/contacts.cfg&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Find the email directive, and replace its value with your own email address&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
= Configuring Apache =&lt;br /&gt;
&lt;br /&gt;
===Enable Apache modules===&lt;br /&gt;
&lt;br /&gt;
Make sure Apache has &amp;lt;code&amp;gt;mod_rewrite&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;mod_cgi&amp;lt;/code&amp;gt; enabled&lt;br /&gt;
&lt;br /&gt;
Enable the Apache rewrite and cgi modules by the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo a2enmod rewrite &amp;amp;&amp;amp; sudo a2enmod cgi&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can use the &amp;lt;code&amp;gt;htpasswd&amp;lt;/code&amp;gt; command to configure a user &#039;&#039;nagiosadmin&#039;&#039; for the nagios web interface&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and type your password.&lt;br /&gt;
&lt;br /&gt;
===Enable the Nagios virtualhost===&lt;br /&gt;
&lt;br /&gt;
You can enable Nagios Virtualhost by the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo ln -s /etc/apache2/sites-available/nagios.conf /etc/apache2/sites-enabled/&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Start Apache and Nagios===&lt;br /&gt;
&lt;br /&gt;
Start the Apache and Nagios by the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo service apache2 restart&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo service nagios start&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When Nagios starts, you may see the following error :&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Starting nagios (via systemctl): nagios.serviceFailed&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
And you can fix it by:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;cd /etc/init.d/&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo cp /etc/init.d/skeleton /etc/init.d/nagios&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now edit the Nagios file by the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo nano /etc/init.d/nagios&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And add the following code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
DESC=&amp;quot;Nagios&amp;quot;&lt;br /&gt;
&lt;br /&gt;
NAME=nagios&lt;br /&gt;
&lt;br /&gt;
DAEMON=/usr/local/nagios/bin/$NAME&lt;br /&gt;
&lt;br /&gt;
DAEMON_ARGS=&amp;quot;-d /usr/local/nagios/etc/nagios.cfg&amp;quot;&lt;br /&gt;
&lt;br /&gt;
PIDFILE=/usr/local/nagios/var/$NAME.lock&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make it executable, restart apache2 and start Nagios:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo chmod +x /etc/init.d/nagios&lt;br /&gt;
&lt;br /&gt;
sudo service apache2 restart&lt;br /&gt;
&lt;br /&gt;
sudo servuce nagios start&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Testing the Nagios Server =&lt;br /&gt;
&lt;br /&gt;
Open your favorite web browser, and go to your Nagios server (substitute the IP address or hostname)&lt;br /&gt;
&lt;br /&gt;
(in my case: http://192.168.56.200/nagios).&lt;br /&gt;
&lt;br /&gt;
Because we configured Apache to use htpasswd, you must enter the login credentials that you created earlier.&lt;br /&gt;
&lt;br /&gt;
We used &amp;quot;nagiosadmin&amp;quot; as the username:&lt;br /&gt;
&lt;br /&gt;
[[File:Htpasswd_prompt.png|thumb|center|Nagios Authentication page]]&lt;br /&gt;
&lt;br /&gt;
After authenticating, you will be see the default Nagios home page: &lt;br /&gt;
&lt;br /&gt;
[[File:Nagios_adminpage.png|thumb|center|Nagios Homepage]]&lt;br /&gt;
&lt;br /&gt;
In the Homepage, click on the Hosts link, in the left navigation bar, to see which hosts Nagios is monitoring:&lt;br /&gt;
&lt;br /&gt;
[[File:Hosts_link.png|thumb|center|Nagios Hostpage]]&lt;br /&gt;
&lt;br /&gt;
As you can see, Nagios is monitoring only &amp;quot;localhost&amp;quot;, or itself.&lt;br /&gt;
&lt;br /&gt;
Let&#039;s monitor another host with Nagios!&lt;br /&gt;
&lt;br /&gt;
= Adding a Host to Monitor =&lt;br /&gt;
&lt;br /&gt;
In this section, you can see how to add a ubuntu host to Nagios server, so it will be monitored.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Note: Here replace the IP with your Nagios server IP and Ubuntu Host IP&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
In my case:&lt;br /&gt;
&lt;br /&gt;
Nagios Server IP : 192.168.56.200 &lt;br /&gt;
&lt;br /&gt;
Ubuntu Host IP : 192.168.56.100&lt;br /&gt;
&lt;br /&gt;
===Connect to ubuntu host===&lt;br /&gt;
&lt;br /&gt;
You can connect to Ubuntu host by using &#039;&#039;ssh&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you are not familiar with ssh use this [http://www.makeuseof.com/tag/beginners-guide-setting-ssh-linux-testing-setup/ Beginner’s Guide To Setting Up SSH On Linux]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;ssh student@192.168.56.100&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Install NRPE Service===&lt;br /&gt;
&lt;br /&gt;
Now install Nagios Plugins and NRPE by following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install nagios-nrpe-server nagios-plugins&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Configure NRPE===&lt;br /&gt;
&lt;br /&gt;
Now, let&#039;s update the NRPE configuration file.&lt;br /&gt;
&lt;br /&gt;
Open it in your favorite editor (we&#039;re using nano):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;nano /etc/nagios/nrpe.cfg&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Find the &#039;&#039;server_address&#039;&#039; directive, and add the private IP address of your Nagios server&lt;br /&gt;
&lt;br /&gt;
In my case:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;server_address=192.168.56.200&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
[[File:5.png|thumb|center|Configure NRPE]]&lt;br /&gt;
&lt;br /&gt;
===Restart NRPE===&lt;br /&gt;
&lt;br /&gt;
Restart NRPE by following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo service nagios-nrpe-server restart&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Add Ubuntu Host to Nagios Server===&lt;br /&gt;
&lt;br /&gt;
connect to the Nagios server:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;ssh student@192.168.56.200&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then create a new file for the host configuration in &#039;&#039;/usr/local/nagios/etc/servers/&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;nano /usr/local/nagios/etc/servers/ubuntu_host.cfg&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add the following lines:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Ubuntu Host configuration file&lt;br /&gt;
&lt;br /&gt;
define host {&lt;br /&gt;
        use                          linux-server&lt;br /&gt;
        host_name                    ubuntu_host&lt;br /&gt;
        alias                        Ubuntu Host&lt;br /&gt;
        address                      192.168.1.100&lt;br /&gt;
        register                     1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
define service {&lt;br /&gt;
      host_name                       ubuntu_host&lt;br /&gt;
      service_description             PING&lt;br /&gt;
      check_command                   check_ping!100.0,20%!500.0,60%&lt;br /&gt;
      max_check_attempts              2&lt;br /&gt;
      check_interval                  2&lt;br /&gt;
      retry_interval                  2&lt;br /&gt;
      check_period                    24x7&lt;br /&gt;
      check_freshness                 1&lt;br /&gt;
      contact_groups                  admins&lt;br /&gt;
      notification_interval           2&lt;br /&gt;
      notification_period             24x7&lt;br /&gt;
      notifications_enabled           1&lt;br /&gt;
      register                        1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
define service {&lt;br /&gt;
      host_name                       ubuntu_host&lt;br /&gt;
      service_description             Check Users&lt;br /&gt;
      check_command           check_local_users!20!50&lt;br /&gt;
      max_check_attempts              2&lt;br /&gt;
      check_interval                  2&lt;br /&gt;
      retry_interval                  2&lt;br /&gt;
      check_period                    24x7&lt;br /&gt;
      check_freshness                 1&lt;br /&gt;
      contact_groups                  admins&lt;br /&gt;
      notification_interval           2&lt;br /&gt;
      notification_period             24x7&lt;br /&gt;
      notifications_enabled           1&lt;br /&gt;
      register                        1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
define service {&lt;br /&gt;
      host_name                       ubuntu_host&lt;br /&gt;
      service_description             Local Disk&lt;br /&gt;
      check_command                   check_local_disk!20%!10%!/&lt;br /&gt;
      max_check_attempts              2&lt;br /&gt;
      check_interval                  2&lt;br /&gt;
      retry_interval                  2&lt;br /&gt;
      check_period                    24x7&lt;br /&gt;
      check_freshness                 1&lt;br /&gt;
      contact_groups                  admins&lt;br /&gt;
      notification_interval           2&lt;br /&gt;
      notification_period             24x7&lt;br /&gt;
      notifications_enabled           1&lt;br /&gt;
      register                        1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
define service {&lt;br /&gt;
      host_name                       ubuntu_host&lt;br /&gt;
      service_description             Check SSH&lt;br /&gt;
      check_command                   check_ssh&lt;br /&gt;
      max_check_attempts              2&lt;br /&gt;
      check_interval                  2&lt;br /&gt;
      retry_interval                  2&lt;br /&gt;
      check_period                    24x7&lt;br /&gt;
      check_freshness                 1&lt;br /&gt;
      contact_groups                  admins&lt;br /&gt;
      notification_interval           2&lt;br /&gt;
      notification_period             24x7&lt;br /&gt;
      notifications_enabled           1&lt;br /&gt;
      register                        1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
define service {&lt;br /&gt;
      host_name                       ubuntu_host&lt;br /&gt;
      service_description             Total Process&lt;br /&gt;
      check_command                   check_local_procs!250!400!RSZDT&lt;br /&gt;
      max_check_attempts              2&lt;br /&gt;
      check_interval                  2&lt;br /&gt;
      retry_interval                  2&lt;br /&gt;
      check_period                    24x7&lt;br /&gt;
      check_freshness                 1&lt;br /&gt;
      contact_groups                  admins&lt;br /&gt;
      notification_interval           2&lt;br /&gt;
      notification_period             24x7&lt;br /&gt;
      notifications_enabled           1&lt;br /&gt;
      register                        1&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can find many check_command in /usr/local/nagios/etc/objects/commands.cfg file. See there if you want to add more services like DHCP, POP etc.&lt;br /&gt;
&lt;br /&gt;
And now check the configuration:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
... to see if the configuration is correct.&lt;br /&gt;
&lt;br /&gt;
[[File:Nagios_check.png|thumb|center|Nagios check]]&lt;br /&gt;
&lt;br /&gt;
===Restart all services===&lt;br /&gt;
&lt;br /&gt;
On the Ubuntu Host start NRPE Service:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo service nagios-nrpe-server restart&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And on the Nagios server, start Apache and Nagios:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo service apache2 restart&lt;br /&gt;
&lt;br /&gt;
sudo service nagios restart&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Testing the Ubuntu Host =&lt;br /&gt;
&lt;br /&gt;
Open the Nagios server from the browser and see the ubuntu_host being monitored.&lt;br /&gt;
&lt;br /&gt;
The Ubuntu host is available on monitored host.&lt;br /&gt;
&lt;br /&gt;
[[File:Nagios.png|thumb|center|Nagios Testing Host]]&lt;br /&gt;
&lt;br /&gt;
All services monitored without error.&lt;br /&gt;
&lt;br /&gt;
[[File:Nagios ubuntu.png|thumb|center|Nagios Testing Host]]&lt;br /&gt;
&lt;br /&gt;
= Summary =&lt;br /&gt;
&lt;br /&gt;
= Reference =&lt;br /&gt;
&lt;br /&gt;
1- [https://www.howtoforge.com/tutorial/ubuntu-nagios/ Nagios Installation]&lt;br /&gt;
&lt;br /&gt;
2- [https://www.linode.com/docs/uptime/monitoring/install-nagios-4-on-ubuntu-debian-8 Nagios tutorial]&lt;br /&gt;
&lt;br /&gt;
3- [https://www.digitalocean.com/community/tutorials/how-to-install-nagios-4-and-monitor-your-servers-on-ubuntu-14-04 Install Nagios and monitor your servers on ubuntu]&lt;br /&gt;
&lt;br /&gt;
4- [https://blog.serverdensity.com/howto-install-nagios-in-30-minutes-and-jumpstart-your-monitoring/ Nagios in 30 minutes and jumpstart your monitoring]&lt;br /&gt;
&lt;br /&gt;
5- [https://nagios-plugins.org/doc/guidelines.html Nagios Plugins]&lt;br /&gt;
&lt;br /&gt;
6- [http://www.monitance.com/en/product-news/what-is-server-monitoring-and-why-is-it-important/ Introduction Monitoring ]&lt;br /&gt;
&lt;br /&gt;
7- [https://www.nagios.org/about/overview/ Introduction Nagios ]&lt;br /&gt;
 &lt;br /&gt;
------&lt;br /&gt;
&lt;br /&gt;
[[Category:Monitoring]]&lt;/div&gt;</summary>
		<author><name>Ishustov</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Monitoring_Nagios&amp;diff=114676</id>
		<title>Monitoring Nagios</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Monitoring_Nagios&amp;diff=114676"/>
		<updated>2016-11-14T13:37:31Z</updated>

		<summary type="html">&lt;p&gt;Ishustov: /* Add Ubuntu Host to Nagios Server */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Team: &lt;br /&gt;
Ilja Shustov,&lt;br /&gt;
Sheela Raj &lt;br /&gt;
&lt;br /&gt;
Group : Cyber Security Engineering (C21)&lt;br /&gt;
&lt;br /&gt;
Page Created: 10 November 2016&lt;br /&gt;
&lt;br /&gt;
‎Last modified: 12 November 2016&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
In this article, we will cover the installation of &#039;&#039;&#039;Nagios&#039;&#039;&#039;, a very popular open source monitoring system, on Ubuntu. We will cover some basic configuration, so you will be able to monitor host resources via the web interface. We will also utilize the Nagios Remote Plugin Executor (NRPE), that will be installed as an agent on remote hosts, to monitor their local resources.&lt;br /&gt;
&lt;br /&gt;
===Monitoring===&lt;br /&gt;
&lt;br /&gt;
Server monitoring is basically a preventative measure to help you detect any issues before they cause any major issues that affect your productivity and your customer.&lt;br /&gt;
&lt;br /&gt;
Server monitoring is a process of continuously scanning servers on a designated network and scans the network for any failures or any irregularities that are detected by server monitoring software.&lt;br /&gt;
&lt;br /&gt;
===Why monitoring is important?===&lt;br /&gt;
Any network crashes costs time and money to fix.  At a time of downtime that is already costing your business money and hurting your reputation, it will be difficult to have to fork out more cash to get things back up and running again.  Server monitoring is important so that you can pick up any small issues before they evolve into anything major.  Server monitoring is essential in ensuring service availability.&lt;br /&gt;
&lt;br /&gt;
===Nagios===&lt;br /&gt;
Nagios is a free and open source computer-software application that monitors systems, networks and infrastructure. Nagios offers monitoring and alerting services for servers, switches, applications and services. It alerts users when things go wrong and alerts them a second time when the problem has been resolved.&lt;br /&gt;
&lt;br /&gt;
By using Nagios, you can:&lt;br /&gt;
&lt;br /&gt;
*Plan for infrastructure upgrades before outdated systems cause failures&lt;br /&gt;
*Respond to issues at the first sign of a problem&lt;br /&gt;
*Automatically fix problems when they are detected&lt;br /&gt;
*Coordinate technical team responses&lt;br /&gt;
*Ensure your organization’s SLAs are being met&lt;br /&gt;
*Ensure IT infrastructure outages have a minimal effect on your organization’s bottom line&lt;br /&gt;
*Monitor your entire infrastructure and business processes&lt;br /&gt;
&lt;br /&gt;
= Before You Begin =&lt;br /&gt;
===Check your current Ubuntu version &amp;amp; Upgrade===&lt;br /&gt;
&lt;br /&gt;
You can check your current ubuntu version by the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;lsb_release -a&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If your machine is already running Ubuntu 16.04.1 LTS or higher than that, There is no need for you to upgrade the OS.&lt;br /&gt;
&lt;br /&gt;
Otherwise you need to upgrade the OS by the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get update &amp;amp;&amp;amp; sudo apt-get upgrade&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039;&lt;br /&gt;
This article is written for a non-root user. Commands that require elevated privileges are prefixed with &amp;lt;code&amp;gt;sudo&amp;lt;/code&amp;gt;. If you’re not familiar with the &amp;lt;code&amp;gt;sudo&amp;lt;/code&amp;gt; command, you can check the [https://www.linode.com/docs/tools-reference/linux-users-and-groups Users and Groups] guide.&lt;br /&gt;
&lt;br /&gt;
===Install the required package===&lt;br /&gt;
&lt;br /&gt;
As a prerequisite, Nagios requires the gcc compiler and build-essentials for the compilation, LAMP (Apache, PHP, MySQL) for the Nagios web interface and Sendmail to send alerts from the server. &lt;br /&gt;
&lt;br /&gt;
To install all those packages, run the following command (it&#039;s just 1 line):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install wget build-essential apache2 php apache2-mod-php7.0 php-gd libgd-dev sendmail unzip&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Create Users and Groups===&lt;br /&gt;
&lt;br /&gt;
Create a user &#039;&#039;&#039;nagios&#039;&#039;&#039;, and a distinct group &#039;&#039;&#039;nagcmd&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Add &#039;&#039;&#039;nagios&#039;&#039;&#039; and the Apache user &#039;&#039;&#039;www-data&#039;&#039;&#039;, to the &#039;&#039;&#039;nagcmd&#039;&#039;&#039; group in order to run external commands on Nagios through the web interface&lt;br /&gt;
&lt;br /&gt;
Use the following command to create:&lt;br /&gt;
&lt;br /&gt;
To create user:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo useradd nagios&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To create group:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo groupadd nagcmd&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To add user to the group:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo usermod -a -G nagcmd nagios &amp;amp;&amp;amp; sudo usermod -a -G nagcmd www-data&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Installing Nagios =&lt;br /&gt;
&lt;br /&gt;
===Download and extract Nagios===&lt;br /&gt;
&lt;br /&gt;
In your web browser, go to the [https://www.nagios.org/downloads/core-stay-informed/ Nagios Core DIY download page].It will ask you to register, If you prefer not to register for updates, click Skip to download.&lt;br /&gt;
&lt;br /&gt;
Under Nagios Core, find the release that says Latest stable release under Notes, then copy the download link to your clipboard.&lt;br /&gt;
&lt;br /&gt;
Now using &amp;lt;code&amp;gt;wget&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;tar&amp;lt;/code&amp;gt;, download the Nagios and extract it.&lt;br /&gt;
&lt;br /&gt;
To download, paste the copied link after &amp;lt;code&amp;gt;wget&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.2.0.tar.gz &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Command to extract:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;tar -xzf nagios*.tar.gz&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now move to the newly created directory, by using the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;cd nagios-4.2.0&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Compile Nagios===&lt;br /&gt;
&lt;br /&gt;
Before you build Nagios, you will have to configure it with the user and the group you have created earlier.&lt;br /&gt;
&lt;br /&gt;
command to configure:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;./configure --with-nagios-group=nagios --with-command-group=nagcmd&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For more information please use: &amp;lt;code&amp;gt;./configure --help&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now compile Nagios with this command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;make all&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===To install Nagios===&lt;br /&gt;
&lt;br /&gt;
Now we can run these make commands to install &#039;&#039;&#039;Nagios&#039;&#039;&#039;, init scripts, and sample configuration files:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo make install &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo make install-commandmode &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo make install-init &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo make install-config &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; /usr/bin/install -c -m 644 sample-config/httpd.conf /etc/apache2/sites-available/nagios.conf &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And copy evenhandler directory to the nagios directory:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo cp -R contrib/eventhandlers/ /usr/local/nagios/libexec/ &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo chown -R nagios:nagios /usr/local/nagios/libexec/eventhandlers &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Nagios Plugins =&lt;br /&gt;
&lt;br /&gt;
Nagios Plugins allow you to monitor services like DHCP, FTP, HTTP and NTP.&lt;br /&gt;
&lt;br /&gt;
===Download and extract the Nagios plugins===&lt;br /&gt;
&lt;br /&gt;
To use Nagios Plugins, go to [https://nagios-plugins.org/downloads/ Nagios Plugins downloads] page and copy the download link for the current stable release.&lt;br /&gt;
&lt;br /&gt;
Now using &amp;lt;code&amp;gt;wget&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;tar&amp;lt;/code&amp;gt;, download and extract &#039;&#039;&#039;Nagios plugin&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Use the following command to move back into user&#039;s home directory:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;cd ~&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To download, paste the copied link after &amp;lt;code&amp;gt;wget&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;wget https://nagios-plugins.org/download/nagios-plugins-2.1.2.tar.gz&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Command to extract:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;tar -xzf nagios-plugins*.tar.gz&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now Change to the newly created directory by the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;cd nagios-plugins-2.1.2/&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Install Nagios plugins===&lt;br /&gt;
&lt;br /&gt;
Install the Nagios plugin&#039;s with the following commands:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;./configure --with-nagios-user=nagios --with-nagios-group=nagios --with-openssl&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo make install&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Configure Nagios =&lt;br /&gt;
&lt;br /&gt;
Now let&#039;s perform the initial Nagios configuration.&lt;br /&gt;
&lt;br /&gt;
===Organize Nagios Configuration===&lt;br /&gt;
&lt;br /&gt;
Open the main Nagios configuration file in your favorite text editor(vim/nano). &lt;br /&gt;
&lt;br /&gt;
We&#039;ll use nano to edit the file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo nano /usr/local/nagios/etc/nagios.cfg&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now find and uncomment the following line by deleting the #:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;#cfg_dir=/usr/local/nagios/etc/servers&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
Now create the directory named &#039;&#039;&#039;servers&#039;&#039;&#039; that will store the configuration file for each server that you will monitor:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo mkdir /usr/local/nagios/etc/servers&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Change the user and group for the new folder to nagios:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo chown nagios:nagios /usr/local/nagios/etc/servers&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Nagios3.png|thumb|right|Nagios Email]]&lt;br /&gt;
&lt;br /&gt;
===Configure Nagios Contacts===&lt;br /&gt;
&lt;br /&gt;
Open the Nagios contacts configuration in your favorite text editor(nano/vim).&lt;br /&gt;
&lt;br /&gt;
We&#039;ll use nano to edit the file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo nano /usr/local/nagios/etc/objects/contacts.cfg&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Find the email directive, and replace its value with your own email address&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
= Configuring Apache =&lt;br /&gt;
&lt;br /&gt;
===Enable Apache modules===&lt;br /&gt;
&lt;br /&gt;
Make sure Apache has &amp;lt;code&amp;gt;mod_rewrite&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;mod_cgi&amp;lt;/code&amp;gt; enabled&lt;br /&gt;
&lt;br /&gt;
Enable the Apache rewrite and cgi modules by the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo a2enmod rewrite &amp;amp;&amp;amp; sudo a2enmod cgi&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can use the &amp;lt;code&amp;gt;htpasswd&amp;lt;/code&amp;gt; command to configure a user &#039;&#039;nagiosadmin&#039;&#039; for the nagios web interface&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and type your password.&lt;br /&gt;
&lt;br /&gt;
===Enable the Nagios virtualhost===&lt;br /&gt;
&lt;br /&gt;
You can enable Nagios Virtualhost by the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo ln -s /etc/apache2/sites-available/nagios.conf /etc/apache2/sites-enabled/&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Start Apache and Nagios===&lt;br /&gt;
&lt;br /&gt;
Start the Apache and Nagios by the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo service apache2 restart&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo service nagios start&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When Nagios starts, you may see the following error :&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Starting nagios (via systemctl): nagios.serviceFailed&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
And you can fix it by:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;cd /etc/init.d/&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo cp /etc/init.d/skeleton /etc/init.d/nagios&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now edit the Nagios file by the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo nano /etc/init.d/nagios&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And add the following code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
DESC=&amp;quot;Nagios&amp;quot;&lt;br /&gt;
&lt;br /&gt;
NAME=nagios&lt;br /&gt;
&lt;br /&gt;
DAEMON=/usr/local/nagios/bin/$NAME&lt;br /&gt;
&lt;br /&gt;
DAEMON_ARGS=&amp;quot;-d /usr/local/nagios/etc/nagios.cfg&amp;quot;&lt;br /&gt;
&lt;br /&gt;
PIDFILE=/usr/local/nagios/var/$NAME.lock&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make it executable, restart apache2 and start Nagios:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo chmod +x /etc/init.d/nagios&lt;br /&gt;
&lt;br /&gt;
sudo service apache2 restart&lt;br /&gt;
&lt;br /&gt;
sudo servuce nagios start&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Testing the Nagios Server =&lt;br /&gt;
&lt;br /&gt;
Open your favorite web browser, and go to your Nagios server (substitute the IP address or hostname)&lt;br /&gt;
&lt;br /&gt;
(in my case: http://192.168.56.200/nagios).&lt;br /&gt;
&lt;br /&gt;
Because we configured Apache to use htpasswd, you must enter the login credentials that you created earlier.&lt;br /&gt;
&lt;br /&gt;
We used &amp;quot;nagiosadmin&amp;quot; as the username:&lt;br /&gt;
&lt;br /&gt;
[[File:Htpasswd_prompt.png|thumb|center|Nagios Authentication page]]&lt;br /&gt;
&lt;br /&gt;
After authenticating, you will be see the default Nagios home page: &lt;br /&gt;
&lt;br /&gt;
[[File:Nagios_adminpage.png|thumb|center|Nagios Homepage]]&lt;br /&gt;
&lt;br /&gt;
In the Homepage, click on the Hosts link, in the left navigation bar, to see which hosts Nagios is monitoring:&lt;br /&gt;
&lt;br /&gt;
[[File:Hosts_link.png|thumb|center|Nagios Hostpage]]&lt;br /&gt;
&lt;br /&gt;
As you can see, Nagios is monitoring only &amp;quot;localhost&amp;quot;, or itself.&lt;br /&gt;
&lt;br /&gt;
Let&#039;s monitor another host with Nagios!&lt;br /&gt;
&lt;br /&gt;
= Adding a Host to Monitor =&lt;br /&gt;
&lt;br /&gt;
In this section, you can see how to add a ubuntu host to Nagios server, so it will be monitored.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Note: Here replace the IP with your Nagios server IP and Ubuntu Host IP&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
In my case:&lt;br /&gt;
&lt;br /&gt;
Nagios Server IP : 192.168.56.200 &lt;br /&gt;
&lt;br /&gt;
Ubuntu Host IP : 192.168.56.100&lt;br /&gt;
&lt;br /&gt;
===Connect to ubuntu host===&lt;br /&gt;
&lt;br /&gt;
You can connect to Ubuntu host by using &#039;&#039;ssh&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you are not familiar with ssh use this [http://www.makeuseof.com/tag/beginners-guide-setting-ssh-linux-testing-setup/ Beginner’s Guide To Setting Up SSH On Linux]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;ssh student@192.168.56.100&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Install NRPE Service===&lt;br /&gt;
&lt;br /&gt;
Now install Nagios Plugins and NRPE by following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install nagios-nrpe-server nagios-plugins&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Configure NRPE===&lt;br /&gt;
&lt;br /&gt;
Now, let&#039;s update the NRPE configuration file.&lt;br /&gt;
&lt;br /&gt;
Open it in your favorite editor (we&#039;re using nano):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;nano /etc/nagios/nrpe.cfg&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Find the &#039;&#039;server_address&#039;&#039; directive, and add the private IP address of your Nagios server&lt;br /&gt;
&lt;br /&gt;
In my case:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;server_address=192.168.56.200&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
[[File:5.png|thumb|center|Configure NRPE]]&lt;br /&gt;
&lt;br /&gt;
===Restart NRPE===&lt;br /&gt;
&lt;br /&gt;
Restart NRPE by following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo service nagios-nrpe-server restart&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Add Ubuntu Host to Nagios Server===&lt;br /&gt;
&lt;br /&gt;
connect to the Nagios server:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;ssh student@192.168.56.200&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then create a new file for the host configuration in &#039;&#039;/usr/local/nagios/etc/servers/&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;nano /usr/local/nagios/etc/servers/ubuntu_host.cfg&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add the following lines:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Ubuntu Host configuration file&lt;br /&gt;
&lt;br /&gt;
define host {&lt;br /&gt;
        use                          linux-server&lt;br /&gt;
        host_name                    ubuntu_host&lt;br /&gt;
        alias                        Ubuntu Host&lt;br /&gt;
        address                      192.168.1.100&lt;br /&gt;
        register                     1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
define service {&lt;br /&gt;
      host_name                       ubuntu_host&lt;br /&gt;
      service_description             PING&lt;br /&gt;
      check_command                   check_ping!100.0,20%!500.0,60%&lt;br /&gt;
      max_check_attempts              2&lt;br /&gt;
      check_interval                  2&lt;br /&gt;
      retry_interval                  2&lt;br /&gt;
      check_period                    24x7&lt;br /&gt;
      check_freshness                 1&lt;br /&gt;
      contact_groups                  admins&lt;br /&gt;
      notification_interval           2&lt;br /&gt;
      notification_period             24x7&lt;br /&gt;
      notifications_enabled           1&lt;br /&gt;
      register                        1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
define service {&lt;br /&gt;
      host_name                       ubuntu_host&lt;br /&gt;
      service_description             Check Users&lt;br /&gt;
      check_command           check_local_users!20!50&lt;br /&gt;
      max_check_attempts              2&lt;br /&gt;
      check_interval                  2&lt;br /&gt;
      retry_interval                  2&lt;br /&gt;
      check_period                    24x7&lt;br /&gt;
      check_freshness                 1&lt;br /&gt;
      contact_groups                  admins&lt;br /&gt;
      notification_interval           2&lt;br /&gt;
      notification_period             24x7&lt;br /&gt;
      notifications_enabled           1&lt;br /&gt;
      register                        1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
define service {&lt;br /&gt;
      host_name                       ubuntu_host&lt;br /&gt;
      service_description             Local Disk&lt;br /&gt;
      check_command                   check_local_disk!20%!10%!/&lt;br /&gt;
      max_check_attempts              2&lt;br /&gt;
      check_interval                  2&lt;br /&gt;
      retry_interval                  2&lt;br /&gt;
      check_period                    24x7&lt;br /&gt;
      check_freshness                 1&lt;br /&gt;
      contact_groups                  admins&lt;br /&gt;
      notification_interval           2&lt;br /&gt;
      notification_period             24x7&lt;br /&gt;
      notifications_enabled           1&lt;br /&gt;
      register                        1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
define service {&lt;br /&gt;
      host_name                       ubuntu_host&lt;br /&gt;
      service_description             Check SSH&lt;br /&gt;
      check_command                   check_ssh&lt;br /&gt;
      max_check_attempts              2&lt;br /&gt;
      check_interval                  2&lt;br /&gt;
      retry_interval                  2&lt;br /&gt;
      check_period                    24x7&lt;br /&gt;
      check_freshness                 1&lt;br /&gt;
      contact_groups                  admins&lt;br /&gt;
      notification_interval           2&lt;br /&gt;
      notification_period             24x7&lt;br /&gt;
      notifications_enabled           1&lt;br /&gt;
      register                        1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
define service {&lt;br /&gt;
      host_name                       ubuntu_host&lt;br /&gt;
      service_description             Total Process&lt;br /&gt;
      check_command                   check_local_procs!250!400!RSZDT&lt;br /&gt;
      max_check_attempts              2&lt;br /&gt;
      check_interval                  2&lt;br /&gt;
      retry_interval                  2&lt;br /&gt;
      check_period                    24x7&lt;br /&gt;
      check_freshness                 1&lt;br /&gt;
      contact_groups                  admins&lt;br /&gt;
      notification_interval           2&lt;br /&gt;
      notification_period             24x7&lt;br /&gt;
      notifications_enabled           1&lt;br /&gt;
      register                        1&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can find many check_command in /usr/local/nagios/etc/objects/commands.cfg file. See there if you want to add more services like DHCP, POP etc.&lt;br /&gt;
&lt;br /&gt;
And now check the configuration:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
... to see if the configuration is correct.&lt;br /&gt;
&lt;br /&gt;
[[File:Nagios_check.png|thumb|center|Nagios check]]&lt;br /&gt;
&lt;br /&gt;
===Restart all services===&lt;br /&gt;
&lt;br /&gt;
On the Ubuntu Host start NRPE Service:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo service nagios-nrpe-server restart&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And on the Nagios server, start Apache and Nagios:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo service apache2 restart&lt;br /&gt;
&lt;br /&gt;
sudo service nagios restart&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Testing the Ubuntu Host =&lt;br /&gt;
&lt;br /&gt;
Open the Nagios server from the browser and see the ubuntu_host being monitored.&lt;br /&gt;
&lt;br /&gt;
The Ubuntu host is available on monitored host.&lt;br /&gt;
&lt;br /&gt;
[[File:Nagios.png|thumb|center|Nagios Testing Host]]&lt;br /&gt;
&lt;br /&gt;
All services monitored without error.&lt;br /&gt;
&lt;br /&gt;
[[File:Nagios ubuntu.png|thumb|center|Nagios Testing Host]]&lt;br /&gt;
&lt;br /&gt;
= Summary =&lt;br /&gt;
&lt;br /&gt;
= Reference =&lt;br /&gt;
&lt;br /&gt;
1- [https://www.howtoforge.com/tutorial/ubuntu-nagios/ Nagios Installation]&lt;br /&gt;
&lt;br /&gt;
2- [https://www.linode.com/docs/uptime/monitoring/install-nagios-4-on-ubuntu-debian-8 Nagios tutorial]&lt;br /&gt;
&lt;br /&gt;
3- [https://www.digitalocean.com/community/tutorials/how-to-install-nagios-4-and-monitor-your-servers-on-ubuntu-14-04 Install Nagios and monitor your servers on ubuntu]&lt;br /&gt;
&lt;br /&gt;
4- [https://blog.serverdensity.com/howto-install-nagios-in-30-minutes-and-jumpstart-your-monitoring/ Nagios in 30 minutes and jumpstart your monitoring]&lt;br /&gt;
&lt;br /&gt;
5- [https://nagios-plugins.org/doc/guidelines.html Nagios Plugins]&lt;br /&gt;
&lt;br /&gt;
6- [http://www.monitance.com/en/product-news/what-is-server-monitoring-and-why-is-it-important/ Introduction Monitoring ]&lt;br /&gt;
&lt;br /&gt;
7- [https://www.nagios.org/about/overview/ Introduction Nagios ]&lt;br /&gt;
 &lt;br /&gt;
------&lt;br /&gt;
&lt;br /&gt;
[[Category:Monitoring]]&lt;/div&gt;</summary>
		<author><name>Ishustov</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Monitoring_Nagios&amp;diff=114675</id>
		<title>Monitoring Nagios</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Monitoring_Nagios&amp;diff=114675"/>
		<updated>2016-11-14T13:33:50Z</updated>

		<summary type="html">&lt;p&gt;Ishustov: /* Reference */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Team: &lt;br /&gt;
Ilja Shustov,&lt;br /&gt;
Sheela Raj &lt;br /&gt;
&lt;br /&gt;
Group : Cyber Security Engineering (C21)&lt;br /&gt;
&lt;br /&gt;
Page Created: 10 November 2016&lt;br /&gt;
&lt;br /&gt;
‎Last modified: 12 November 2016&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
In this article, we will cover the installation of &#039;&#039;&#039;Nagios&#039;&#039;&#039;, a very popular open source monitoring system, on Ubuntu. We will cover some basic configuration, so you will be able to monitor host resources via the web interface. We will also utilize the Nagios Remote Plugin Executor (NRPE), that will be installed as an agent on remote hosts, to monitor their local resources.&lt;br /&gt;
&lt;br /&gt;
===Monitoring===&lt;br /&gt;
&lt;br /&gt;
Server monitoring is basically a preventative measure to help you detect any issues before they cause any major issues that affect your productivity and your customer.&lt;br /&gt;
&lt;br /&gt;
Server monitoring is a process of continuously scanning servers on a designated network and scans the network for any failures or any irregularities that are detected by server monitoring software.&lt;br /&gt;
&lt;br /&gt;
===Why monitoring is important?===&lt;br /&gt;
Any network crashes costs time and money to fix.  At a time of downtime that is already costing your business money and hurting your reputation, it will be difficult to have to fork out more cash to get things back up and running again.  Server monitoring is important so that you can pick up any small issues before they evolve into anything major.  Server monitoring is essential in ensuring service availability.&lt;br /&gt;
&lt;br /&gt;
===Nagios===&lt;br /&gt;
Nagios is a free and open source computer-software application that monitors systems, networks and infrastructure. Nagios offers monitoring and alerting services for servers, switches, applications and services. It alerts users when things go wrong and alerts them a second time when the problem has been resolved.&lt;br /&gt;
&lt;br /&gt;
By using Nagios, you can:&lt;br /&gt;
&lt;br /&gt;
*Plan for infrastructure upgrades before outdated systems cause failures&lt;br /&gt;
*Respond to issues at the first sign of a problem&lt;br /&gt;
*Automatically fix problems when they are detected&lt;br /&gt;
*Coordinate technical team responses&lt;br /&gt;
*Ensure your organization’s SLAs are being met&lt;br /&gt;
*Ensure IT infrastructure outages have a minimal effect on your organization’s bottom line&lt;br /&gt;
*Monitor your entire infrastructure and business processes&lt;br /&gt;
&lt;br /&gt;
= Before You Begin =&lt;br /&gt;
===Check your current Ubuntu version &amp;amp; Upgrade===&lt;br /&gt;
&lt;br /&gt;
You can check your current ubuntu version by the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;lsb_release -a&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If your machine is already running Ubuntu 16.04.1 LTS or higher than that, There is no need for you to upgrade the OS.&lt;br /&gt;
&lt;br /&gt;
Otherwise you need to upgrade the OS by the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get update &amp;amp;&amp;amp; sudo apt-get upgrade&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039;&lt;br /&gt;
This article is written for a non-root user. Commands that require elevated privileges are prefixed with &amp;lt;code&amp;gt;sudo&amp;lt;/code&amp;gt;. If you’re not familiar with the &amp;lt;code&amp;gt;sudo&amp;lt;/code&amp;gt; command, you can check the [https://www.linode.com/docs/tools-reference/linux-users-and-groups Users and Groups] guide.&lt;br /&gt;
&lt;br /&gt;
===Install the required package===&lt;br /&gt;
&lt;br /&gt;
As a prerequisite, Nagios requires the gcc compiler and build-essentials for the compilation, LAMP (Apache, PHP, MySQL) for the Nagios web interface and Sendmail to send alerts from the server. &lt;br /&gt;
&lt;br /&gt;
To install all those packages, run the following command (it&#039;s just 1 line):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install wget build-essential apache2 php apache2-mod-php7.0 php-gd libgd-dev sendmail unzip&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Create Users and Groups===&lt;br /&gt;
&lt;br /&gt;
Create a user &#039;&#039;&#039;nagios&#039;&#039;&#039;, and a distinct group &#039;&#039;&#039;nagcmd&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Add &#039;&#039;&#039;nagios&#039;&#039;&#039; and the Apache user &#039;&#039;&#039;www-data&#039;&#039;&#039;, to the &#039;&#039;&#039;nagcmd&#039;&#039;&#039; group in order to run external commands on Nagios through the web interface&lt;br /&gt;
&lt;br /&gt;
Use the following command to create:&lt;br /&gt;
&lt;br /&gt;
To create user:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo useradd nagios&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To create group:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo groupadd nagcmd&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To add user to the group:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo usermod -a -G nagcmd nagios &amp;amp;&amp;amp; sudo usermod -a -G nagcmd www-data&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Installing Nagios =&lt;br /&gt;
&lt;br /&gt;
===Download and extract Nagios===&lt;br /&gt;
&lt;br /&gt;
In your web browser, go to the [https://www.nagios.org/downloads/core-stay-informed/ Nagios Core DIY download page].It will ask you to register, If you prefer not to register for updates, click Skip to download.&lt;br /&gt;
&lt;br /&gt;
Under Nagios Core, find the release that says Latest stable release under Notes, then copy the download link to your clipboard.&lt;br /&gt;
&lt;br /&gt;
Now using &amp;lt;code&amp;gt;wget&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;tar&amp;lt;/code&amp;gt;, download the Nagios and extract it.&lt;br /&gt;
&lt;br /&gt;
To download, paste the copied link after &amp;lt;code&amp;gt;wget&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.2.0.tar.gz &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Command to extract:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;tar -xzf nagios*.tar.gz&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now move to the newly created directory, by using the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;cd nagios-4.2.0&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Compile Nagios===&lt;br /&gt;
&lt;br /&gt;
Before you build Nagios, you will have to configure it with the user and the group you have created earlier.&lt;br /&gt;
&lt;br /&gt;
command to configure:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;./configure --with-nagios-group=nagios --with-command-group=nagcmd&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For more information please use: &amp;lt;code&amp;gt;./configure --help&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now compile Nagios with this command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;make all&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===To install Nagios===&lt;br /&gt;
&lt;br /&gt;
Now we can run these make commands to install &#039;&#039;&#039;Nagios&#039;&#039;&#039;, init scripts, and sample configuration files:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo make install &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo make install-commandmode &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo make install-init &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo make install-config &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; /usr/bin/install -c -m 644 sample-config/httpd.conf /etc/apache2/sites-available/nagios.conf &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And copy evenhandler directory to the nagios directory:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo cp -R contrib/eventhandlers/ /usr/local/nagios/libexec/ &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo chown -R nagios:nagios /usr/local/nagios/libexec/eventhandlers &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Nagios Plugins =&lt;br /&gt;
&lt;br /&gt;
Nagios Plugins allow you to monitor services like DHCP, FTP, HTTP and NTP.&lt;br /&gt;
&lt;br /&gt;
===Download and extract the Nagios plugins===&lt;br /&gt;
&lt;br /&gt;
To use Nagios Plugins, go to [https://nagios-plugins.org/downloads/ Nagios Plugins downloads] page and copy the download link for the current stable release.&lt;br /&gt;
&lt;br /&gt;
Now using &amp;lt;code&amp;gt;wget&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;tar&amp;lt;/code&amp;gt;, download and extract &#039;&#039;&#039;Nagios plugin&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Use the following command to move back into user&#039;s home directory:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;cd ~&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To download, paste the copied link after &amp;lt;code&amp;gt;wget&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;wget https://nagios-plugins.org/download/nagios-plugins-2.1.2.tar.gz&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Command to extract:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;tar -xzf nagios-plugins*.tar.gz&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now Change to the newly created directory by the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;cd nagios-plugins-2.1.2/&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Install Nagios plugins===&lt;br /&gt;
&lt;br /&gt;
Install the Nagios plugin&#039;s with the following commands:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;./configure --with-nagios-user=nagios --with-nagios-group=nagios --with-openssl&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo make install&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Configure Nagios =&lt;br /&gt;
&lt;br /&gt;
Now let&#039;s perform the initial Nagios configuration.&lt;br /&gt;
&lt;br /&gt;
===Organize Nagios Configuration===&lt;br /&gt;
&lt;br /&gt;
Open the main Nagios configuration file in your favorite text editor(vim/nano). &lt;br /&gt;
&lt;br /&gt;
We&#039;ll use nano to edit the file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo nano /usr/local/nagios/etc/nagios.cfg&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now find and uncomment the following line by deleting the #:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;#cfg_dir=/usr/local/nagios/etc/servers&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
Now create the directory named &#039;&#039;&#039;servers&#039;&#039;&#039; that will store the configuration file for each server that you will monitor:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo mkdir /usr/local/nagios/etc/servers&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Change the user and group for the new folder to nagios:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo chown nagios:nagios /usr/local/nagios/etc/servers&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Nagios3.png|thumb|right|Nagios Email]]&lt;br /&gt;
&lt;br /&gt;
===Configure Nagios Contacts===&lt;br /&gt;
&lt;br /&gt;
Open the Nagios contacts configuration in your favorite text editor(nano/vim).&lt;br /&gt;
&lt;br /&gt;
We&#039;ll use nano to edit the file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo nano /usr/local/nagios/etc/objects/contacts.cfg&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Find the email directive, and replace its value with your own email address&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
= Configuring Apache =&lt;br /&gt;
&lt;br /&gt;
===Enable Apache modules===&lt;br /&gt;
&lt;br /&gt;
Make sure Apache has &amp;lt;code&amp;gt;mod_rewrite&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;mod_cgi&amp;lt;/code&amp;gt; enabled&lt;br /&gt;
&lt;br /&gt;
Enable the Apache rewrite and cgi modules by the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo a2enmod rewrite &amp;amp;&amp;amp; sudo a2enmod cgi&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can use the &amp;lt;code&amp;gt;htpasswd&amp;lt;/code&amp;gt; command to configure a user &#039;&#039;nagiosadmin&#039;&#039; for the nagios web interface&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and type your password.&lt;br /&gt;
&lt;br /&gt;
===Enable the Nagios virtualhost===&lt;br /&gt;
&lt;br /&gt;
You can enable Nagios Virtualhost by the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo ln -s /etc/apache2/sites-available/nagios.conf /etc/apache2/sites-enabled/&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Start Apache and Nagios===&lt;br /&gt;
&lt;br /&gt;
Start the Apache and Nagios by the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo service apache2 restart&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo service nagios start&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When Nagios starts, you may see the following error :&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Starting nagios (via systemctl): nagios.serviceFailed&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
And you can fix it by:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;cd /etc/init.d/&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo cp /etc/init.d/skeleton /etc/init.d/nagios&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now edit the Nagios file by the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo nano /etc/init.d/nagios&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And add the following code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
DESC=&amp;quot;Nagios&amp;quot;&lt;br /&gt;
&lt;br /&gt;
NAME=nagios&lt;br /&gt;
&lt;br /&gt;
DAEMON=/usr/local/nagios/bin/$NAME&lt;br /&gt;
&lt;br /&gt;
DAEMON_ARGS=&amp;quot;-d /usr/local/nagios/etc/nagios.cfg&amp;quot;&lt;br /&gt;
&lt;br /&gt;
PIDFILE=/usr/local/nagios/var/$NAME.lock&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make it executable, restart apache2 and start Nagios:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo chmod +x /etc/init.d/nagios&lt;br /&gt;
&lt;br /&gt;
sudo service apache2 restart&lt;br /&gt;
&lt;br /&gt;
sudo servuce nagios start&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Testing the Nagios Server =&lt;br /&gt;
&lt;br /&gt;
Open your favorite web browser, and go to your Nagios server (substitute the IP address or hostname)&lt;br /&gt;
&lt;br /&gt;
(in my case: http://192.168.56.200/nagios).&lt;br /&gt;
&lt;br /&gt;
Because we configured Apache to use htpasswd, you must enter the login credentials that you created earlier.&lt;br /&gt;
&lt;br /&gt;
We used &amp;quot;nagiosadmin&amp;quot; as the username:&lt;br /&gt;
&lt;br /&gt;
[[File:Htpasswd_prompt.png|thumb|center|Nagios Authentication page]]&lt;br /&gt;
&lt;br /&gt;
After authenticating, you will be see the default Nagios home page: &lt;br /&gt;
&lt;br /&gt;
[[File:Nagios_adminpage.png|thumb|center|Nagios Homepage]]&lt;br /&gt;
&lt;br /&gt;
In the Homepage, click on the Hosts link, in the left navigation bar, to see which hosts Nagios is monitoring:&lt;br /&gt;
&lt;br /&gt;
[[File:Hosts_link.png|thumb|center|Nagios Hostpage]]&lt;br /&gt;
&lt;br /&gt;
As you can see, Nagios is monitoring only &amp;quot;localhost&amp;quot;, or itself.&lt;br /&gt;
&lt;br /&gt;
Let&#039;s monitor another host with Nagios!&lt;br /&gt;
&lt;br /&gt;
= Adding a Host to Monitor =&lt;br /&gt;
&lt;br /&gt;
In this section, you can see how to add a ubuntu host to Nagios server, so it will be monitored.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Note: Here replace the IP with your Nagios server IP and Ubuntu Host IP&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
In my case:&lt;br /&gt;
&lt;br /&gt;
Nagios Server IP : 192.168.56.200 &lt;br /&gt;
&lt;br /&gt;
Ubuntu Host IP : 192.168.56.100&lt;br /&gt;
&lt;br /&gt;
===Connect to ubuntu host===&lt;br /&gt;
&lt;br /&gt;
You can connect to Ubuntu host by using &#039;&#039;ssh&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you are not familiar with ssh use this [http://www.makeuseof.com/tag/beginners-guide-setting-ssh-linux-testing-setup/ Beginner’s Guide To Setting Up SSH On Linux]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;ssh student@192.168.56.100&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Install NRPE Service===&lt;br /&gt;
&lt;br /&gt;
Now install Nagios Plugins and NRPE by following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install nagios-nrpe-server nagios-plugins&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Configure NRPE===&lt;br /&gt;
&lt;br /&gt;
Now, let&#039;s update the NRPE configuration file.&lt;br /&gt;
&lt;br /&gt;
Open it in your favorite editor (we&#039;re using nano):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;nano /etc/nagios/nrpe.cfg&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Find the &#039;&#039;server_address&#039;&#039; directive, and add the private IP address of your Nagios server&lt;br /&gt;
&lt;br /&gt;
In my case:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;server_address=192.168.56.200&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
[[File:5.png|thumb|center|Configure NRPE]]&lt;br /&gt;
&lt;br /&gt;
===Restart NRPE===&lt;br /&gt;
&lt;br /&gt;
Restart NRPE by following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo service nagios-nrpe-server restart&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Add Ubuntu Host to Nagios Server===&lt;br /&gt;
&lt;br /&gt;
connect to the Nagios server:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;ssh student@192.168.56.200&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then create a new file for the host configuration in &#039;&#039;/usr/local/nagios/etc/servers/&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;nano /usr/local/nagios/etc/servers/ubuntu_host.cfg&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add the following lines:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Ubuntu Host configuration file&lt;br /&gt;
&lt;br /&gt;
define host {&lt;br /&gt;
        use                          linux-server&lt;br /&gt;
        host_name                    ubuntu_host&lt;br /&gt;
        alias                        Ubuntu Host&lt;br /&gt;
        address                      192.168.1.10&lt;br /&gt;
        register                     1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
define service {&lt;br /&gt;
      host_name                       ubuntu_host&lt;br /&gt;
      service_description             PING&lt;br /&gt;
      check_command                   check_ping!100.0,20%!500.0,60%&lt;br /&gt;
      max_check_attempts              2&lt;br /&gt;
      check_interval                  2&lt;br /&gt;
      retry_interval                  2&lt;br /&gt;
      check_period                    24x7&lt;br /&gt;
      check_freshness                 1&lt;br /&gt;
      contact_groups                  admins&lt;br /&gt;
      notification_interval           2&lt;br /&gt;
      notification_period             24x7&lt;br /&gt;
      notifications_enabled           1&lt;br /&gt;
      register                        1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
define service {&lt;br /&gt;
      host_name                       ubuntu_host&lt;br /&gt;
      service_description             Check Users&lt;br /&gt;
      check_command           check_local_users!20!50&lt;br /&gt;
      max_check_attempts              2&lt;br /&gt;
      check_interval                  2&lt;br /&gt;
      retry_interval                  2&lt;br /&gt;
      check_period                    24x7&lt;br /&gt;
      check_freshness                 1&lt;br /&gt;
      contact_groups                  admins&lt;br /&gt;
      notification_interval           2&lt;br /&gt;
      notification_period             24x7&lt;br /&gt;
      notifications_enabled           1&lt;br /&gt;
      register                        1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
define service {&lt;br /&gt;
      host_name                       ubuntu_host&lt;br /&gt;
      service_description             Local Disk&lt;br /&gt;
      check_command                   check_local_disk!20%!10%!/&lt;br /&gt;
      max_check_attempts              2&lt;br /&gt;
      check_interval                  2&lt;br /&gt;
      retry_interval                  2&lt;br /&gt;
      check_period                    24x7&lt;br /&gt;
      check_freshness                 1&lt;br /&gt;
      contact_groups                  admins&lt;br /&gt;
      notification_interval           2&lt;br /&gt;
      notification_period             24x7&lt;br /&gt;
      notifications_enabled           1&lt;br /&gt;
      register                        1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
define service {&lt;br /&gt;
      host_name                       ubuntu_host&lt;br /&gt;
      service_description             Check SSH&lt;br /&gt;
      check_command                   check_ssh&lt;br /&gt;
      max_check_attempts              2&lt;br /&gt;
      check_interval                  2&lt;br /&gt;
      retry_interval                  2&lt;br /&gt;
      check_period                    24x7&lt;br /&gt;
      check_freshness                 1&lt;br /&gt;
      contact_groups                  admins&lt;br /&gt;
      notification_interval           2&lt;br /&gt;
      notification_period             24x7&lt;br /&gt;
      notifications_enabled           1&lt;br /&gt;
      register                        1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
define service {&lt;br /&gt;
      host_name                       ubuntu_host&lt;br /&gt;
      service_description             Total Process&lt;br /&gt;
      check_command                   check_local_procs!250!400!RSZDT&lt;br /&gt;
      max_check_attempts              2&lt;br /&gt;
      check_interval                  2&lt;br /&gt;
      retry_interval                  2&lt;br /&gt;
      check_period                    24x7&lt;br /&gt;
      check_freshness                 1&lt;br /&gt;
      contact_groups                  admins&lt;br /&gt;
      notification_interval           2&lt;br /&gt;
      notification_period             24x7&lt;br /&gt;
      notifications_enabled           1&lt;br /&gt;
      register                        1&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can find many check_command in /usr/local/nagios/etc/objects/commands.cfg file. See there if you want to add more services like DHCP, POP etc.&lt;br /&gt;
&lt;br /&gt;
And now check the configuration:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
... to see if the configuration is correct.&lt;br /&gt;
&lt;br /&gt;
[[File:Nagios_check.png|thumb|center|Nagios check]]&lt;br /&gt;
&lt;br /&gt;
===Restart all services===&lt;br /&gt;
&lt;br /&gt;
On the Ubuntu Host start NRPE Service:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo service nagios-nrpe-server restart&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And on the Nagios server, start Apache and Nagios:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo service apache2 restart&lt;br /&gt;
&lt;br /&gt;
sudo service nagios restart&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Testing the Ubuntu Host =&lt;br /&gt;
&lt;br /&gt;
Open the Nagios server from the browser and see the ubuntu_host being monitored.&lt;br /&gt;
&lt;br /&gt;
The Ubuntu host is available on monitored host.&lt;br /&gt;
&lt;br /&gt;
[[File:Nagios.png|thumb|center|Nagios Testing Host]]&lt;br /&gt;
&lt;br /&gt;
All services monitored without error.&lt;br /&gt;
&lt;br /&gt;
[[File:Nagios ubuntu.png|thumb|center|Nagios Testing Host]]&lt;br /&gt;
&lt;br /&gt;
= Summary =&lt;br /&gt;
&lt;br /&gt;
= Reference =&lt;br /&gt;
&lt;br /&gt;
1- [https://www.howtoforge.com/tutorial/ubuntu-nagios/ Nagios Installation]&lt;br /&gt;
&lt;br /&gt;
2- [https://www.linode.com/docs/uptime/monitoring/install-nagios-4-on-ubuntu-debian-8 Nagios tutorial]&lt;br /&gt;
&lt;br /&gt;
3- [https://www.digitalocean.com/community/tutorials/how-to-install-nagios-4-and-monitor-your-servers-on-ubuntu-14-04 Install Nagios and monitor your servers on ubuntu]&lt;br /&gt;
&lt;br /&gt;
4- [https://blog.serverdensity.com/howto-install-nagios-in-30-minutes-and-jumpstart-your-monitoring/ Nagios in 30 minutes and jumpstart your monitoring]&lt;br /&gt;
&lt;br /&gt;
5- [https://nagios-plugins.org/doc/guidelines.html Nagios Plugins]&lt;br /&gt;
&lt;br /&gt;
6- [http://www.monitance.com/en/product-news/what-is-server-monitoring-and-why-is-it-important/ Introduction Monitoring ]&lt;br /&gt;
&lt;br /&gt;
7- [https://www.nagios.org/about/overview/ Introduction Nagios ]&lt;br /&gt;
 &lt;br /&gt;
------&lt;br /&gt;
&lt;br /&gt;
[[Category:Monitoring]]&lt;/div&gt;</summary>
		<author><name>Ishustov</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Monitoring_Nagios&amp;diff=114674</id>
		<title>Monitoring Nagios</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Monitoring_Nagios&amp;diff=114674"/>
		<updated>2016-11-14T13:31:21Z</updated>

		<summary type="html">&lt;p&gt;Ishustov: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Team: &lt;br /&gt;
Ilja Shustov,&lt;br /&gt;
Sheela Raj &lt;br /&gt;
&lt;br /&gt;
Group : Cyber Security Engineering (C21)&lt;br /&gt;
&lt;br /&gt;
Page Created: 10 November 2016&lt;br /&gt;
&lt;br /&gt;
‎Last modified: 12 November 2016&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
In this article, we will cover the installation of &#039;&#039;&#039;Nagios&#039;&#039;&#039;, a very popular open source monitoring system, on Ubuntu. We will cover some basic configuration, so you will be able to monitor host resources via the web interface. We will also utilize the Nagios Remote Plugin Executor (NRPE), that will be installed as an agent on remote hosts, to monitor their local resources.&lt;br /&gt;
&lt;br /&gt;
===Monitoring===&lt;br /&gt;
&lt;br /&gt;
Server monitoring is basically a preventative measure to help you detect any issues before they cause any major issues that affect your productivity and your customer.&lt;br /&gt;
&lt;br /&gt;
Server monitoring is a process of continuously scanning servers on a designated network and scans the network for any failures or any irregularities that are detected by server monitoring software.&lt;br /&gt;
&lt;br /&gt;
===Why monitoring is important?===&lt;br /&gt;
Any network crashes costs time and money to fix.  At a time of downtime that is already costing your business money and hurting your reputation, it will be difficult to have to fork out more cash to get things back up and running again.  Server monitoring is important so that you can pick up any small issues before they evolve into anything major.  Server monitoring is essential in ensuring service availability.&lt;br /&gt;
&lt;br /&gt;
===Nagios===&lt;br /&gt;
Nagios is a free and open source computer-software application that monitors systems, networks and infrastructure. Nagios offers monitoring and alerting services for servers, switches, applications and services. It alerts users when things go wrong and alerts them a second time when the problem has been resolved.&lt;br /&gt;
&lt;br /&gt;
By using Nagios, you can:&lt;br /&gt;
&lt;br /&gt;
*Plan for infrastructure upgrades before outdated systems cause failures&lt;br /&gt;
*Respond to issues at the first sign of a problem&lt;br /&gt;
*Automatically fix problems when they are detected&lt;br /&gt;
*Coordinate technical team responses&lt;br /&gt;
*Ensure your organization’s SLAs are being met&lt;br /&gt;
*Ensure IT infrastructure outages have a minimal effect on your organization’s bottom line&lt;br /&gt;
*Monitor your entire infrastructure and business processes&lt;br /&gt;
&lt;br /&gt;
= Before You Begin =&lt;br /&gt;
===Check your current Ubuntu version &amp;amp; Upgrade===&lt;br /&gt;
&lt;br /&gt;
You can check your current ubuntu version by the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;lsb_release -a&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If your machine is already running Ubuntu 16.04.1 LTS or higher than that, There is no need for you to upgrade the OS.&lt;br /&gt;
&lt;br /&gt;
Otherwise you need to upgrade the OS by the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get update &amp;amp;&amp;amp; sudo apt-get upgrade&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039;&lt;br /&gt;
This article is written for a non-root user. Commands that require elevated privileges are prefixed with &amp;lt;code&amp;gt;sudo&amp;lt;/code&amp;gt;. If you’re not familiar with the &amp;lt;code&amp;gt;sudo&amp;lt;/code&amp;gt; command, you can check the [https://www.linode.com/docs/tools-reference/linux-users-and-groups Users and Groups] guide.&lt;br /&gt;
&lt;br /&gt;
===Install the required package===&lt;br /&gt;
&lt;br /&gt;
As a prerequisite, Nagios requires the gcc compiler and build-essentials for the compilation, LAMP (Apache, PHP, MySQL) for the Nagios web interface and Sendmail to send alerts from the server. &lt;br /&gt;
&lt;br /&gt;
To install all those packages, run the following command (it&#039;s just 1 line):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install wget build-essential apache2 php apache2-mod-php7.0 php-gd libgd-dev sendmail unzip&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Create Users and Groups===&lt;br /&gt;
&lt;br /&gt;
Create a user &#039;&#039;&#039;nagios&#039;&#039;&#039;, and a distinct group &#039;&#039;&#039;nagcmd&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Add &#039;&#039;&#039;nagios&#039;&#039;&#039; and the Apache user &#039;&#039;&#039;www-data&#039;&#039;&#039;, to the &#039;&#039;&#039;nagcmd&#039;&#039;&#039; group in order to run external commands on Nagios through the web interface&lt;br /&gt;
&lt;br /&gt;
Use the following command to create:&lt;br /&gt;
&lt;br /&gt;
To create user:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo useradd nagios&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To create group:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo groupadd nagcmd&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To add user to the group:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo usermod -a -G nagcmd nagios &amp;amp;&amp;amp; sudo usermod -a -G nagcmd www-data&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Installing Nagios =&lt;br /&gt;
&lt;br /&gt;
===Download and extract Nagios===&lt;br /&gt;
&lt;br /&gt;
In your web browser, go to the [https://www.nagios.org/downloads/core-stay-informed/ Nagios Core DIY download page].It will ask you to register, If you prefer not to register for updates, click Skip to download.&lt;br /&gt;
&lt;br /&gt;
Under Nagios Core, find the release that says Latest stable release under Notes, then copy the download link to your clipboard.&lt;br /&gt;
&lt;br /&gt;
Now using &amp;lt;code&amp;gt;wget&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;tar&amp;lt;/code&amp;gt;, download the Nagios and extract it.&lt;br /&gt;
&lt;br /&gt;
To download, paste the copied link after &amp;lt;code&amp;gt;wget&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.2.0.tar.gz &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Command to extract:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;tar -xzf nagios*.tar.gz&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now move to the newly created directory, by using the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;cd nagios-4.2.0&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Compile Nagios===&lt;br /&gt;
&lt;br /&gt;
Before you build Nagios, you will have to configure it with the user and the group you have created earlier.&lt;br /&gt;
&lt;br /&gt;
command to configure:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;./configure --with-nagios-group=nagios --with-command-group=nagcmd&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For more information please use: &amp;lt;code&amp;gt;./configure --help&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now compile Nagios with this command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;make all&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===To install Nagios===&lt;br /&gt;
&lt;br /&gt;
Now we can run these make commands to install &#039;&#039;&#039;Nagios&#039;&#039;&#039;, init scripts, and sample configuration files:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo make install &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo make install-commandmode &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo make install-init &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo make install-config &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; /usr/bin/install -c -m 644 sample-config/httpd.conf /etc/apache2/sites-available/nagios.conf &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And copy evenhandler directory to the nagios directory:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo cp -R contrib/eventhandlers/ /usr/local/nagios/libexec/ &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo chown -R nagios:nagios /usr/local/nagios/libexec/eventhandlers &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Nagios Plugins =&lt;br /&gt;
&lt;br /&gt;
Nagios Plugins allow you to monitor services like DHCP, FTP, HTTP and NTP.&lt;br /&gt;
&lt;br /&gt;
===Download and extract the Nagios plugins===&lt;br /&gt;
&lt;br /&gt;
To use Nagios Plugins, go to [https://nagios-plugins.org/downloads/ Nagios Plugins downloads] page and copy the download link for the current stable release.&lt;br /&gt;
&lt;br /&gt;
Now using &amp;lt;code&amp;gt;wget&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;tar&amp;lt;/code&amp;gt;, download and extract &#039;&#039;&#039;Nagios plugin&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Use the following command to move back into user&#039;s home directory:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;cd ~&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To download, paste the copied link after &amp;lt;code&amp;gt;wget&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;wget https://nagios-plugins.org/download/nagios-plugins-2.1.2.tar.gz&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Command to extract:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;tar -xzf nagios-plugins*.tar.gz&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now Change to the newly created directory by the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;cd nagios-plugins-2.1.2/&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Install Nagios plugins===&lt;br /&gt;
&lt;br /&gt;
Install the Nagios plugin&#039;s with the following commands:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;./configure --with-nagios-user=nagios --with-nagios-group=nagios --with-openssl&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo make install&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Configure Nagios =&lt;br /&gt;
&lt;br /&gt;
Now let&#039;s perform the initial Nagios configuration.&lt;br /&gt;
&lt;br /&gt;
===Organize Nagios Configuration===&lt;br /&gt;
&lt;br /&gt;
Open the main Nagios configuration file in your favorite text editor(vim/nano). &lt;br /&gt;
&lt;br /&gt;
We&#039;ll use nano to edit the file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo nano /usr/local/nagios/etc/nagios.cfg&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now find and uncomment the following line by deleting the #:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;#cfg_dir=/usr/local/nagios/etc/servers&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
Now create the directory named &#039;&#039;&#039;servers&#039;&#039;&#039; that will store the configuration file for each server that you will monitor:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo mkdir /usr/local/nagios/etc/servers&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Change the user and group for the new folder to nagios:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo chown nagios:nagios /usr/local/nagios/etc/servers&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Nagios3.png|thumb|right|Nagios Email]]&lt;br /&gt;
&lt;br /&gt;
===Configure Nagios Contacts===&lt;br /&gt;
&lt;br /&gt;
Open the Nagios contacts configuration in your favorite text editor(nano/vim).&lt;br /&gt;
&lt;br /&gt;
We&#039;ll use nano to edit the file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo nano /usr/local/nagios/etc/objects/contacts.cfg&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Find the email directive, and replace its value with your own email address&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
= Configuring Apache =&lt;br /&gt;
&lt;br /&gt;
===Enable Apache modules===&lt;br /&gt;
&lt;br /&gt;
Make sure Apache has &amp;lt;code&amp;gt;mod_rewrite&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;mod_cgi&amp;lt;/code&amp;gt; enabled&lt;br /&gt;
&lt;br /&gt;
Enable the Apache rewrite and cgi modules by the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo a2enmod rewrite &amp;amp;&amp;amp; sudo a2enmod cgi&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can use the &amp;lt;code&amp;gt;htpasswd&amp;lt;/code&amp;gt; command to configure a user &#039;&#039;nagiosadmin&#039;&#039; for the nagios web interface&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and type your password.&lt;br /&gt;
&lt;br /&gt;
===Enable the Nagios virtualhost===&lt;br /&gt;
&lt;br /&gt;
You can enable Nagios Virtualhost by the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo ln -s /etc/apache2/sites-available/nagios.conf /etc/apache2/sites-enabled/&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Start Apache and Nagios===&lt;br /&gt;
&lt;br /&gt;
Start the Apache and Nagios by the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo service apache2 restart&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo service nagios start&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When Nagios starts, you may see the following error :&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Starting nagios (via systemctl): nagios.serviceFailed&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
And you can fix it by:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;cd /etc/init.d/&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo cp /etc/init.d/skeleton /etc/init.d/nagios&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now edit the Nagios file by the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo nano /etc/init.d/nagios&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And add the following code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
DESC=&amp;quot;Nagios&amp;quot;&lt;br /&gt;
&lt;br /&gt;
NAME=nagios&lt;br /&gt;
&lt;br /&gt;
DAEMON=/usr/local/nagios/bin/$NAME&lt;br /&gt;
&lt;br /&gt;
DAEMON_ARGS=&amp;quot;-d /usr/local/nagios/etc/nagios.cfg&amp;quot;&lt;br /&gt;
&lt;br /&gt;
PIDFILE=/usr/local/nagios/var/$NAME.lock&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make it executable, restart apache2 and start Nagios:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo chmod +x /etc/init.d/nagios&lt;br /&gt;
&lt;br /&gt;
sudo service apache2 restart&lt;br /&gt;
&lt;br /&gt;
sudo servuce nagios start&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Testing the Nagios Server =&lt;br /&gt;
&lt;br /&gt;
Open your favorite web browser, and go to your Nagios server (substitute the IP address or hostname)&lt;br /&gt;
&lt;br /&gt;
(in my case: http://192.168.56.200/nagios).&lt;br /&gt;
&lt;br /&gt;
Because we configured Apache to use htpasswd, you must enter the login credentials that you created earlier.&lt;br /&gt;
&lt;br /&gt;
We used &amp;quot;nagiosadmin&amp;quot; as the username:&lt;br /&gt;
&lt;br /&gt;
[[File:Htpasswd_prompt.png|thumb|center|Nagios Authentication page]]&lt;br /&gt;
&lt;br /&gt;
After authenticating, you will be see the default Nagios home page: &lt;br /&gt;
&lt;br /&gt;
[[File:Nagios_adminpage.png|thumb|center|Nagios Homepage]]&lt;br /&gt;
&lt;br /&gt;
In the Homepage, click on the Hosts link, in the left navigation bar, to see which hosts Nagios is monitoring:&lt;br /&gt;
&lt;br /&gt;
[[File:Hosts_link.png|thumb|center|Nagios Hostpage]]&lt;br /&gt;
&lt;br /&gt;
As you can see, Nagios is monitoring only &amp;quot;localhost&amp;quot;, or itself.&lt;br /&gt;
&lt;br /&gt;
Let&#039;s monitor another host with Nagios!&lt;br /&gt;
&lt;br /&gt;
= Adding a Host to Monitor =&lt;br /&gt;
&lt;br /&gt;
In this section, you can see how to add a ubuntu host to Nagios server, so it will be monitored.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Note: Here replace the IP with your Nagios server IP and Ubuntu Host IP&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
In my case:&lt;br /&gt;
&lt;br /&gt;
Nagios Server IP : 192.168.56.200 &lt;br /&gt;
&lt;br /&gt;
Ubuntu Host IP : 192.168.56.100&lt;br /&gt;
&lt;br /&gt;
===Connect to ubuntu host===&lt;br /&gt;
&lt;br /&gt;
You can connect to Ubuntu host by using &#039;&#039;ssh&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you are not familiar with ssh use this [http://www.makeuseof.com/tag/beginners-guide-setting-ssh-linux-testing-setup/ Beginner’s Guide To Setting Up SSH On Linux]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;ssh student@192.168.56.100&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Install NRPE Service===&lt;br /&gt;
&lt;br /&gt;
Now install Nagios Plugins and NRPE by following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install nagios-nrpe-server nagios-plugins&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Configure NRPE===&lt;br /&gt;
&lt;br /&gt;
Now, let&#039;s update the NRPE configuration file.&lt;br /&gt;
&lt;br /&gt;
Open it in your favorite editor (we&#039;re using nano):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;nano /etc/nagios/nrpe.cfg&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Find the &#039;&#039;server_address&#039;&#039; directive, and add the private IP address of your Nagios server&lt;br /&gt;
&lt;br /&gt;
In my case:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;server_address=192.168.56.200&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
[[File:5.png|thumb|center|Configure NRPE]]&lt;br /&gt;
&lt;br /&gt;
===Restart NRPE===&lt;br /&gt;
&lt;br /&gt;
Restart NRPE by following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo service nagios-nrpe-server restart&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Add Ubuntu Host to Nagios Server===&lt;br /&gt;
&lt;br /&gt;
connect to the Nagios server:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;ssh student@192.168.56.200&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then create a new file for the host configuration in &#039;&#039;/usr/local/nagios/etc/servers/&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;nano /usr/local/nagios/etc/servers/ubuntu_host.cfg&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add the following lines:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Ubuntu Host configuration file&lt;br /&gt;
&lt;br /&gt;
define host {&lt;br /&gt;
        use                          linux-server&lt;br /&gt;
        host_name                    ubuntu_host&lt;br /&gt;
        alias                        Ubuntu Host&lt;br /&gt;
        address                      192.168.1.10&lt;br /&gt;
        register                     1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
define service {&lt;br /&gt;
      host_name                       ubuntu_host&lt;br /&gt;
      service_description             PING&lt;br /&gt;
      check_command                   check_ping!100.0,20%!500.0,60%&lt;br /&gt;
      max_check_attempts              2&lt;br /&gt;
      check_interval                  2&lt;br /&gt;
      retry_interval                  2&lt;br /&gt;
      check_period                    24x7&lt;br /&gt;
      check_freshness                 1&lt;br /&gt;
      contact_groups                  admins&lt;br /&gt;
      notification_interval           2&lt;br /&gt;
      notification_period             24x7&lt;br /&gt;
      notifications_enabled           1&lt;br /&gt;
      register                        1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
define service {&lt;br /&gt;
      host_name                       ubuntu_host&lt;br /&gt;
      service_description             Check Users&lt;br /&gt;
      check_command           check_local_users!20!50&lt;br /&gt;
      max_check_attempts              2&lt;br /&gt;
      check_interval                  2&lt;br /&gt;
      retry_interval                  2&lt;br /&gt;
      check_period                    24x7&lt;br /&gt;
      check_freshness                 1&lt;br /&gt;
      contact_groups                  admins&lt;br /&gt;
      notification_interval           2&lt;br /&gt;
      notification_period             24x7&lt;br /&gt;
      notifications_enabled           1&lt;br /&gt;
      register                        1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
define service {&lt;br /&gt;
      host_name                       ubuntu_host&lt;br /&gt;
      service_description             Local Disk&lt;br /&gt;
      check_command                   check_local_disk!20%!10%!/&lt;br /&gt;
      max_check_attempts              2&lt;br /&gt;
      check_interval                  2&lt;br /&gt;
      retry_interval                  2&lt;br /&gt;
      check_period                    24x7&lt;br /&gt;
      check_freshness                 1&lt;br /&gt;
      contact_groups                  admins&lt;br /&gt;
      notification_interval           2&lt;br /&gt;
      notification_period             24x7&lt;br /&gt;
      notifications_enabled           1&lt;br /&gt;
      register                        1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
define service {&lt;br /&gt;
      host_name                       ubuntu_host&lt;br /&gt;
      service_description             Check SSH&lt;br /&gt;
      check_command                   check_ssh&lt;br /&gt;
      max_check_attempts              2&lt;br /&gt;
      check_interval                  2&lt;br /&gt;
      retry_interval                  2&lt;br /&gt;
      check_period                    24x7&lt;br /&gt;
      check_freshness                 1&lt;br /&gt;
      contact_groups                  admins&lt;br /&gt;
      notification_interval           2&lt;br /&gt;
      notification_period             24x7&lt;br /&gt;
      notifications_enabled           1&lt;br /&gt;
      register                        1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
define service {&lt;br /&gt;
      host_name                       ubuntu_host&lt;br /&gt;
      service_description             Total Process&lt;br /&gt;
      check_command                   check_local_procs!250!400!RSZDT&lt;br /&gt;
      max_check_attempts              2&lt;br /&gt;
      check_interval                  2&lt;br /&gt;
      retry_interval                  2&lt;br /&gt;
      check_period                    24x7&lt;br /&gt;
      check_freshness                 1&lt;br /&gt;
      contact_groups                  admins&lt;br /&gt;
      notification_interval           2&lt;br /&gt;
      notification_period             24x7&lt;br /&gt;
      notifications_enabled           1&lt;br /&gt;
      register                        1&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can find many check_command in /usr/local/nagios/etc/objects/commands.cfg file. See there if you want to add more services like DHCP, POP etc.&lt;br /&gt;
&lt;br /&gt;
And now check the configuration:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
... to see if the configuration is correct.&lt;br /&gt;
&lt;br /&gt;
[[File:Nagios_check.png|thumb|center|Nagios check]]&lt;br /&gt;
&lt;br /&gt;
===Restart all services===&lt;br /&gt;
&lt;br /&gt;
On the Ubuntu Host start NRPE Service:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo service nagios-nrpe-server restart&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And on the Nagios server, start Apache and Nagios:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo service apache2 restart&lt;br /&gt;
&lt;br /&gt;
sudo service nagios restart&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Testing the Ubuntu Host =&lt;br /&gt;
&lt;br /&gt;
Open the Nagios server from the browser and see the ubuntu_host being monitored.&lt;br /&gt;
&lt;br /&gt;
The Ubuntu host is available on monitored host.&lt;br /&gt;
&lt;br /&gt;
[[File:Nagios.png|thumb|center|Nagios Testing Host]]&lt;br /&gt;
&lt;br /&gt;
All services monitored without error.&lt;br /&gt;
&lt;br /&gt;
[[File:Nagios ubuntu.png|thumb|center|Nagios Testing Host]]&lt;br /&gt;
&lt;br /&gt;
= Summary =&lt;br /&gt;
&lt;br /&gt;
= Reference =&lt;br /&gt;
&lt;br /&gt;
1- [https://www.howtoforge.com/tutorial/ubuntu-nagios/ Nagios Installation]&lt;br /&gt;
&lt;br /&gt;
2- [https://www.linode.com/docs/uptime/monitoring/install-nagios-4-on-ubuntu-debian-8 Nagios tutorial]&lt;br /&gt;
&lt;br /&gt;
3- [https://www.digitalocean.com/community/tutorials/how-to-install-nagios-4-and-monitor-your-servers-on-ubuntu-14-04 Install Nagios and monitor your servers on ubuntu]&lt;br /&gt;
&lt;br /&gt;
4- [https://blog.serverdensity.com/howto-install-nagios-in-30-minutes-and-jumpstart-your-monitoring/ Nagios in 30 minutes and jumpstart your monitoring]&lt;br /&gt;
&lt;br /&gt;
5- [https://nagios-plugins.org/doc/guidelines.html Nagios Plugins]&lt;br /&gt;
&lt;br /&gt;
------&lt;br /&gt;
&lt;br /&gt;
[[Category:Monitoring]]&lt;/div&gt;</summary>
		<author><name>Ishustov</name></author>
	</entry>
</feed>