http://www.unixmen.com/install-configure-nagios-ubuntu-14-04-lts/
Nagios is an open source software that can be used for network and infrastructure
monitoring. Nagios will monitor servers, switches, applications and services. It alerts the
System Administrator when something goes wrong and also alerts back when the issues
has been rectified.
Using Nagios, you can:
Scenario
In this tutorial i am going to use two systems as mentioned below.
Nagios server:
Operating system : Ubuntu 14.04 LTS Server
IP Address
: 192.168.1.250/24
Nagios client:
Operating System : Ubuntu 14.04 Desktop
IP Address
: 192.168.1.100/24
Prerequisites
Make sure your server have installed with fully working LAMP stack. If not, follow the
below link to install LAMP server On Ubuntu 14.04 and earlier versions.
Install Nagios
Install nagios and nagios plugin using the following command:
sudo apt-get install nagios3 nagios-nrpe-plugin
During installation, youll have to answer some simple questions. First, youll be asked to
configure your mail server to get alerts from your nagios server.
Enter the system mail name. It will be automatically selected by the installer. If not,
enter it manually.
Configure Nagios
After
nagios
and
data directory
to
nagios
plugins
nagios
installation,
user,
and
assign
set
the
permissions
executable
of www-
permission
to
Click on the Hosts section on the left pane to list of hosts being monitored.
If you want to see the complete details of a monitoring hosts, click on the respective
monitoring hosts in the above window.
As you see in the above picture, the localhost(Nagios server) itself only is being
monitored by default. We have to add the clients to monitor them now.
Now let us add some clients to monitor by Nagios server. To do that we have to
install nrpe and nagios-pluginspackages in our monitoring targets.
sudo apt-get install nagios-nrpe-server nagios-plugins
By
default,
Debian
based
systems
uses
configuration
directory
use
generic-host
host_name
alias
sk
sk
address
192.168.1.100
max_check_attempts
check_period
24x7
notification_interval
30
notification_period
24x7
}
Save and close the file.
Here, sk is my Ubuntu 14.04 client host name, and 192.168.1.100 is the IP address of
my client.
Restart nagios service.
sudo /etc/init.d/nagios3 restart
Now, open the nagios web console again in the browser and navigate to Hosts section
in the left pane. You should see the newly added client will be visible there. Click on the
host to see if there is anything wrong or alerts. Please note that you have to wait 90
seconds after any changes in your nagios server.
Like
this
way,
you
can
define
more
clients
Define services
by
creating
separate
config
We have defined the monitoring host before. Now let us add some services of the
monitoring host. For example, to monitor the ssh service, add the following lines shown
in red colour in the /etc/nagios3/servers/clients.cfg file.
sudo nano /etc/nagios3/servers/clients.cfg
Add the lines shown in red color:
define host{
use
generic-host
host_name
alias
sk
sk
address
192.168.1.100
max_check_attempts
check_period
24x7
notification_interval
30
notification_period
24x7
}
define service {
use
host_name
service_description
check_command
notifications_enabled
}
generic-service
sk
SSH
check_ssh
0
To know more about object definitions such as Host definitions, service definitions,
contact definitions and more please do visit here. This page will describe you the
description and format of all nagios object definitions.
Thats it. Happy Monitoring with Nagios!
Reference Links:
Nagios Homepage