0% found this document useful (0 votes)
269 views36 pages

Nagios Is One of The Most Popular Open Source Monitoring Systems

Nagios is an open source monitoring system that keeps an inventory of your IT infrastructure and ensures components are working properly. This tutorial describes how to install the latest version of Nagios Core from source on a CentOS 7 server. The steps include: downloading and extracting the Nagios source code; compiling Nagios; creating a nagios user and group; installing Nagios binaries, configuration files, and the Apache configuration; installing Nagios plugins; and accessing the Nagios web interface.

Uploaded by

badhonctg
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
269 views36 pages

Nagios Is One of The Most Popular Open Source Monitoring Systems

Nagios is an open source monitoring system that keeps an inventory of your IT infrastructure and ensures components are working properly. This tutorial describes how to install the latest version of Nagios Core from source on a CentOS 7 server. The steps include: downloading and extracting the Nagios source code; compiling Nagios; creating a nagios user and group; installing Nagios binaries, configuration files, and the Apache configuration; installing Nagios plugins; and accessing the Nagios web interface.

Uploaded by

badhonctg
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 36

Nagios is one of the most popular open source monitoring systems.

Nagios
keeps an inventory of your entire IT infrastructure and ensures your networks,
servers, applications, services, and processes are up and running. In case of
failure or suboptimal performance Nagios will send notification alerts via
various methods.

This tutorial describes how to install and configure Nagios Core on a CentOS 7
server.

Prerequisites
Before continuing with this tutorial, make sure you are logged in as a user with
sudo privileges.

Disable SELinux or set in permissive mode as instructed here.

Update your CentOS system and install Apache, PHP and all the packages
necessary to download and compile the Nagios main application and Nagios
plugins:
sudo yum updatesudo yum install httpd php php-cli gcc glibc glibc-common gd gd-devel
net-snmp openssl-devel wgetsudo yum install make gettext autoconf net-snmp-utils
epel-release perl-Net-SNMP postfix unzip automake
Copy

Installing Nagios on CentOS


Perform the following steps to install the latest version of Nagios Core from
source.

1. Downloading Nagios

We’ll download Nagios source in the /usr/src directory which is the common
location to place source files.

Navigate to the directory with:


cd /usr/src/
Copy
Download the latest version of Nagios from the project Github
repository using the following wget command:

sudo wget https://github.com/NagiosEnterprises/nagioscore/archive/nagios-4.4.2.tar.gz


Copy

Once the download is complete extract the tar file with:

sudo tar zxf nagios-*.tar.gz


Copy

Before continuing with the next steps, make sure you change to the Nagios
source directory by typing:
cd nagioscore-nagios-*/
Copy

2. Compiling Nagios

To start the build process run the configure script which will perform a number
of checks to make sure all of the dependencies on your system are present:
sudo ./configure
Copy

Upon successful completion, the following message will be printed on your


screen:

*** Configuration summary for nagios 4.4.2 2018-08-16 ***:

General Options:
-------------------------
Nagios executable: nagios
Nagios user/group: nagios,nagios
Command user/group: nagios,nagios
Event Broker: yes
Install ${prefix}: /usr/local/nagios
Install ${includedir}: /usr/local/nagios/include/nagios
Lock file: /run/nagios.lock
Check result directory: /usr/local/nagios/var/spool/checkresults
Init directory: /lib/systemd/system
Apache conf.d directory: /etc/httpd/conf.d
Mail program: /sbin/sendmail
Host OS: linux-gnu
IOBroker Method: epoll
Web Interface Options:
------------------------
HTML URL: http://localhost/nagios/
CGI URL: http://localhost/nagios/cgi-bin/
Traceroute (used by WAP): /bin/traceroute

Review the options above for accuracy. If they look okay,


type 'make all' to compile the main program and CGIs.
Copy

Start the compilation process using the make command:

sudo make all


Copy

The compilation may take some time, depending on your system. Once the
build process is completed, the following message will be printed on your
screen:
....
*** Compile finished ***
...
For more information on obtaining support for Nagios, visit:

https://support.nagios.com

*************************************************************

Enjoy.
Copy

3. Creating Nagios User And Group

Create a new system nagios user and group by issuing:

sudo make install-groups-users


Copy

The output will look something like below:

groupadd -r nagios
useradd -g nagios nagios
Copy
Add the Apache apache user to the nagios group:

sudo usermod -a -G nagios apache


Copy

4. Installing Nagios Binaries

Run the following command to install Nagios binary files, CGIs, and HTML
files:

sudo make install


Copy

You should see the following output:

...
*** Main program, CGIs and HTML files installed ***
...
Copy

5. Creating External Command Directory

Nagios can process commands from external applications. Create the external
command directory and set the proper permissions by typing:

sudo make install-commandmode


Copy
*** External command directory configured ***
Copy

6. Install Nagios Configuration Files

Install the sample Nagios configuration files with:


sudo make install-config
Copy
...
*** Config files installed ***

Remember, these are *SAMPLE* config files. You'll need to read


the documentation for more information on how to actually define
services, hosts, etc. to fit your particular needs.
Copy

7. Install Apache Configuration Files

Run the command below to install the Apache web server configuration files:

sudo make install-webconf


Copy
...
*** Nagios/Apache conf file installed ***
Copy

8. Creating Systemd Unit File

The following command installs a systemd unit file and also configure the
nagios service to start on boot.

sudo make install-daemoninit


Copy
...
*** Init script installed ***
Copy

9. Creating User Account

To be able to access the Nagios web interface wel’ll create an admin user
called nagiosadmin

Run the following htpasswd command to create a user called nagiosadmin

sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin


Copy

You will be prompted to enter and confirm the user’s password.

New password:
Re-type new password:
Adding password for user nagiosadmin
Copy

Restart the Apache service for changes to take effect:


sudo systemctl restart httpd
Copy

Configure the Apache service to start on boot.


sudo systemctl enable httpd
Copy

10. Configuring Firewall

The firewall will secure your server against unwanted traffic.

If you don’t have a firewall configured on your server, you can check our guide
about how to setup a firewall with firewalld on centos

Open the Apache ports by running the following commands:

sudo firewall-cmd --permanent --zone=public --add-service=httpsudo firewall-cmd --


permanent --zone=public --add-service=httpssudo firewall-cmd --reload
Copy

Installing Nagios Plugins


Switch back to the /usr/src directory:

cd /usr/src/
Copy

Download the latest version of the Nagios Plugins from the project Github
repository:

sudo wget -O nagios-plugins.tar.gz https://github.com/nagios-plugins/nagios-


plugins/archive/release-2.2.1.tar.gz
Copy

When the download is complete extract the tar file:

sudo tar zxf nagios-plugins.tar.gz


Copy

Change to the plugins source directory:


cd nagios-plugins-release-2.2.1
Copy

Run the following commands one by one to compile and install the Nagios
plugins:

sudo ./tools/setupsudo ./configuresudo makesudo make install


Copy

Starting Nagios
Now that both Nagios and its plugins are installed, start the Nagios service
with:

sudo systemctl start nagios


Copy

To verify that Nagios is running, check the service status with the following
command:
sudo systemctl status nagios
Copy

The output should look something like below indicating that Nagios service is
active and running.
nagios.service - Nagios Core 4.4.2
Loaded: loaded (/usr/lib/systemd/system/nagios.service; enabled; vendor preset:
disabled)
Active: active (running) since Sat 2018-12-08 14:33:35 UTC; 3s ago
Docs: https://www.nagios.org/documentation
Process: 22217 ExecStart=/usr/local/nagios/bin/nagios -d
/usr/local/nagios/etc/nagios.cfg (code=exited, status=0/SUCCESS)
Process: 22216 ExecStartPre=/usr/local/nagios/bin/nagios -v
/usr/local/nagios/etc/nagios.cfg (code=exited, status=0/SUCCESS)
Main PID: 22219 (nagios)
CGroup: /system.slice/nagios.service
Copy

Accessing the Nagios Web Interface


To access the Nagios web interface open your favorite browser and type your
server’s domain name or public IP address followed by /nagios:

http(s)://your_domain_or_ip_address/nagios
Copy

Enter the nagiosadmin user login credentials and you will be redirected to the
default Nagios home page as shown on the image below:

Conclusion
You have successfully installed the latest Nagios version from source on your
CentOS system.

You should now check the Nagios Documentation and learn more about how
to configure and use Nagios.

If you hit a problem or have feedback, leave a comment below.


https://linuxize.com/post/how-to-install-and-configure-nagios-on-centos-7/

How to Install Nagios Core on CentOS


7
Nagios (also known as Nagios Core) is a free and open source application which can be
used for monitoring Linux or Windows servers, network infrastructures and applications.
When properly configured it will alert you when something on your server goes wrong
and then notify you again once the problem has been resolved. In this tutorial, we will
show you how to install and configure the latest Nagios Core version on a CentOS 7
VPS.

Step 1: Connect to your server


Connect to your server via SSH as user root, use the following command:
ssh root@IP_ADDRESS -p PORT_NUMBER

and replace IP_ADDRESS and PORT_NUMBER with your actual server IP address and SSH
port number.
Once logged in, make sure that your server is up-to-date by running the following
command:
yum update

Step 2: Install LAMP


For Nagios Core to work on your server you will also need to set up a LAMP or any
other web hosting stack. If you already have working web hosting stack installed on
your server you can skip this and go to the next step of this tutorial.
To install a LAMP stack with Apache, MariaDB and PHP 7 on your CentOS server, run the
following command:
yum install httpd mariadb-server php php-mysql
When the MariaDB installation is complete, you can also run the following command to
secure your MariaDB installation:
mysql_secure_installation

You will also need to enable MariaDB and Apache to start on boot with:
systemctl enable httpd.service
systemctl enable mariadb.service

Step 3: Install the required packages


The following packages are also be required by the Nagios Core software. You can
install them with the following command:
yum install gcc glibc glibc-common wget gd gd-devel perl postfix

Step 4: Download and Install Nagios Core


Let’s download the latest stable version of the Nagios Core.
First, navigate to the tmp directory on your server with:
cd /tmp

and run the following command to download the tar archive file:
wget -O nagioscore.tar.gz
https://github.com/NagiosEnterprises/nagioscore/archive/nagios-4.4.2.tar.gz

Once the download is complete, execute the following command to extract the archive
file:
tar xzf nagioscore.tar.gz

Once the archive is extracted, move to the nagioscore-nagios-4.4.2 directory:


cd /tmp/nagioscore-nagios-4.4.2

and run the following command in order to configure the installer and prepare the
Nagios Core source code for the compilation process:
./configure

After the configuration is completed, you can now compile Nagios Core by execution
the following command:
make all
You also need to run the following commands to create the nagios user and group and
add apacheto the nagios group:
make install-groups-users
usermod -a -G nagios apache

Now, you can finally run the following command in order to install Nagios Core:
make install

To, install the initialization script which can be used to manage your Nagios service, run
the following command:
make install-daemoninit

Next, run the following command to install the Nagios sample configuration files:
make install-config

Run the following command to install and configure the external command file to make
Nagios Core to work from the command line:
make install-commandmode

The following command will install the Apache web server configuration files:
make install-webconf

After all the installations are complete, restart your apache service with:
systemctl restart httpd

Step 5: Create nagiosadmin User Account


To be able to log into Nagios, you will need to create an Apache user account.
You need to run the following command to create a new user account
called nagiosadmin and assign a password to it:
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

With this step, the main Nagios Core installation is now complete. However, for Nagios
Core to operate properly you will also need to install the Nagios Plugins as explained in
the next step.

Step 6: Install Nagios Plugins


Before you download and install the Nagios plugins, you need to make sure that the
following packages are installed on your CentOS 7 server:
yum install gcc glibc glibc-common make gettext automake autoconf wget openssl-devel
net-snmp net-snmp-utils epel-release perl-Net-SNMP

To download and extract the latest version of the Nagios Plugins to the tmp directory on
your server, run the following commands:
cd /tmp
wget --no-check-certificate -O nagios-plugins.tar.gz https://github.com/nagios-
plugins/nagios-plugins/archive/release-2.2.1.tar.gz
tar zxf nagios-plugins.tar.gz

Once the Nagios Plugins archive is extracted, run the following commands to compile
and install the Nagios Plugins on your server:
cd /tmp/nagios-plugins-release-2.2.1/
./tools/setup
./configure
make
make install

Step 7: Accessing Nagios Core


After you have successfully installed Nagios Core and the Nagios Plugins your CentOS 7
system, you can use the following command to start the Nagios service:
systemctl start nagios

To access Nagios Core, open your browser and navigate to http://YOUR-IP-


ADDRESS/nagios and log in using the nagiosadmin user account which you have created
in one of the previous steps in this tutorial.
After you have successfully logged in, you will be presented with the Nagios Core home
screen as shown in the image below:
Congratulations! You have successfully installed Nagios Core on CentOS 7. For more
information about how to manage your Nagios Core software, please refer to the official
Nagios documentation.

Of course, you don’t have to install Nagios Core on CentOS 7, if you use one of
our premium server management services, in which case you can simply ask our expert
system administrators to install the latest version of Nagios Core on CentOS 7 for you,
using the LAMP stack or any other web hosting stack of your choice. They are available
24×7 and will take care of your request immediately.
PS. If you liked this post, on how to install Nagios Core on CentOS 7, please share it with
your friends on the social networks using the buttons below or simply leave a comment
in the comments section. Thanks.
https://linuxhostsupport.com/blog/how-to-install-nagios-core-on-centos-7/

Setting up Network flow monitoring using Nfsen


on CentOS
Nfsen(http://nfsen.sourceforge.net/) is amazing project that supports various netflow collectors
and it allows you to investigate the netflows to your imagination!
The installation procedure for nfsen is described below:

Dependent package installation using yum


——————————————————
The following rpms and perl modules are required for installation and I used yum to install them:
httpd
php
perl
gcc
make
rrdtool
rrdtool-devel
rrdtool-perl
perl-TimeDate
perl-MailTools
perl-Socket6
bison
flex

Make sure that SELinux is disabled.


vi /etc/selinux/config
set SELINUX=disabled
reboot

Start and enable httpd at boot


# service httpd start
# chkconfig httpd on

Install fprobe
——————
Download fprobe from SourceForge Site and install
# tar -xjvf fprobe-1.11.tar.bz2
# cd fprobe-1.11
# ./configure
# make
# make install
Now run fprobe using command – /usr/local/sbin/fprobe -i eth0 -f”ip” -n7 remote:port
e.g.
# /usr/local/sbin/fprobe -i eth0 -f”ip” -n7 127.0.0.1:9995

and make sure that the process is running using ‘ps aux’ command.

Nfdump installation
———————-
Download nfdump from SourceForge Site and install
# tar -zxvf nfdump-1.6.11.tar.gz
# cd nfdump-1.6.11
nfdump-1.6.11]# ./configure –enable-nfprofile –enable-nftrack –enable-nfpcapd
nfdump-1.6.11]# make
nfdump-1.6.11]# make install

### You can check whether nfcapd can collect network data or not using
# nfcapd -w -D -S 2 -B 1024000 -l /opt/nfcapd_test/ -p 9995

Nfsen installation
————————

Download nfsen from SourceForge Site and install


# tar -zxvf nfsen-1.3.6p1
# cd nfsen-1.3.6p1
# cp etc/nfsen-dist.conf etc/nfsen.conf

Make all the necessay changes in nfsen.conf. Just go through the README file of nfsen for
installation and configuration instructions. These are really helpful.

Typical options in ‘nfsen.conf’ configuration file look like:

# Example Config file!


$BASEDIR = “/opt/nfsen”;
$BINDIR=”${BASEDIR}/bin”;
$LIBEXECDIR=”${BASEDIR}/libexec”;
$CONFDIR=”${BASEDIR}/etc”;
$HTMLDIR = “/var/www/nfsen/”;
$DOCDIR=”${HTMLDIR}/doc”;
$VARDIR=”${BASEDIR}/var”;
$PROFILESTATDIR=”${BASEDIR}/profiles-stat”;
$PROFILEDATADIR=”${BASEDIR}/profiles-data”;
$BACKEND_PLUGINDIR=”${BASEDIR}/plugins”;
$FRONTEND_PLUGINDIR=”${HTMLDIR}/plugins”;
$PREFIX = ‘/usr/local/bin’; $USER = “apache”;
$WWWUSER = “apache”;
$WWWGROUP = “apache”;
$EXTENSIONS = ‘all’;
$SUBDIRLAYOUT = 1;
$ZIPcollected = 1;
$ZIPprofiles = 1;
$PROFILERS = 2;
$DISKLIMIT = 98;
$PROFILERS = 6;
%sources = (
‘home’ => { ‘port’ => ‘9995’, ‘col’ => ‘#0000ff’, ‘type’ => ‘netflow’ },
);

When you install nfsen, it will automatically configure nfcapd program as a daemon.
So, there is no need to run nfcapd seperately as a daemon.

But, yes, if you would like to test it with tools like fprobe/softflowd, you can make use of nfcapd
program as a standalone and capture the flows from softflowd/fprobe.

nfcapd -w -D -S 2 -B 1024000 -l /opt/flow_base_dir/ -p 9995

Make sure that /opt/data/nfsen directory is apache writable.i.e.


# chown -R apache:apache /opt/data/nfsen

Install nfsen using


# perl install.pm etc/nfsen.conf

# Make nfsen to start at boot. Please refer to reference links for writing a daemon script.
# chmod 755 nfsen && chkconfig –add nfsen && chkconfig nfsen on

Configure apche for nfsen.


———————————-
# vi /etc/httpd/conf.d/nfsen.conf
Alias /nfsen /var/www/nfsen
<Directory /var/www/nfsen/>
DirectoryIndex nfsen.php
Options -Indexes
order allow,deny
allow from all
</Directory>

# service httpd restart

Typical Errors
——————
If you encounter errors like:

Rebuilding profile stats for ‘./live’


Unable to create graph: No such file or directory
Error GenGraph: Profile: live, traffic-day: Legend set but no color: peer2 at
libexec/NfSenRRD.pm line 337.
Unable to create graph: No such file or directory

Please ignore them. For some reason, pre-built graphs could not be generated. Make sure
that RRD.pm is installed correctly.
After some time, the graphs will be rebuilt.

Another error you might encounter is – “ERROR: nfsend connect() error: Permission denied!” This
is a permissions issue, as documented in
– https://code.google.com/p/nfsenplugins/wiki/NFSEN_Installation_Gotchas. You need to make
sure that the nfsen package can read the nfsen.comm socket file.

Typical checks
———————
Check whether fprobe is working correctly or not by using tcpdump. Fprobe is collecting traffic on
interface eth0 and capturing network flows and sending it to port 9995 over udp.

tcpdump -n -i eth0 -v dst port 9995

Check if fprobe,nfcapd processes are running or not


# ps aux | grep fprobe
# ps axu | grep nfcapd
Create a soft link for nfsen
# ln -s /opt/nfsen/bin/nfsen /usr/sbin/nfsen

## You can start and stop nfsen using


# nfsen start
# nfsen stop
### Check status of nfsen daemon
# nfsen status

### If you change the configuration in nfsen.conf, do not forget to reconfigure nfsen by using
command:

# nfsen reconfig

#### check if the required ports are listening to the traffic using netstat command:
# netstat -t -u -c

Reference Links:

I found the following blog entries to be useful for nfsen configuration:

 http://www.forwardingplane.net/2014/01/install-nfsen-and-nfdump-on-centos-6-5-for-netflow-and-
or-sflow-collection/

 https://www.m00nie.com/2014/02/install-nfsen-centos-6-fedora-20/

 http://manpages.ubuntu.com/manpages/hardy/man8/fprobe.8.html

 http://www.itsprite.com/linuxhow-to-install-nfdump-and-nfsen/

 http://blogfranz.blogspot.in/2010/11/netflow-on-endpoint.html

https://pradyumnajoshi.wordpress.com/2014/03/18/setting-up-network-flow-monitoring-using-nfsen-
on-centos/
How to install Nagios on
CentOS 6
Nagios is a powerful monitoring system that monitors your servers and/or services and
alerts staff if a problem should arise. The system is plugable which gives administrators
the ability to write their own or use hundreds of pre written plugins to monitor their
infrastructure.

Installation
Install required packages
yum -y install http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-
6-8.noarch.rpm
yum -y install nagios nagios-plugins-all

Create blank index.html


If you do not do this you will get a warning from nagios when it checks itself to make
sure apache is running.

touch /var/www/html/index.html

Set services to start on boot


chkconfig httpd on
chkconfig nagios on

Change nagiosadmin password


By default the web interface is password protected, the default user is nagiosadmin so
we'll change this users password. You can change this username too but it requires you
to modify the nagios configuration files to match.
htpasswd -c /etc/nagios/passwd nagiosadmin

Change default contact address


By default alerts will be sent to nagios@localhost. You can change this by editing
/etc/nagios/objects/contacts.cfg and changing this address

Start Services
service httpd start
service nagios start

Web Interface
You can now open your browser and goto your server's hostname or ip address
prefixed with /nagios. You will be prompted for a username and password. The
username is nagiosadmin unless you changed it, and the password is what you set
above.
Example: http://192.168.1.1/nagios

Monitoring a remote server


We will now create a configuration file to monitor an additional host. We will monitor
ICMP and SSH
Create and edit a file in /etc/nagios/conf.d/server1.domain.cfg

define host {
use linux-server
host_name server1.domain.com
alias server1.domain.com
address 10.0.0.1
}

define service {
use generic-service
host_name server1.domain.com
service_description PING
check_command check_ping!100.0,20%!500.0,60%
}

define service {
use generic-service
host_name server1.domain.com
service_description SSH
check_command check_ssh
}

Next you need to reload nagios

service nagios reload

Install and Configure Nagios On


CentOS, RHEL, Scientific Linux
6.5/6.4
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 went wrong and also
alerts back when the issues has been rectified.

With Nagios you can:

– Monitor your entire IT infrastructure.


– Identify problems before they occur.
– Know immediately when problems arise.
– Share availability data with stakeholders.hypothetical question
– Detect security breaches.
– Plan and budget for IT upgrades.
– Reduce downtime and business losses.

Scenario

In this tutorial i am going to use two systems as mentioned below.

Nagios server:

Operating system : CentOS 6.5 minimal installation

IP Address : 192.168.1.101/24

Nagios client:

Operating System : Ubuntu 13.04

IP Address : 192.168.1.100/24
Prerequisites

Before installing Nagios, make sure that you’ve a properly installed and
configured LAMP stack in your server. To install and configure LAMP server, refer
any one of the following links.

– Install LAMP server On CentOS/RHEL/Scientific Linux 6

Also install the following prerequisites too. All commands should be run as root
user.

# yum install gd gd-devel gcc glibc glibc-common


Install Nagios

I tested this how-to on CentOS 6.5 minimal server, although it should work on
all RHEL 6.x and its clones like CentOS 6.x and Scientific Linux 6.x.

Nagios will not be found in CentOS official repositories, so let us add the EPEL
repository to install nagios. To add and enable EPEL repository, refer the following
link.

– Install EPEL Repository On CentOS/RHEL/Scientific Linux 6

Next install nagios with all plug-ins and nagios agents(nrpe-agent) using
command:

# yum install nagios*


Note: It worked for me either if i keep SELINUX and iptables enable or disable.
All you need to do is allow the apache port through iptables as shown below.

# vi /etc/sysconfig/iptables
Add the following line:

[...]

-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT

[...]
Save and close the file. Restart iptables.

# service iptables restart


Configure Nagios

Add the admin mail address in the nagios contact file to receive alerts from nagios
server. To do that edit file /etc/nagios/objects/contacts.cfg,
# vi /etc/nagios/objects/contacts.cfg
Find the following line and enter the email id:

[...]

email [email protected] ;

[...
Save and close the file. Then Edit file /etc/httpd/conf.d/nagios.conf,

# vi /etc/httpd/conf.d/nagios.conf
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 Lines 15 & 16 ##

# Order allow,deny

# Allow from all

## Uncomment and Change lines 17,18 & 19 as shown below ##

Order deny,allow

Deny from all

Allow from 127.0.0.1 192.168.1.0/24

[...]
Set nagiosadmin password

# htpasswd /etc/nagios/passwd nagiosadmin

New password:

Re-type new password:

Updating password for user nagiosadmin


Start nagios and httpd services and let them to start automatically on every boot.

# service nagios start

# service httpd start

# chkconfig nagios on

# chkconfig httpd on
Access Nagios admin console

Open nagios administrator console with URL http://nagios-server-


ip/nagios and enter the username as nagiosadmin and its password which we
created in the earlier steps.
This
is how Nagios administrative console looks:

Click
on the “Hosts” section in the left pane of the console. You will see the no of
hosts to be monitored by Nagios server. Initially, the nagios server (localhost)
itself will only be monitored.
Click
on the monitoring host to display more details:

Add Monitoring targets to Nagios server


Now let us add some clients to monitor by Nagios server. To do that we have to
install nrpeand nagios-plugins in our monitoring targets.

On CentOS/RHEL/Scientifc Linux clients:

Like i said before, you have to add EPEL repository in your CentOS/RHEL/Scientific
Linux 6.x clients to install nrpe package.

Install “nrpe” and “nagios-plugins” packages in client systems to be


monitored.

# yum install nrpe nagios-plugins-all openssl


On Debian/Ubuntu clients:

$ sudo apt-get install nagios-nrpe-server nagios-plugins


Configure Monitoring targets

Edit /etc/nagios/nrpe.cfg file,

# vi /etc/nagios/nrpe.cfg
Add your Nagios server ip address

[...]

## Line 81 - Add the Nagios server IP ##

allowed_hosts=127.0.0.1 192.168.1.101

[...]
Start nrpe service:

# service nrpe start


# chkconfig nrpe on
For Debian/Ubuntu Clients, start nrpe service as shown below.

$ sudo /etc/init.d/nagios-nrpe-server restart


Now go back to your Nagios server to add the clients to be monitored through
nagios server. Edit “/etc/nagios/nagios.cfg” file,

# vi /etc/nagios/nagios.cfg
and uncomment the following lines.

## Line 52 - Uncomment ##

cfg_dir=/etc/nagios/servers
Create a directory called “servers” under “/etc/nagios/”.

# mkdir /etc/nagios/servers
Create config file to the client to be monitored:

# vi /etc/nagios/servers/clients.cfg

define host{

use linux-server

host_name client

alias client
address 192.168.1.100

max_check_attempts 5

check_period 24x7

notification_interval 30

notification_period 24x7

}
Finally restart nagios service.

# service nagios restart


Now open the 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 alerts.
Click
on the monitoring target, you’ll get the detailed output:

Like
this way, you can define more clients by creating a separate config
files “/etc/nagios/servers directory for each client.

Define services
We did define 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/nagios/servers/clients.cfg file.

# vi /etc/nagios/servers/clients.cfg

define host{

use linux-server

host_name client

alias client

address 192.168.1.100

max_check_attempts 5

check_period 24x7
notification_interval 30

notification_period 24x7

define service {

use generic-service

host_name client

service_description SSH

check_command check_ssh

notifications_enabled 0

}
Save and close the file. Restart Nagios.

# service nagios restart


Now log in to Nagios web console and check for the added services. Navigate to
Services section, you’ll see the ssh service there.
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 object definitions.

That’s all about now. Good Luck! Stay healthy!

You might want to check Nagios 4 installation on CentOS 7.

 Install And Configure Nagios 4 On CentOS 7

Reference Links:

Nagios Homepage

 TAGS

 monitoring tools

 nagios

Previous articleCommand-Line Download Manager Aria2 1.18.3 Released!


Next articleSamba 4.1.4 Available for Download
SK

http://www.ostecnix.com/

A Linux enthusiast, FOSS Supporter & Linux Consultant from Tamilnadu, India.

RELATED ARTICLESMORE FROM AUTHOR

Upgrading from Fedora 24 to Fedora 25

Fedora 25 released!

Fedora 25: On the way of Wayland


by Taboola

Sponsored Links

You May Like

You might also like