1. Make a directory in /usr/local/nagios/etc/objects/ with client's name. We should group all the host.cfg file of the client in this directory.
2.Make the host.cfg file as host_name.cfg where host_name is the hostname of the server
3. Add the following sections to the host_name.cfg
Note: Add the service definitons according to the requirement
-----------------------------------------------------
##################################################
#
# HOST DEFINITION
#
###################################################
# Define a host for the local machine
define host{
use linux-server ; Name of host template to use
; This host definition will inherit all variables that are defined
; in (or inherited by) the linux-server host template definition.
host_name <host_name>
alias <host_name>
address <server_ip>
contact_groups nsdesign-admins
}
#################################################
#################################################
#
# SERVICE DEFINITIONS
#
###################################################
# Define a service to "ping" the local machine
define service{
use local-service ; Name of service template to use
host_name <host_name>
service_description PING
check_command check_ping!150.0,20%!500.0,60%
}
# Define a service to check the disk space of the root partition
# on the local machine. Warning if < 20% free, critical if
# < 10% free space on partition.
define service{
use local-service ; Name of service template to use
host_name <host_name>
service_description Partition /
check_command check_nrpe!check_diskslash
}
# Define a service to check the number of currently running procs
# on the local machine. Warning if > 250 processes, critical if
# > 400 users.
define service{
use local-service ; Name of service template to use
host_name <host_name>
service_description Total Processes
check_command check_nrpe!check_total_procs!500!750!RSZDT
}
# Define a service to check the load on the local machine.
define service{
use local-service ; Name of service template to use
host_name <host_name>
service_description Current Load
check_command check_nrpe!check_load!5.0,4.0,3.0!10.0,6.0,4.0
}
# Define a service to check SSH on the local machine.
# Disable notifications for this service by default, as not all users may have SSH enabled.
define service{
use local-service ; Name of service template to use
host_name <host_name>
service_description SSH
check_command check_ssh
notifications_enabled 0
}
# Define a service to check HTTP on the local machine.
define service{
use local-service ; Name of service template to use
host_name <host_name>
service_description HTTP
check_command check_http
notifications_enabled 0
}
# Define a service to check FTP on the local machine.
define service{
use local-service ; Name of service template to use
host_name <host_name>
service_description FTP
check_command check_ftp
notifications_enabled 0
}
# Define a service to check POP on the local machine.
define service{
use local-service ; Name of service template to use
host_name <host_name>
service_description POP
check_command check_pop
notifications_enabled 0
}
# Define a service to check SMTP on the local machine.
define service{
use local-service ; Name of service template to use
host_name <host_name>
service_description SMTP
check_command check_smtp
notifications_enabled 0
}
# Define a service to check MySQL on the local machine.
define service{
use local-service ; Name of service template to use
host_name <host_name>
service_description MySQL
check_command check_mysql_nsd
notifications_enabled 0
}
-----------------------------------------------------
Where <host_name> is the hostname of the remote server
<server_ip> is the Ip of the remote server
Note: Enable notification if needed by giving 1 instead of 0
4. Save the file
5.Add the following line to /usr/local/nagios/etc/nagios.cfg
------------------------------------------------------
cfg_dir=/usr/local/nagios/etc/objects/<directory_name>
------------------------------------------------------
Where directory_name is the name of the directory that we made in Step:1
6.Add the following lines to /usr/local/nagios/etc/objects/contacts.cfg
------------------------------------------------------
############<client's name> DATA BEGINS ########
define contact{
contact_name <client's name>
alias <client's name>
service_notification_period 24x7
host_notification_period 24x7
service_notification_options c,r
host_notification_options d,r
service_notification_commands notify-service-by-email
host_notification_commands notify-host-by-email
email <Email_address>
}
define contactgroup{
contactgroup_name <client's name>-admins
alias <client's name> Administrators
members <client's name>,shared
}
########### <client's name> DATA ENDS ##########
Note: Where <Email_address> is the email addresss to which notification goes
7. Add the following lines in /usr/local/nagios/etc/objects/hostgroups.cfg
############nsdesign GROUP BEGINS ##############
define hostgroup{
hostgroup_name nsdesign ; The name of the hostgroup
alias NSDesign Linux Servers ; Long name of the group
members server.dnsblock1.com,server.dnsblock2.com,server.dnsblock3.com,server.dnsblock4.com,server.dnsblock5.com,server.nsdesign.net,server.dnsblock6.com,server.dnsblock7.com,server.q4server.co.uk,server.hellodkdo.com,server.dnsblock8.com ;
}
################## nsdesign GROUP ENDS ##############
8. Issue the following command for nagios config test
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
9. Restart nagios if there is no error in config test
/etc/init.d/nagios restart
########################## How to add a nagios user to monitor their servers? #######################################
Run the following command,
htpasswd /usr/local/nagios/etc/htpasswd.users <username>
and give password
########################## How to install NRPE in client server? #######################################
On the remote server
====================
cd /opt/
wget http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.15.tar.gz
wget http://www.mycutelife.net/sanju/newtickethelp/nagios_downloads/nrpe-1.9.tar.gz
wget http://www.mycutelife.net/sanju/newtickethelp/nagios_downloads/nrpe
wget http://www.mycutelife.net/sanju/newtickethelp/nagios_downloads/nrpe.cfg
useradd nagios
tar -xvzf nagios-plugins-1.4.15.tar.gz
cd nagios-plugins-1.4.15/
./configure
make
make install
cd /opt/
tar -xvzf nrpe-1.9.tar.gz
cd nrpe-1.9/
./configure
make all
cd /opt/
mkdir /usr/local/nagios/bin
mkdir /usr/local/nagios/etc
cp nrpe-1.9/src/nrpe /usr/local/nagios/bin/
cp nrpe.cfg /usr/local/nagios/etc/
cp nrpe /etc/xinetd.d/
echo "nrpe 5666/tcp" >> /etc/services
chkconfig nrpe on
/sbin/iptables -I INPUT -p tcp -s 0/0 --dport 5666 -j ACCEPT;
service iptables save;
/etc/rc.d/init.d/xinetd restart
Then enter mysql prompt
mysql
mysql> create database nagios;
Query OK, 1 row affected (0.02 sec)
mysql> grant all privileges on nagios.* to nsduser@nagios-server-ip identified by 'Hnj7bjsv45nkja0L';
mysql> quit
Bye
Next step is to give the nagios server ip to file /etc/xinetd.d/nrpe
vi /etc/xinetd.d/nrpe
================================
# default: on
# description: NRPE
service nrpe
{
flags = REUSE
socket_type = stream
wait = no
user = root
server = /usr/local/nagios/bin/nrpe
server_args = -c /etc/nrpe.conf --inetd
log_on_failure += USERID
disable = no
only_from = <nagios-server-ip>
}
==================================
where <nagios-server-ip> is the IP of the Nagios Server
To check mysql in remote server, run the following command in the nagios server.
./check_mysql --hostname=<remote-server-ip> --port=3306 --username=nsduser --password=Hnj7bjsv45nkja0L
Allow the nagios-server-ip in the iptables and in the csf
The file /usr/local/nagios/etc/nrpe.cfg contains details of the internal commands from where it is loaded and parameters.
2.Make the host.cfg file as host_name.cfg where host_name is the hostname of the server
3. Add the following sections to the host_name.cfg
Note: Add the service definitons according to the requirement
-----------------------------------------------------
##################################################
#
# HOST DEFINITION
#
###################################################
# Define a host for the local machine
define host{
use linux-server ; Name of host template to use
; This host definition will inherit all variables that are defined
; in (or inherited by) the linux-server host template definition.
host_name <host_name>
alias <host_name>
address <server_ip>
contact_groups nsdesign-admins
}
#################################################
#################################################
#
# SERVICE DEFINITIONS
#
###################################################
# Define a service to "ping" the local machine
define service{
use local-service ; Name of service template to use
host_name <host_name>
service_description PING
check_command check_ping!150.0,20%!500.0,60%
}
# Define a service to check the disk space of the root partition
# on the local machine. Warning if < 20% free, critical if
# < 10% free space on partition.
define service{
use local-service ; Name of service template to use
host_name <host_name>
service_description Partition /
check_command check_nrpe!check_diskslash
}
# Define a service to check the number of currently running procs
# on the local machine. Warning if > 250 processes, critical if
# > 400 users.
define service{
use local-service ; Name of service template to use
host_name <host_name>
service_description Total Processes
check_command check_nrpe!check_total_procs!500!750!RSZDT
}
# Define a service to check the load on the local machine.
define service{
use local-service ; Name of service template to use
host_name <host_name>
service_description Current Load
check_command check_nrpe!check_load!5.0,4.0,3.0!10.0,6.0,4.0
}
# Define a service to check SSH on the local machine.
# Disable notifications for this service by default, as not all users may have SSH enabled.
define service{
use local-service ; Name of service template to use
host_name <host_name>
service_description SSH
check_command check_ssh
notifications_enabled 0
}
# Define a service to check HTTP on the local machine.
define service{
use local-service ; Name of service template to use
host_name <host_name>
service_description HTTP
check_command check_http
notifications_enabled 0
}
# Define a service to check FTP on the local machine.
define service{
use local-service ; Name of service template to use
host_name <host_name>
service_description FTP
check_command check_ftp
notifications_enabled 0
}
# Define a service to check POP on the local machine.
define service{
use local-service ; Name of service template to use
host_name <host_name>
service_description POP
check_command check_pop
notifications_enabled 0
}
# Define a service to check SMTP on the local machine.
define service{
use local-service ; Name of service template to use
host_name <host_name>
service_description SMTP
check_command check_smtp
notifications_enabled 0
}
# Define a service to check MySQL on the local machine.
define service{
use local-service ; Name of service template to use
host_name <host_name>
service_description MySQL
check_command check_mysql_nsd
notifications_enabled 0
}
-----------------------------------------------------
Where <host_name> is the hostname of the remote server
<server_ip> is the Ip of the remote server
Note: Enable notification if needed by giving 1 instead of 0
4. Save the file
5.Add the following line to /usr/local/nagios/etc/nagios.cfg
------------------------------------------------------
cfg_dir=/usr/local/nagios/etc/objects/<directory_name>
------------------------------------------------------
Where directory_name is the name of the directory that we made in Step:1
6.Add the following lines to /usr/local/nagios/etc/objects/contacts.cfg
------------------------------------------------------
############<client's name> DATA BEGINS ########
define contact{
contact_name <client's name>
alias <client's name>
service_notification_period 24x7
host_notification_period 24x7
service_notification_options c,r
host_notification_options d,r
service_notification_commands notify-service-by-email
host_notification_commands notify-host-by-email
email <Email_address>
}
define contactgroup{
contactgroup_name <client's name>-admins
alias <client's name> Administrators
members <client's name>,shared
}
########### <client's name> DATA ENDS ##########
Note: Where <Email_address> is the email addresss to which notification goes
7. Add the following lines in /usr/local/nagios/etc/objects/hostgroups.cfg
############nsdesign GROUP BEGINS ##############
define hostgroup{
hostgroup_name nsdesign ; The name of the hostgroup
alias NSDesign Linux Servers ; Long name of the group
members server.dnsblock1.com,server.dnsblock2.com,server.dnsblock3.com,server.dnsblock4.com,server.dnsblock5.com,server.nsdesign.net,server.dnsblock6.com,server.dnsblock7.com,server.q4server.co.uk,server.hellodkdo.com,server.dnsblock8.com ;
}
################## nsdesign GROUP ENDS ##############
8. Issue the following command for nagios config test
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
9. Restart nagios if there is no error in config test
/etc/init.d/nagios restart
########################## How to add a nagios user to monitor their servers? #######################################
Run the following command,
htpasswd /usr/local/nagios/etc/htpasswd.users <username>
and give password
########################## How to install NRPE in client server? #######################################
On the remote server
====================
cd /opt/
wget http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.15.tar.gz
wget http://www.mycutelife.net/sanju/newtickethelp/nagios_downloads/nrpe-1.9.tar.gz
wget http://www.mycutelife.net/sanju/newtickethelp/nagios_downloads/nrpe
wget http://www.mycutelife.net/sanju/newtickethelp/nagios_downloads/nrpe.cfg
useradd nagios
tar -xvzf nagios-plugins-1.4.15.tar.gz
cd nagios-plugins-1.4.15/
./configure
make
make install
cd /opt/
tar -xvzf nrpe-1.9.tar.gz
cd nrpe-1.9/
./configure
make all
cd /opt/
mkdir /usr/local/nagios/bin
mkdir /usr/local/nagios/etc
cp nrpe-1.9/src/nrpe /usr/local/nagios/bin/
cp nrpe.cfg /usr/local/nagios/etc/
cp nrpe /etc/xinetd.d/
echo "nrpe 5666/tcp" >> /etc/services
chkconfig nrpe on
/sbin/iptables -I INPUT -p tcp -s 0/0 --dport 5666 -j ACCEPT;
service iptables save;
/etc/rc.d/init.d/xinetd restart
Then enter mysql prompt
mysql
mysql> create database nagios;
Query OK, 1 row affected (0.02 sec)
mysql> grant all privileges on nagios.* to nsduser@nagios-server-ip identified by 'Hnj7bjsv45nkja0L';
mysql> quit
Bye
Next step is to give the nagios server ip to file /etc/xinetd.d/nrpe
vi /etc/xinetd.d/nrpe
================================
# default: on
# description: NRPE
service nrpe
{
flags = REUSE
socket_type = stream
wait = no
user = root
server = /usr/local/nagios/bin/nrpe
server_args = -c /etc/nrpe.conf --inetd
log_on_failure += USERID
disable = no
only_from = <nagios-server-ip>
}
==================================
where <nagios-server-ip> is the IP of the Nagios Server
To check mysql in remote server, run the following command in the nagios server.
./check_mysql --hostname=<remote-server-ip> --port=3306 --username=nsduser --password=Hnj7bjsv45nkja0L
Allow the nagios-server-ip in the iptables and in the csf
The file /usr/local/nagios/etc/nrpe.cfg contains details of the internal commands from where it is loaded and parameters.
No comments:
Post a Comment