sábado, 10 de setembro de 2011

Instalação Nagios 3.2.3 em CentOs 5.x


1. Introduction
This script install Nagios 3.2.3 server with majors plugins and configure send-mail application.


2. Pre-requisites: Install necessary packages
# yum install httpd gcc glibc glibc-common gd gd-devel php


3. Create Directory to store Nagios installation files
# mkdir /opt/Nagios
# cd /opt/Nagios

4. Download Nagios Core, Nagios Plugins e AddOns
    4.1. Download from
           http://www.nagios.org/download
    4.2. Downloading
#
# cd /opt/Nagios
# wget http://sourceforge.net/projects/nagios/files/nagios-3.x/nagios-3.2.3/nagios-3.2.3.tar.gz/download?use_mirror=ufpr
#
# wget http://prdownloads.sourceforge.net/sourceforge/nagios/nsca-2.7.2.tar.gz              #
# wget http://sourceforge.net/projects/pnp4nagios/files/PNP-0.6/pnp4nagios-0.6.13.tar.gz/download
#
# wget http://caspian.dotconf.net/menu/Software/SendEmail/sendEmail-v1.56.tar.gz
#
# wget http://nagios.manubulon.com/nagios-plugins-snmp-0.6.0.tgz
# wget http://nagios.manubulon.com/nagios-snmp-plugins.1.1.1.tgz
# wget http://nagios.manubulon.com/nagios-plugins-snmp-extras-1.1-1.noarch.rpm
# wget -O check_snmp_traffic.py http://checksnmptraffic.googlecode.com/files/check_snmp_traffic
# wget -O check_snmp_traffic "http://exchange.nagios.org/components/com_mtree/attachment.php?link_id=1816&cf_id=24"
#


5. Create Nagios User account and group
# useradd -m nagios
# groupadd nagcmd
# usermod -a -G nagcmd nagios
# usermod -a -G nagcmd apache

6. Extract, Compile and Configure Nagios
# echo "Installing dependency: compiler ..."
# yum -y install gcc

# cd /opt/Nagios
# tar xzf nagios-3.2.3.tar.gz
# cd ./nagios-3.2.3
# echo "Configuring and Compiling Nagios ..."
# ./configure --with-gd-lib=/usr/lib   --with-gd-inc=/usr/include
# ./configure --with-command-group=nagcmd
# ./configure --with-command-group=nagcmd --with-gd-lib=/usr/lib   --with-gd-inc=/usr/include
# make all

# make install
# make install-init
# make install-commandmode
# make install-config

# make install-webconf

# htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin  # repeat pwd 2x

# service httpd restart

7. Extract, Compile and Install Nagios Plugins
#
# mkdir /opt/Nagios
# cd /opt/Nagios
# wget http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.15.tar.gz
#
# cd /opt/Nagios
# tar xzf nagios-plugins-1.4.15.tar.gz
# cd ./nagios-plugins-1.4.15
# ./configure --with-nagios-user=nagios --with-nagios-group=nagios
# make
# make install


8. Configure nagiosadmin email address for alerts
# vim /usr/local/nagios/etc/objects/contacts.cfg
# email     nagios@localhost   ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******


9. Verify the sample Nagios configuration files
# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
          :
  Total Warnings: 0
  Total Errors: 0

10. Configuring Nagios to Start with system

# chkconfig --add nagios
# chkconfig nagios on
# chkconfig httpd on


# service nagios start



11. Log into Web Interface
# http://localhost/nagios/  # username=nagiosadmin password=nagiosadmin

12. Configurando SELinux
      Se tiver problemas com a visualização do statusmap.cgi  consulte o link e faça o seguinte:


# chcon -R -t httpd_sys_content_t /usr/local/nagios/sbin/
# chcon -R -t httpd_sys_content_t /usr/local/nagios/share/

# chown -R nagios:nagios /usr/local/nagios
# chown -R nagios:nagios /usr/local/nagios/var/spool/checkresults



13. Installing tools e services SNMP 
# yum -y install net-snmp net-snmp-utils


14. Installing Client E-mail SMTP
# cd /usr/local/bin
# tar -xvf /opt/Nagios/sendEmail-v1.56.tar.gz
# echo "Faca um teste para ver se esta tudo funcionando ..."
# /usr/local/bin/sendEmail-v1.56/sendEmail -f noreply@internet.com.br \
  -t josemarsilva@inmetrics.com.br \
  -s cindy.inmetrics.com.br \
  -u "SendEmail-v1.56 is working properly" \
  -m "Yes, It's working"
# echo "configurar o arquivo de comandos conforme abaixo ..."
# vim /usr/local/nagios/etc/object/inmetrics_command.cfg
          :
          :
          :
      # 'notify-host-by-email' command definition
      define command{
             command_name notify-host-by-email
             command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /usr/local/bin/sendEmail-v1.56/sendEmail -s cindy.inmetrics.com.br -u "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$
             }
      # 'notify-service-by-email' command definition
      define command{
             command_name notify-service-by-email
             command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$" | /usr/local/bin/sendEmail-v1.56/sendEmail -s cindy.inmetrics.com.br -u "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
             }


Nenhum comentário:

Postar um comentário