nagios server configuration

Download Nagios Server Configuration

If you can't read please download the document

Upload: harsh

Post on 08-Nov-2015

215 views

Category:

Documents


0 download

DESCRIPTION

Nagios Server Configuration

TRANSCRIPT

Nagios Server Configuration

wget http://dl.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm

rpm ivh epel-release-5-4.noarch.rpm

yum install -y wget httpd php gcc glibc glibc-common gd gd-devel make net-snmp

Download NAGIOS CORE Server Software

wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-4.0.6.tar.gz

tar xvf nagios-4.0.6.tar.gz

cd nagios-4.0.6

useradd nagios

passwd nagios

groupadd nagcmd

usermod -a -G nagcmd nagios

./configure --with-command-group=nagcmd

make all

make install

make install-init

make install-config

make install-commandmode

make install-webconf

cp -R contrib/eventhandlers/ /usr/local/nagios/libexec/

chown -R nagios:nagios /usr/local/nagios/libexec/eventhandlers

/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

/etc/init.d/nagios restart

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

Add bellow code in following file :- vi /usr/local/nagios/etc/objects/commands.cfg

define command{command_name check_nrpecommand_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$}

Install Nagios Plugins

Download Nagios Plugin

wget http://nagios-plugins.org/download/nagios-plugins-2.0.2.tar.gz

tar xvf nagios-plugins-2.0.2.tar.gz

cd nagios-plugins-2.0.2

./configure --with-nagios-user=nagios --with-nagios-group=nagios

Make

Make install

chkconfig --add nagios

chkconfig --level 35 nagios on

chkconfig --add httpd

chkconfig --level 35 httpd on

/etc/init.d/nagios restart

/etc/init.d/httpd restart

Install Nrpe on nagios server:-

yum install openssl.

wget http://osdn.dl.sourceforge.net/sourceforge/nagios/nrpe-2.8.tar.gztar xzf nrpe-2.8.tar.gz

cd nrpe-2.8Compile the NRPE addon../configuremake allInstall the NRPE plugin (for testing), daemon, and sample daemon config file.make install-pluginmake install-daemonmake install-daemon-configInstall the NRPE daemon as a service under xinetd.make install-xinetdEdit the /etc/xinetd.d/nrpe file and add the IP address of the monitoring server to the only_from directive.only_from = 127.0.0.1, Add the following entry for the NRPE daemon to the /etc/services file.nrpe 5666/tcp # NRPERestart the xinetd service.service xinetd restartMake sure the nrpe daemon is running under xinetd.netstat -at | grep nrpeThe output out above command should show something like this:tcp 0 0 *:nrpe *:* LISTENIf it does, great! If it doesn't, make sure of the following: You added the nrpe entry to your /etc/services file The only_from directive in the /etc/xinetd.d/nrpe file contains an entry for "127.0.0.1" xinetd is installed and started Check the system log files for references about xinetd or nrpe and fix any problems that are reportedNext, check to make sure the NRPE daemon is functioning properly. To do this, run the check_nrpe plugin that was installed for testing purposes./usr/local/nagios/libexec/check_nrpe -H localhostYou should get a string back that tells you what version of NRPE is installed, like this:NRPE v2.8On nagios server,after installtion of nrpe ,nrep service is not created default ,you need to create it with usign below steps

cd /root/nrpe-2.12 cp init-script /etc/init.d/nrpe chmod 777 /etc/init.d/nrpe /etc/init.d/nrep restart

Login to Nagios webconsole with using below url

http://10.20.41.250/nagios/

username :-nagiosadmin

password :- which you have set to user nagiosadmin.for eg:-trimax

Configure nrpe and nagios-plugins on Client server

Install nrpe on Client Server

wget http://dl.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm

rpm ivh epel-release-5-4.noarch.rpm

yum install -y nrpe openssl

cd /etc/nagios/

cp -p nrpe.cfg nrpe.cfg.orig (take backup of nrpe.cfg file)

Configure nrpe

Add the nagios server ip in allowed_hosts as edited in given below nrpe.cfg file.

vi /etc/nagios/nrpe.cfg

log_facility=daemonpid_file=/var/run/nrpe/nrpe.pidserver_port=5666nrpe_user=nrpenrpe_group=nrpeallowed_hosts=192.168.10.50 (Nagios server ip address)dont_blame_nrpe=0debug=0command_timeout=60connection_timeout=300include_dir=/etc/nrpe.d/Defult :-command[check_users]=/usr/lib/nagios/plugins/check_users -w 5 -c 10command[check_load]=/usr/lib/nagios/plugins/check_load -w 15,10,5 -c 30,25,20command[check_hda1]=/usr/lib/nagios/plugins/check_disk -w 20% -c 10% -p /dev/hda1 (Enter here / partition device name for eg: /dev/had1)command[check_zombie_procs]=/usr/lib/nagios/plugins/check_procs -w 5 -c 10 -s Zcommand[check_total_procs]=/usr/lib/nagios/plugins/check_procs -w 150 -c 200

change to :-command[check_users]=/usr/lib/nagios/plugins/check_users -w 80 -c 90 command[check_http]=/usr/lib/nagios/plugins/check_http -H 127.0.0.1 -w 2 -c 1 command[check_ssh]=/usr/lib/nagios/plugins/check_ssh -t 30 -H 10.20.41.250 command[check_swap]=/usr/lib/nagios/plugins/check_swap -w 20% -c 10% command[check_load]=/usr/lib/nagios/plugins/check_load -w 15,10,5 -c 30,25,20 command[check_disk]=/usr/lib/nagios/plugins/check_disk -w 20% -c 10% -p /dev/hda2 command[check_procs]=/usr/lib/nagios/plugins/check_procs -w 190 -c 220 command[check_ping]=/usr/lib/nagios/plugins/check_ping -H 10.20.41.250 -w 100.0,25% -c 300.0,75% -p 1

NOTE:-1).when you install Nagios plugines through YUM command then nagios plugines install at path /usr/lib/nagios/plugins/ on 32 bit os ,on 64 bit os /usr/lib64/nagios/plugins/

2). when you install Nagios pluginess through source means download nagios plugine and install ,then that time Nagios plugines install at path /usr/local/nagios/libexec

/etc/init.d/nrpe restart

2) Install Nagios Plugins on Client Server

useradd nagios

passwd nagios

Download Nagios Plugin

wget http://nagios-plugins.org/download/nagios-plugins-2.0.2.tar.gz

tar xvf nagios-plugins-2.0.2.tar.gz

cd nagios-plugins-2.0.2

./configure --with-nagios-user=nagios --with-nagios-group=nagios

Make

Make install

chown nagios.nagios /usr/local/nagios

chown -R nagios.nagios /usr/local/nagios/libexec

yum install xinetd

service xinetd restart

Do below thing on Nagios server

Create server configure file on Nagios Server

cd /usr/local/nagios/etc/objects/

cp localhost.cfg GLPI_Server.cfg

vi GLPI_Server.cfg

Note:- 1.you need to replace localhost by server name in below file.

2.At point define host.you need to replace localhost ip address 127.0.0.1 by server ip address for eg:- 192.168.10.21 where nagios client is installed.

3.You need to replace hostgroup_name linux-servers, when you go to install the other server you need to change hostgroup name linux-servers1,linux-server2 etc.

4.you need to replace members localhost change to members kaushik_server(hostname of client server).

5. you need to replace use local-service change to use generic-service.

6.You need to replace check_command check_local_disk!20%!10% / change to check_command check_nrpe!check_disk---------------------------------------------------------------------------------------------------------------------------------------------------------------------------################################################################################ LOCALHOST.CFG - SAMPLE OBJECT CONFIG FILE FOR MONITORING THIS MACHINE### NOTE: This config file is intended to serve as an *extremely* simple# example of how you can create configuration entries to monitor# the local (Linux) machine.################################################################################################################################################################ 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 GLPI_Serveralias GLPI_Serveraddress 192.168.10.21}############################################################################################################################################################# HOST GROUP DEFINITION############################################################################################################################################################# Define an optional hostgroup for Linux machinesdefine hostgroup{hostgroup_name linux-servers The name of the hostgroupalias Linux Servers ; Long name of the groupmembers kaushik_server Comma separated list of hosts that belong to this group}######################################################################################################################################################## SERVICE DEFINITIONS############################################################################################################################################################# Define a service to "ping" the local machinedefine service{use generic-service ; Name of service template to usehost_name GLPI_Serverservice_description PINGcheck_command check_nrpe!check_ping}

2) Configure nagios.cfg file on Nagios Server.Add this server configure file (cfg_file=/usr/local/nagios/etc/objects/GLPI_Server.cfg)

vi /usr/local/nagios/etc/nagios.cfg

---------------------------------------------------------------------------------------# You can also tell Nagios to process all config files (with a .cfg# extension) in a particular directory by using the cfg_dir# directive as shown below:

#cfg_dir=/usr/local/nagios/etc/servers#cfg_dir=/usr/local/nagios/etc/printers#cfg_dir=/usr/local/nagios/etc/switches#cfg_dir=/usr/local/nagios/etc/routerscfg_file=/usr/local/nagios/etc/objects/GLPI_Server.cfg

To work email.need to start the SMTP service on Nagios server.----------------------------------------------------------------------------------------

1).install sendmail as below#yum install sendmail

2).After successful installation of sendmail.restart the sendmail server as below#/etc/init.d/sendmail start

3).After starting Sendmail check SMTP port 25 is opened on nagios server or not with below command.#namp localhost

output :-------------------------------PORT STATE SERVICE 22/tcp open ssh 25/tcp open smtp 80/tcp open http 111/tcp open rpcbind --------------------------------

Mail Configure for sending Critical and warning Alert.

/etc/init.d/sendmail restart

Add Email id in bellow .cfg filevi /usr/local/nagios/etc/objects/contacts.cfg

################################################################################################################################################################ CONTACTS################################################################################################################################################################ Just one contact defined by default - the Nagios admin (that's you)# This contact definition inherits a lot of default values from the 'generic-contact'# template which is defined elsewhere.

define contact{contact_name nagiosadmin ; Short name of useruse generic-contact ; Inherit default values from generic-contact template (defined above)alias Nagios Admin ; Full name of user

email [email protected] ;