Professional Documents
Culture Documents
Scenario
In this tutorial i am going to use two systems as mentioned below.
Nagios server:
Operating system : Ubuntu 14.10 Server
IP Address
: 192.168.1.150/24
Nagios client:
Operating System : Ubuntu 14.04 Server
IP Address
: 192.168.1.250/24
Prerequisites
Make sure your server have installed with fully working LAMP stack. If not, follow the below link to
install LAMP server.
Install LAMP Server On Ubuntu 14.10/14.04
Create a new nagcmd group for allowing external commands to be submitted through the web
interface. Add both the nagios user and the apache user to the group.
sudo groupadd nagcmd
sudo usermod -a -G nagcmd nagios
sudo usermod -a -G nagcmd www-data
Go to the folder where youve downloaded nagios, and extract it using command:
tar xzf nagios-4.0.8.tar.gz
Change to the nagios directory, and run the following commands one by one from the Terminal to
compile and install nagios.
cd nagios-4.0.8
sudo ./configure --with-command-group=nagcmd
sudo make all
sudo make install
sudo make install-init
sudo make install-config
Enter the following commands to compile and install nagios web interface.
sudo make install-webconf
The above error message describes that nagios is trying to create the nagios.conf file inside the
/etc/httpd.conf/ directory. But, in Ubuntu systems the nagios.conf file should be placed in
/etc/apache2/sites-enabled/ directory.
So, run the following command instead of using sudo make install-webconf.
sudo /usr/bin/install
enabled/nagios.conf
-c
-m
644
sample-config/httpd.conf
/etc/apache2/sites-
Sample output:
total 4
lrwxrwxrwx 1 root root 35 Dec 17 17:59 000-default.conf -> ../sites-available/000default.conf
-rw-r--r-- 1 root root 982 Dec 17 19:01 nagios.conf
Create a nagiosadmin account for logging into the Nagios web interface. Remember the password you
assign to this account. Youll need it while logging in to nagios web interface..
sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
Go to the directory where you downloaded the nagios plugins, and extract it.
tar xzf nagios-plugins-2.0.3.tar.gz
Run the following commands one by one to compile and install it.
sudo ./configure --with-nagios-user=nagios --with-nagios-group=nagios
sudo make
sudo make install
Configure Nagios
Nagios sample configuration files have now been installed in the /usr/local/nagios/etc directory. These
sample files should work fine for getting started with Nagios. However, youll need to put your actual
email ID to receive alerts.
To do that, Edit the /usr/local/nagios/etc/objects/contacts.cfg config file with your favorite editor and
change the email address associated with the nagiosadmin contact definition to the address youd like
to use for receiving alerts.
sudo nano /usr/local/nagios/etc/objects/contacts.cfg
sk@unixmen.com
; Short name of
; Inherit default
; Full name of user
; <<***** CHANGE THIS TO
And edit the following lines if you want to access nagios administrative console from a particular IP
series. Here, I want to allow nagios administrative access from 192.168.1.0/24 series only.
[...]
## Comment the following lines ##
#
Order allow,deny
#
Allow from all
## Uncomment and Change lines as shown below ##
Order deny,allow
Deny from all
If there are no errors, start nagios service and make it to start automatically on every boot.
sudo service nagios start
sudo ln -s /etc/init.d/nagios /etc/rcS.d/S99nagios
Click on the Hosts section in the left pane of the console. You will see there the no of hosts to be
monitored by Nagios server. We havent added any hosts yet. So it simply monitors the localhost itself
only.
Add EPEL repository in your CentOS/RHEL/Scientific Linux 6.x or 7 clients to install nrpe package.
To install EPEL on CentOS 7, run the following command:
yum install epel-release
CentOS 6.x:
service nrpe start
chkconfig nrpe on
Now, go back to your Nagios server, and add the clients in the configuration file.
To do that, Edit /usr/local/nagios/etc/nagios.cfg file,
sudo nano /usr/local/nagios/etc/nagios.cfg
linux-server
host_name
client
alias
client
address
192.168.1.250
max_check_attempts
check_period
24x7
notification_interval
30
notification_period
24x7
Wait for few seconds, and refresh nagios admin console in the browser and navigate to Hosts section
in the left pane. You will see the newly added client will be visible there. Click on the host to see if
there is anything wrong or any alerts it has.
creating
separate
config
files
Define services
We have just defined the monitoring host. Now, let us add some services of the monitoring host. For
example, to monitor the ssh service, add the following lines shown in bold in the
/usr/local/nagios/etc/servers/clients.cfg file.
sudo nano /usr/local/nagios/etc/servers/clients.cfg
linux-server
host_name
client
alias
client
address
192.168.1.250
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
client
SSH
check_ssh
0
Wait for few seconds, and check for the added services (i.e ssh) in the nagios web interface. Navigate to
Services section on the left side bar, youll see the ssh service there.
To know more about object definitions such as Host definitions, service definitions, contact definitions,
please do visit here. This page will explain you the description and format of all object definitions.
Additional Tip:
If youre trying to use check_http with the -S flag (for https), this guide misses a big step.
Make sure you install openssl and libssl-dev first. And yes, even if your Nagios server is checking a
I would like to thank our Unixmen reader for this useful tip.
Thats it. Cheers!
Reference
SK
Senthilkumar, aka SK, is a Linux enthusiast, FOSS Supporter & Linux Consultant from Tamilnadu,
India. A passionate and dynamic person, aims to deliver quality content to IT professionals. He loves
very much to write and explore new things about Linux, Open Source, Computers and Internet.
Recommended for you
nagiosNetwork Monitoring ToolsFrequently Asked QuestionsLinux Mint
How To Send Alerts From Nagios Core Using Gmail And Yahoo
Nagios Xi: How To Monitor Your Linux Server Using NRPE Agent
Nagios Auto Install Script For Fedora 19/20, And CentOS 6/7
Donate to Unixmen
Unixmen.com
Object 2
Object 3
Advestise here ?
Install LAMP Server (Apache, MySQL, PHP) On RHEL, CentOS, Scientific Linux 6.5/6.4
8
44827
Ifconfig Command Not Found In CentOS 7 Minimal Installation ...
9
36842
Install lamp with 1 command in Ubuntu 12.10, 13.04 Raring Ringtail & LinuxMint13
10
35869
Setup Local Mail Server Using Postfix, Dovecot And Squirrelmail On CentOS 6.5/6.4
Copyright 2015 Unixmen, All Rights Reserved.
Website Design and Maintained by Unixmen.
Object 4
Object 6
Object 5