November 2024
M T W T F S S
 123
45678910
11121314151617
18192021222324
252627282930  

Categories

November 2024
M T W T F S S
 123
45678910
11121314151617
18192021222324
252627282930  

NAGIOS

Nagios

Firewall and SElinux is Disable

Server IP :- 192.168.0.10
Hostname :- shashi.example.com
 
Client IP :- 192.168.0.11
Hostname :- client.example.com
 
1.Package Requirement :-
 
# yum install httpd php
# yum install gcc glibc glibc-common
# yum install gd gd-devel
 
2.Create Nagios user and group :-
 
# useradd -m nagios
# passwd nagios
# usermod -G nagios  nagios
# groupadd nagcmd
# usermod -a -G nagcmd nagios
# usermod -a -G nagcmd apache
 
3.Download Some Package :-
 
# mkdir /opt/nagios
 
# cd /opt/nagios
 
3.2.3.tar.gz
 
plugins-1.4.11.tar.gz
 
# tar xvf nagios-3.2.3.tar.gz
 
# cd nagios-3.2.3
 
# ./configure –with-command-group=nagcmd
 
# make all
 
# make install
 
# make install-init
 
# make install-config
 
# make install-commandmode
 
# make install-webconf
 

 4.vim /usr/local/nagios/etc/objects/contacts.cfg

 
35: change —> email youadmin-mail-ID
 

6.Give the password web nagiosadmin user

 
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
New password :
Re-type new password :
 
Note:- If you want to change admin “nagiosadmin” name change all in “/usr/local/nagios/etc/cgi.cfg” file too.
 
7. Go to this Path :-
 
# cd /opt/shashi
 
# tar xvf nagios-plugin-1.4.11.tar.gz
 
# cd nagios-plugin-1.4.11
 
# ./configure – – with-nagios-user=nagios – – with-nagios-group=nagios
 
# make
 
# make install
 
# chkconfig – – add nagios
 
# chkconfig nagios on
 
# /etc/init.d/nagios start
 
# /etc/init.d/nagios restart
 
# chkconfig nagios on

# /etc/init.d/httpd restart

#chkconfig httpd on

 
# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg (check nagios)
 
Total warnings: 0
Total Errors: 0
Things look okay – No serious problems
 
8.Login to web interface :-
 
 
username :- nagiosadmin
passwd :- *******
 
 
 
9.Package Requirement :-
 
# yum install openssl-devel xinetd
 
# cd /opt/shashi
 
2.x/nrpe-2.13/nrpe-2.13.tar.gz/download
 
# tar xvf nrpe-2.13.tar.gz
 
# cd nrpe
 
# ./configure
 
General Options:
 
————————-
 
NRPE port:5666
 
NRPE user:nagios
 
NRPE group:nagios
 
Nagios user: nagios
 
Nagios group: nagios
 
 
 
# make all
 
# make install-plugin
 
# make install-daemon
 
# make install-daemon-config
 
# make install-xinetd
 
 
10.Enter the following entry :-
 
# vim /etc/xinetd.d/nrpe
 
 
 
only_from = 127.0.0.1 192.168.0.10 (nagios_ip_address
)
 
11.Now, add entry for nrpe daemon to /etc/services file :-
 
# vim /etc/services
 
 
nrpe 5666/tcp # NRPE
 
# service xinetd restart
 
 
# chkconfig xinetd on
 
12.Test NRPE Daemon Install :-
 
# netstat -at |grep nrpe
Output should be :
 
tcp 0 0 *:nrpe *.* LISTEN
 
13.Check NRPE Service :-
 
# /usr/local/nagios/libexec/check_nrpe -H 192.168.0.10
 
Output should be NRPE version:
 
 
NRPE v2.12
 
 
 
-: CLIENT SETUP :-
 
1.Package Requirement :-
 
# yum install openssl-devel xinetd
 
# yum install httpd php
 
# yum install gcc glibc glibc-common
 
# yum install gd gd-devel
 
2.Create Nagios user and group :-
 
# useradd -m nagios
# passwd nagios
# usermod -G nagios  nagios
# groupadd nagcmd
# usermod -a -G nagcmd nagios
# usermod -a -G nagcmd apache
 
3.Create a Directary shashi :-
 
# mkdir /opt/shashi
 
# cd /opt/shashi
 
# wget http://sourceforge.net/projects/nagios/files/nrpe-2.x/nrpe-2.13/nrpe-2.13.tar.gz/download
 
 
# tar -xvf nrpe-2.13.tar.gz
# cd nrpe
 
# ./configure
 
General Options:
 
————————-
 
NRPE port: 5666
NRPE user: nagios
NRPE group: nagios
Nagios user: nagios
Nagios group: nagios
 
# make all
 
# make install-plugin
 
# make install-daemon
 
# make install-daemon-config
 
# make install-xinetd
 
Enter the following entry in :-
 
 
# vim /etc/xinetd.d/nrpe
 
 
only_from = 127.0.0.1 <192.168.0.10>(nagios_ip_address)
 
 
 
 
 
4.Now, add entry for nrpe daemon to /etc/services file
 
# vim /etc/services
nrpe 5666/tcp # NRPE
 
# service xinetd start
 
# service xinetd restart
 
 
# chkconfig xinetd on
 
5.Test NRPE Daemon Install
 
# netstat -at |grep nrpe
 
Output should be:
tcp 0 0 *:nrpe *.* LISTEN
 
This command run by server side :-
# /usr/local/nagios/libexec/check_nrpe -H 192.168.0.11 (client IP)
 
NRPE v2.12
 
# cd /opt/shashi
 
 
# tar xvf nagios-plugins-1.4.11.tar.gz
 
# cd nagios-plugins-1.4.11
 
# ./configure –with-nagios-user=nagios –with-nagios-group=nagios
 
# make
 
# make install
 
# chkconfig –add nagios
 
# chkconfig nagios on
 
# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
 
Total Warnings: 0
 
Total Errors: 0
Things look okay – No serious problems were detected during the pre-flight check
 
6.All Plugin :-
 
# cd /usr/local/nagios/libexec
 
# cp check_http check_tomcat
# cp check_http check_jboss
 
GO TO SERVER SIDE :-
 
# vim /usr/local/nagios/etc/nagios.cfg
 
>Definitions for monitoring the local (Linux) host
 
cfg_file=/usr/local/nagios/etc/objects/localhost.cfg (add line)
 
cfg_file=/usr/local/nagios/etc/objects/client.cfg (add line)
 
# vim /usr/local/nagios/etc/objects/client.cfg
 
 
define host {
 
name client ; Name of this template
 
use generic-host ; Inherit default values
 
check_period 24×7
 
check_interval 5
 
retry_interval 1
 
max_check_attempts 10
 
check_command check-host-alive
 
notification_period 24×7
 
notification_interval 30
 
notification_options d,r
 
contact_groups admins
 
register 0 ; DONT REGISTER THIS – ITS A TEMPLATE
 
}
 
define host {
 
use client ; Inherit default values from a template
 
host_name client ; The name we’re giving to this server
 
alias client ; A longer name for the server
 
address 192.168.0.11 ; IP address of the server
}
define service {
 
use local-service
 
host_name client
 
service_description PING
 
check_command check_ping!100.0,20%!500.0,60%
}
 
 
define service {
 
use local-service ; Name of service template to use
 
host_name client
 
service_description Disk Space
 
check_command check_disk!20%!10%!/
}
 
 
define service {
 
use local-service ; Name of service template to use
 
host_name client
 
service_description Total Processes
 
check_command check_local_procs!150!300!RSZDT
 
}
 
define service {
 
use local-service ; Name of service template to use
 
host_name client
 
service_description HTTP
 
check_command check_http
 
notification_interval 0 ; set > 0 if you want to be renotified
 
}
 
 
 
define service {
 
use local-service
 
host_name client
 
service_description MySQL connection-time
 
check_command check_mysql_health!root!XXXX!connection-time
 
notifications_enabled 1
}
 
 
#define service {
 
use local-service
 
host_name client
 
service_description Tomcat
 
check_command check_tomcat
}
 
define service {
 
use local-service
 
host_name client
 
service_description Jboss
 
check_command check_jboss
}
 
 
define service {
 
use local-service
 
host_name client
 
service_description SSH
 
check_command check_ssh
}
 
 
define service {
 
use local-service ; Name of service template to use
 
host_name client
 
service_description Current Users
 
check_command check_local_users!20!50
}
 
 
# vim /usr/local/nagios/etc/objects/command.cfg
 
 
################################################################################
 
# NOTE: The following ‘check_…’ commands are used to monitor services on
 
# both local and remote hosts.
 
################################################################################
 
 
 
# ‘check_load’ command definition
 
define command {
 
command_name check_procs
 
command_line $USER1$/check_procs -w $ARG1$ -c $ARG2$ -s $ARG3$
}
 
 
# ‘check_ftp’ command definition
 
define command {
 
command_name check_ftp
 
command_line $USER1$/check_ftp -H $HOSTADDRESS$ $ARG1$
}
 
# ‘check_http’ command definition
 
define command {
 
command_name check_http
 
command_line $USER1$/check_http -H $HOSTADDRESS$ -w 10 -c 20
}
# ‘check_ssh’ command definition
 
define command {
 
command_name check_ssh
 
command_line $USER1$/check_ssh $ARG1$ $HOSTADDRESS$
}
 
 
# ‘check_ping’ command definition
 
define command {
 
command_name check_ping
 
command_line $USER1$/check_ping -H $HOSTADDRESS$ -w $ARG1$ -c $ARG2$ -p 5
}
 
 
# ‘check_remote_users’ command definition
 
define command {
 
command_name check_remote_users
 
command_line $USER1$/check_users -w $ARG1$ -c $ARG2$
}
 
# ‘check_disk’ command defintion
 
define command {
 
command_name check_disk
 
command_line $USER1$/check_disk -w 20% -c 10% -p /dev/sda1
}
 
# ‘check_mysql’comman definition
 
define command {
 
command_name check_mysql_health
 
command_line $USER1$/check_mysql_health -H $HOSTADDRESS$ –user $ARG1$
–password $ARG2$ –mode $ARG3$
}
 
# ‘check_tomcat’comman definition
 
define command {
 
command_name check_tomcat
 
command_line $USER1$/check_tomcat -H $HOSTADDRESS$ -p 8080 -w 4 -c 5
}
 
#’check_jboss’command definition
 
define command{
 
command_name check_jboss
 
command_line $USER1$/check_jboss -H $HOSTADDRESS$ -p 4444 -w 4 -c 5
}
 
 
 
Check Configuration :-
 
# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
 
 
 
# /etc/init.d/nagios restart
 
######################### Now Enjoy Working with Nagios ###########################
 
 

Installing nagios with nrpe to monitor remote hosts

This post explains installingnagios with nrpe to monitor remote hosts. Nagios is one of the most used monitoring tools today.

On Remote client server to be monitored:

 
Create the user nagios and set password:
# useradd nagios
# passwd nagios
 
Download the nagios plugin from http://www.nagios.org/download/plugins
 
# mkdir -p /opt/Nagios/Nagios_Plugins
# cd /opt/Nagios/Nagios_Plugins
# cd ..
# tar xzf nagios-plugins-1.4.15.tar.gz
# cd nagios-plugins-1.4.15
 
Compiling and Installing:
Pere-requisite openssl-devel package.
#rpm -q openssl-devel
if not installed, then
# yum -y install openssl-devel
 
Configuring: 
 
# cd /opt/Nagios/nagios-plugins-1.4.15
# ./configure –with-nagios-user=nagios –with-nagios-group=nagios
If the configure struck with ICMP ping check run as below
./configure –with-nagios-user=nagios –with-nagios-group=nagios –with-ping-command=ping
# make
# make install
 
Changing permissions:
# chown nagios.nagios /usr/local/nagios
# chown -R nagios.nagios /usr/local/nagios/libexec
 
Installing xinetd super demon if not installed
# yum install xinetd
 
Now downloading and installing nrpe demon from
 
# mkdir -p /opt/Nagios/Nagios_NRPE
# cd /opt/Nagios/Nagios_NRPE
#cd ..
# tar -xzf nrpe-2.12.tar.gz
# cd nrpe-2.12
 
Compiling and Configuring nrpe
# cd /opt/Nagios/nrpe-2.12
# ./configure 
# make all
# make install-plugin
# make install-daemon
# make install-daemon-config
# make install-xinetd
 
Add Nagios Monitoring server to the “only_from” directive
# vi /etc/xinetd.d/nrpe
only_from =  
 
Add entry for nrpe daemon to services
# vi /etc/services
nrpe      5666/tcp    # NRPE
 
Restart Xinetd and set chkconfig on
# chkconfig xinetd on
# service xinetd restart
 
Checking whether NRPE daemon is running and listening on port 5666:
# netstat -at |grep nrpe
tcp    0    0 *:nrpe    *.*    LISTEN
 
Open Port 5666 on Firewall
if using csf add 5666 to TCP_IN and TCP_OUT in /etc/csf/csf.conf and restart as
#csf -r

And add the following lines to /usr/local/nagios/etc/nrpe.cfg

command[check_users]=/usr/local/nagios/libexec/check_users -w 5 -c 10
command[check_load]=/usr/local/nagios/libexec/check_load -w 15,10,5 -c 30,25,20
command[check_hda1]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /dev/hda1
command[check_zombie_procs]=/usr/local/nagios/libexec/check_procs -w 5 -c 10 -s Z
command[check_total_procs]=/usr/local/nagios/libexec/check_procs -w 150 -c 200
command[check_disk]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /dev/sda
command[check_mem]=/usr/local/nagios/libexec/check_mem 85 95
 
 
Nagios server  Setup (mail nagios server)
Downloading and installing nrpe demon from
 
# mkdir -p /opt/Nagios/Nagios_NRPE
# cd /opt/Nagios/Nagios_NRPE
#cd ..
# tar -xzf nrpe-2.12.tar.gz
# cd nrpe-2.12
 
Compiling and Configuring nrpe
# cd /opt/Nagios/nrpe-2.12
# ./configure 
# make all
# make install-plugin
 
Check NRPE daemon is functioning from nagios server. 
# /usr/local/nagios/libexec/check_nrpe -H
Output:
NRPE v2.12
 
Check whether it is defined or not.
# vi /usr/local/nagios/etc/objects/commands.cfg
define command{
        command_name check_nrpe
        command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
        }
 
If you want to add a few ips then define them in hosts.cfg
and make a hostgroup in hostgroups.cfg with all the needed users as members
and now in services.cfg and the services you want and specidy hostgroup name as follows
 
### CPU LOAD/Load Average ###
define service{
        use                             basic-service
        hostgroup_name                  customer1
        contact_groups                  admins
        service_description             CPU LOAD
        check_command                   check_nrpe!check_load
}
 
### Disk Usage ###
define service{
        use                             basic-service
        hostgroup_name                  customer1
        contact_groups                  admins
        service_description             CHECK DISK
        check_command                   check_nrpe!check_disk
}
 
### RAM Usage ###
define service{
        use                             basic-service
        hostgroup_name                  customer1
        contact_groups                  admins
        service_description             CHECK MEM
        check_command                   check_nrpe!check_mem
 
Check the configuration  as :
#/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
Now restart
#/etc/init.d/nagios restart
 
 
 
 How to setup url or website monitoring in nagios server

 

First of all create a configuration directory for writing the rules. You can also create the rules in localhost.cfg but I recommend  to create a separate directory and create the files in it.

#mkdir /etc/nagios/monitor_websites
and cd to this directory

And create file host.cfg in this directory for setting the urls.
#vi host.cfg

Suppose I want to monitor three sites
www.abc.com, www.xyz.com, www.pqr.com

Configure host.cfg as below.
#vi host.cfg

define host{
host_name  abc.com
alias         abc
address    www.abc.com
use        generic-host
}

define host{
host_name  xyz.com
alias      xyz
address    www.xyz.com
use        generic-host
}

define host{
host_name  pqr.com
alias           pqr
address    www.pqr.com
use        generic-host
}

#Defining group of urls  – you should add this if you want to set up an HTTP check service.
define hostgroup {
hostgroup_name    monitor_websites
alias           monitor_urls
members         www.abc.com, www.xyz.com, www.pqr.com
}
:wq #save it

And now create the file services.cfg for setting the service ( http_check )

#vi services.cfg
## Hostgroups services ##
define service {
hostgroup_name                 monitor_websites
service_description             HTTP
check_command                 check_http
use                             generic-service
notification_interval           0
}

Now give the permissions for directory and configuration files.
#chown  -R nagios:nagios monitor_websites

List and check.
[root@mail nagios]#  ll monitor_websites
total 16
-rw-r–r– 1 nagios nagios 669 Apr 25 23:13 host.cfg
-rw-r–r– 1 nagios nagios 253 Apr 25 23:15 services.cfg
[root@mail nagios]#

Now give the configuration directory path in main nagios configuration file.
#vi /etc/nagios/nagios.cfg
cfg_dir=/etc/nagios/monitor_websites
:wq

Now restart the nagios service.
#service nagios restart

Thats it. Check the nagios site. You are done. You rocks.

 How to install and configure Nagios Monitoring tool in redhat linux rhel5 or centos

This article will help you to install and configure Nagios monitoring tool in redhat linux or other redhat distributions like fedora, centos etc.
Nagios Installation :
Installing packages. Apache, PHP, GCC & GD

Installing Apache web server:
#yum -y install httpd*
set hostname in FQDN
#service httpd on


Installing PHP, GCC and GD:
#yum -y install php*
#yum -y install gcc*
#yum -y install gd*

Getting the package:
Get the latest packages from net. Mov it to some directory and untar them.

#wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-3.2.0.tar.gz
#mv nagios-3.2.0.tar.gz  /usr/local/src
#tar xvf nagios-3.2.0.tar.gz

#wget http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.14.tar.gz
#mv nagios-plugins-1.4.14.tar.gz/usr/local/src
#tar xvf nagios-plugins-1.4.14.tar.gz

Adding nagios user and setting password for that user:
#useradd nagios
#passwd nagios
usermod -a -G nagios apache              //To permit the commands through web interface.

Configuration of Nagios:
cd /usr/local/src/nagios-3.2.0

./configure
make all
make install
make install-init
make install-config
make install-commandmode
make install-webconf

Admin account setting for nagios:
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin          /passwd  for web interface
give passwd
service httpd restart

Nagios Plugin installation:
install nagios – pluggin

cd /usr/local/src/nagios-plugins-1.4.14
./configure
make
make install

Creating entry in /etc/init.d/:
chkconfig –add nagios
chkconfig nagios on

Checking the configuration:
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

Nagios Alert Plugin – Mozilla Addon:
Name : Nagios Checker
[give name and url]

Configuring remotehost in nagios:
cp /usr/local/nagios/etc/objects/localhost.cfg  /usr/local/nagios/etc/objects/remotehost.cfg
[comment the hostgroup entries in order to prevent duplicate entries]
[change the localhost entries to the remote machine hostname and IP address.]

 

 

 

 

 

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>