Nagios

*******************************************************************************
Instalar e Configurar o Nagios
Criado por: Alessandro C. M. Kuramoto
Data: 17/07/2009
Modificado em: 17/07/2010-23:56
v.20100716-2056
Palavras-chaves: Nagios
Por favor, matenham o nome do autor deste arquivo.

If you want to know something about this file, send an e-mail to me at the
sancmk@gmail.com or post a comment here (at the Word Press)

moshi kono fairu no koto wo shiteitakatara, boku ni email wo okutte kudasai,
matawa kono Word Press ni chuushaku mo shitte ii desu.
boku no email wa sancmk@gmail.com desu
*******************************************************************************

###############################################################################
# Avisos!!!
###############################################################################

http://memovirtual.worpress.com

## Atenção no site memovirtual:
## As opções passadas com – - (menos,menos) no site podem ter ficado
## com um — (travessão), assim use o “man” para confirmar a opção utilizada

## Desculpem-me pelos erros de português, mas vocês sabem…
## nossa lingua é fácil… e às vezes ao escrever o pensamento está
## lá na frente, enquanto que a digitação…

|##########^ Avisos!!! #######################################################|

###############################################################################
# Temp:
###############################################################################

Ver:

service_description     CPU
check_command           check_nt!CPULOAD!-l 5,80,90

http://nagiosplugins.org/man/check_nt

http://nagios.sourceforge.net/docs/3_0/monitoring-windows.html

Ver:

http://nagiosplugins.org/man/check_procs

Ver:

http://www.debianhelp.co.uk/nagiospluins.htm

VER: Muito bom site:

http://techgurulive.com/2009/06/17/how-to-limit-linux-cpu-usage-per-process/

VER: Como editar os textos da página do Nagios:

http://www.vivaolinux.com.br/dica/Mudar-a-visualizacao-da-pagina-inicial-do-Nagios/

|##########^ Temp ############################################################|

###############################################################################
# Servidor:
###############################################################################

SO:
Servidor: Nagios
Serviço:  Nagios

Instalação básica (modo texto).

RAM

Swap
/boot
/

===============================================================================
Dados para diferenciação: (Estudo de caso)
===============================================================================

### free
free -m
total       used       free     shared    buffers     cached
Mem:          2028       1391        636          0        218        496
-/+ buffers/cache:        676       1352
Swap:         1647          0       1647

|<<<<<<<<<<<<<< ==== Dados para diferenciação: (Estudo de caso) ====

### df
df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda1             259M  255M     0 100% /
tmpfs                1015M     0 1015M   0% /lib/init/rw
udev                   10M   68K   10M   1% /dev
tmpfs                1015M   12K 1015M   1% /dev/shm
/dev/sda9              11G  493M  9.2G   5% /home
/dev/sda8             373M   11M  343M   3% /tmp
/dev/sda5             4.6G  955M  3.5G  22% /usr
/dev/sda6             2.8G  628M  2.0G  24% /var

|<<<<<<<<<<<<<< ==== Dados para diferenciação: (Estudo de caso) ====

|==========^ Dados para diferenciação: (Estudo de caso) ======================|

|##########^ Servidor ########################################################|

###############################################################################
# Conceitos:
###############################################################################
>Conceitos

A porta que o Plugin NRPE trabalha no Linux é: tcp/5666.

===============================================================================
Características do Nagios:
===============================================================================

- Possui verificação de disponibilidade;
- Monitoramento de serviços de rede (SMTP, POP3, HTTP, NNTP, PING)

|==========^ Características do Nagios =======================================|

|##########^ Conceitos #######################################################|

###############################################################################
# Instalando:
###############################################################################

|<<<<<<<<<<<<<< #### Instalando ####
===============================================================================
Instalando o Nagios no Debian: (~60min, depende da taxa de Download)
===============================================================================

(Fonte: http://www.vivaolinux.com.br/artigo/Instalando-o-poderoso-gerenciador-de-redes-Nagios-3.0-com-Apache2/)

### Instalando os pré-requisitos do Nagios para ser compilado no Debian:
apt-get install -y apache2 libapache2-mod-php5 build-essential
apt-get install -y libgdchart-gd2-xpm libgdchart-gd2-xpm-dev
apt-get install -y libgd2-xpm libgd2-xpm-dev

|==========^ Instalando o Nagios no Debian ===================================|

|<<<<<<<<<<<<<< #### Instalando ####
===============================================================================
Instalando o Nagios no CentOS 5.5:
===============================================================================

(Fonte: http://wiki.centos.org/HowTos/Nagios)
|<<<<<<<<<<<<< #### Instalando #### ==== Instalando o Nagios no CentOS 5.5 ====
yum install nagios nagios-plugins nagios-plugins-nrpe nagios-devel

|==========^ Instalando o Nagios no CentOS 5.5 ===============================|

|##########^ Instalando ######################################################|

###############################################################################
# Compilando o Nagios:
###############################################################################
>Compilando o Nagios

### Para quem quiser compilar o Nagios:

#### Pré-requitos:
# Servidor Web: Apache
# PHP
# Compilador: gcc

### Para baixar os fontes do Nagios:
wget -c http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-3.2.1.tar.gz

### Para baixar os Plugins do Nagios:
wget -c http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.14.tar.gz

### Mova os dois fontes baixados para /usr/local/src
mv -v nagios-3.2.1.tar.gz /usr/local/src
mv -v nagios-plugins-1.4.14.tar.gz /usr/local/src

### Crie o grupo do Nagios no Linux:
groupadd nagios

### Crie o usuário Nagios e o diretório pessoal em /usr/local/nagios:
useradd -g nagios -md /usr/local/nagios nagios

### Crie um grupo com o nome nagioscmd:
groupadd nagioscmd

### Adicione o usuário do Apache no grupo nagioscmd:
## No Debian o usuário do Apache normalmente é o www-data
usermod -G nagioscmd www-data

### Adicione o usuário do Nagios no grupo nagioscmd:
usermod -G nagioscmd nagios

### Entre no diretório /usr/local/src:
cd /usr/local/src

### Descompacte os arquivos fontes do Nagios:
tar xzvf nagios-3.2.1.tar.gz
tar xzvf nagios-plugins-1.4.14.tar.gz

### Entre no diretório dos fontes do Nagios:
cd /usr/local/src/nagios-3.2.1

### Rode o script para preparar a compilação:
./configure –with-cgiurl=/nagios/cgi-bin \
–with-htmurl=/nagios \
–with-nagios-user=nagios \
–with-nagios-group=nagios \
–with-command-group=nagioscmd

### Para compilar rode o comando:
make all

### Para instalar rode o comando:
make install

### Para instalar os scripts de inicialização:
### (To installs the init script in /etc/init.d)
make install-init

### This installs and configures permissions on the
### directory for holding the external command file
make install-commandmode

### This installs sample config files in /usr/local/nagios/etc
make install-config

##### Compilar e instalar os plugins:
### Para compilar os plugins entre no diretório dos fontes dos plugins:
cd /usr/local/src/nagios-plugins-1.4.14

### Rode o script para preparar a compilação:
./configure

### Para compilar rode o comando:
make

### Para instalar rode o comando:
make install

|##########^ Compilando o Nagios #############################################|

############################################################################### # Configurando o Nagios no CentOS:
###############################################################################

(Fonte:http://wiki.centos.org/HowTos/Nagios)
|<<<<<<<<<<<<<< #### Configurando o Nagios no CentOS ####
### Configure os arquivos do Apache para o Nagios
## (Configure the Nagios Apache file)
vim /etc/httpd/conf.d/nagios.conf
_______________________________________________________________________________
SO: CentOS 5.5
Arquivo: /etc/httpd/conf.d/nagios.conf (Permissões: -rw-r–r– 1 root root)
—————————————————————————–

ScriptAlias /nagios/cgi-bin /usr/lib/nagios/cgi-bin/
<Directory /usr/lib/nagios/cgi-bin/>
Options ExecCGI
order deny,allow
deny from all
#>>>> Modificado (Modified)
### Alterado o Allow from
#   allow from 127.0.0.1
Allow from 10.0.0.0/8 192.168.56.0/24

AuthType Basic

#>>>> Modificado (Modified)
### Alterado o arquivo de usuários e senhas
#   AuthUserFile /etc/nagios/passwd
AuthUserFile /etc/nagios/htpasswd

#>>>> Modificado (Modified)
### Alterado o AuthName
#   AuthName “nagios”
AuthName “nagiosadmin”

require valid-user
</Directory>

Alias /nagios /usr/share/nagios/html/
<Directory /usr/share/nagios/html/>
Options None
order deny,allow
deny from all

#>>>> Modificado (Modified)
### Alterado o Allow from
#   allow from 127.0.0.1
Allow from 10.0.0.0/8 192.168.56.0/24

AuthType Basic

#>>>> Modificado (Modified)
### Alterado o arquivo de usuários e senhas
#   AuthUserFile /etc/nagios/passwd
AuthUserFile /etc/nagios/htpasswd

#>>>> Modificado (Modified)
### Alterado o AuthName
#   AuthName “nagios”
AuthName “nagiosadmin”
require valid-user
</Directory>

#|<<<<<<<<<<<<<< #### Configurando o Nagios no CentOS ####
# For SSL-servers
#<Directory /usr/lib/nagios/cgi-bin/>
#   Options ExecCGI
#   SSLRequireSSL
#   order deny,allow
#   deny from all
#   allow from 127.0.0.1
#   AuthType Basic
#   AuthUserFile /etc/nagios/passwd
#   AuthName “nagios”
#   require valid-user
#</Directory>
#
#Alias /nagios/ /usr/share/nagios/html/
#<Directory /usr/share/nagios/html/>
#   Options None
#   SSLRequireSSL
#   order deny,allow
#   deny from all
#   allow from 127.0.0.1
#   AuthType Basic
#   AuthUserFile /etc/nagios/passwd
#   AuthName “nagios”
#   require valid-user
#</Directory>

|———-^ Arquivo: /etc/httpd/conf.d/nagios.conf ————————–|

|<<<<<<<<<<<<<< #### Configurando o Nagios no CentOS ####
### Reinicie o serviço do Apache:
service httpd restart

|<<<<<<<<<<<<<< #### Configurando o Nagios no CentOS ####
### Para criar o usuário e o arquivo de senhas
## Atenção para a opção “-c”, somente a utilize na criação do arquivo
htpasswd -c /etc/nagios/htpasswd nagiosadmin

|<<<<<<<<<<<<<< #### Configurando o Nagios no CentOS ####
### Configurando os arquivos CGI:
## (Set up the CGI file)
vim /etc/nagios/cgi.cfg
_______________________________________________________________________________
SO: CentOS 5.5
Arquivo: /etc/nagios/cgi.cfg (Permissões: -rw-r–r– 1 root root)
—————————————————————————–

#################################################################
#
# CGI.CFG – Sample CGI Configuration File for Nagios 2.12
#
# Last Modified: 11-21-2006
#
#################################################################

#|<<<<<<<<<<<<<< #### Configurando o Nagios no CentOS ####
### Arquivo de configuração principal do Nagios
# MAIN CONFIGURATION FILE
# This tells the CGIs where to find your main configuration file.
# The CGIs will read the main and host config files for any other
# data they might need.

main_config_file=/etc/nagios/nagios.cfg



#|<<<<<<<<<<<<<< #### Configurando o Nagios no CentOS ####
# AUTHENTICATION USAGE
# This option controls whether or not the CGIs will use any
# authentication when displaying host and service information, as
# well as committing commands to Nagios for processing.
#
# Read the HTML documentation to learn how the authorization works!
#
# NOTE: It is a really *bad* idea to disable authorization, unless
# you plan on removing the command CGI (cmd.cgi)!  Failure to do
# so will leave you wide open to kiddies messing with Nagios and
# possibly hitting you with a denial of service attack by filling up
# your drive by continuously writing to your command file!
#
# Setting this value to 0 will cause the CGIs to *not* use
# authentication (bad idea), while any other value will make them
# use the authentication functions (the default).

#>>>> Verificar
### AUTHENTICATION USAGE  – utilizar autenticação, 1 = sim e 0 = não
use_authentication=1



#|<<<<<<<<<<<<<< #### Configurando o Nagios no CentOS ####
# SYSTEM/PROCESS INFORMATION ACCESS
# This option is a comma-delimited list of all usernames that
# have access to viewing the Nagios process information as
# provided by the Extended Information CGI (extinfo.cgi).  By
# default, *no one* has access to this unless you choose to
# not use authorization.  You may use an asterisk (*) to
# authorize any user who has authenticated to the web server.

#>>>> Modificado
#authorized_for_system_information=nagiosadmin,theboss,jdoe
authorized_for_system_information=nagiosadmin

# CONFIGURATION INFORMATION ACCESS
# This option is a comma-delimited list of all usernames that
# can view ALL configuration information (hosts, commands, etc).
# By default, users can only view configuration information
# for the hosts and services they are contacts for. You may use
# an asterisk (*) to authorize any user who has authenticated
# to the web server.

#>>>> Modificado
#authorized_for_configuration_information=nagiosadmin,jdoe
authorized_for_configuration_information=nagiosadmin

#|<<<<<<<<<<<<<< #### Configurando o Nagios no CentOS ####
# SYSTEM/PROCESS COMMAND ACCESS
# This option is a comma-delimited list of all usernames that
# can issue shutdown and restart commands to Nagios via the
# command CGI (cmd.cgi).  Users in this list can also change
# the program mode to active or standby. By default, *no one*
# has access to this unless you choose to not use authorization.
# You may use an asterisk (*) to authorize any user who has
# authenticated to the web server.

#>>>> Mantido
#authorized_for_system_commands=nagiosadmin
authorized_for_system_commands=nagiosadmin

#|<<<<<<<<<<<<<< #### Configurando o Nagios no CentOS ####
# GLOBAL HOST/SERVICE VIEW ACCESS
# These two options are comma-delimited lists of all usernames that
# can view information for all hosts and services that are being
# monitored.  By default, users can only view information
# for hosts or services that they are contacts for (unless you
# you choose to not use authorization). You may use an asterisk (*)
# to authorize any user who has authenticated to the web server.

#>>>> Modificado
#authorized_for_all_services=nagiosadmin,guest
authorized_for_all_services=nagiosadmin

#>>> Modificado
#authorized_for_all_hosts=nagiosadmin,guest
authorized_for_all_hosts=nagiosadmin

#|<<<<<<<<<<<<<< #### Configurando o Nagios no CentOS ####
# GLOBAL HOST/SERVICE COMMAND ACCESS
# These two options are comma-delimited lists of all usernames that
# can issue host or service related commands via the command
# CGI (cmd.cgi) for all hosts and services that are being monitored.
# By default, users can only issue commands for hosts or services
# that they are contacts for (unless you you choose to not use
# authorization).  You may use an asterisk (*) to authorize any
# user who has authenticated to the web server.

#>>>> Mantido
#authorized_for_all_service_commands=nagiosadmin
authorized_for_all_service_commands=nagiosadmin

#>>>> Mantido
#authorized_for_all_host_commands=nagiosadmin
authorized_for_all_host_commands=nagiosadmin


..
.
|———-^ Arquivo: /etc/nagios/cgi.cfg ————————————|

|<<<<<<<<<<<<<< #### Configurando o Nagios no CentOS ####
### Configurando os arquivos CGI:
## (Setting up nagios.cfg)
vim /etc/nagios/nagios.cfg
_______________________________________________________________________________
SO: CentOS 5.5
Arquivo: /etc/nagios/nagios.cfg (Permissões: -rw-rw-r– 1 root root)
————————————————————————–

##############################################################################
#
# NAGIOS.CFG – Sample Main Config File for Nagios 2.12
#
# Read the documentation for more information on this configuration
# file.  I’ve provided some comments here, but things may not be so
# clear without further explanation.
#
# Last Modified: 12-21-2006
#
##############################################################################

#|<<<<<<<<<<<<<< #### Configurando o Nagios no CentOS ####
# LOG FILE
# This is the main log file where service and host events are logged
# for historical purposes.  This should be the first option specified
# in the config file!!!

log_file=/var/log/nagios/nagios.log



# You can split other types of object definitions across several
# config files if you wish (as done here), or keep them all in a
# single config file.

#|<<<<<<<<<<<<<< #### Configurando o Nagios no CentOS ####
#>>>> Modificado
### Descomentado a linha
#cfg_file=/etc/nagios/contactgroups.cfg
cfg_file=/etc/nagios/contactgroups.cfg

#>>>> Modificado
### Descomentado a linha
#cfg_file=/etc/nagios/contacts.cfg
cfg_file=/etc/nagios/contacts.cfg

#cfg_file=/etc/nagios/dependencies.cfg
#cfg_file=/etc/nagios/escalations.cfg

#>>>> Modificado
### Descomentado a linha
#cfg_file=/etc/nagios/hostgroups.cfg
cfg_file=/etc/nagios/hostgroups.cfg

#|<<<<<<<<<<<<<< #### Configurando o Nagios no CentOS ####
#>>>> Modificado
### Descomentado a linha
#cfg_file=/etc/nagios/hosts.cfg
cfg_file=/etc/nagios/hosts.cfg

#>>>> Modificado
### Descomentado a linha
#cfg_file=/etc/nagios/services.cfg
cfg_file=/etc/nagios/services.cfg

#|<<<<<<<<<<<<<< #### Configurando o Nagios no CentOS ####
#>>>> Modificado
### Descomentado a linha
#cfg_file=/etc/nagios/timeperiods.cfg
cfg_file=/etc/nagios/timeperiods.cfg



#|<<<<<<<<<<<<<< #### Configurando o Nagios no CentOS ####
# EXTERNAL COMMAND OPTION
# This option allows you to specify whether or not Nagios should check
# for external commands (in the command file defined below).  By default
# Nagios will *not* check for external commands, just to be on the
# cautious side.  If you want to be able to use the CGI command interface
# you will have to enable this.  Setting this value to 0 disables command
# checking (the default), other values enable it.

#>>>> Modificado
#check_external_commands=0
check_external_commands=1

#|<<<<<<<<<<<<<< #### Configurando o Nagios no CentOS ####
# EXTERNAL COMMAND CHECK INTERVAL
# This is the interval at which Nagios should check for external commands.
# This value works of the interval_length you specify later.  If you leave
# that at its default value of 60 (seconds), a value of 1 here will cause
# Nagios to check for external commands every minute.  If you specify a
# number followed by an “s” (i.e. 15s), this will be interpreted to mean
# actual seconds rather than a multiple of the interval_length variable.
# Note: In addition to reading the external command file at regularly
# scheduled intervals, Nagios will also check for external commands after
# event handlers are executed.
# NOTE: Setting this value to -1 causes Nagios to check the external
# command file as often as possible.

#>>>> Modificado
#command_check_interval=15s
### Comentado esta linha:
#command_check_interval=-1
### Adicionado esta linha
command_check_interval=1


..
.

|———-^ Arquivo: /etc/nagios/nagios.cfg ———————————|

|<<<<<<<<<<<<<< #### Configurando o Nagios no CentOS ####
### Criar os arquivos da configuração:
touch contactgroups.cfg contacts.cfg hostgroups.cfg hosts.cfg services.cfg timeperiods.cfg

|<<<<<<<<<<<<<< #### Configurando o Nagios no CentOS ####
### Modificando as permissões dos arquivos:
chown -v nagios.nagios contactgroups.cfg contacts.cfg hostgroups.cfg hosts.cfg services.cfg timeperiods.cfg

|<<<<<<<<<<<<<< #### Configurando o Nagios no CentOS ####
### Exemplodo arquivo: /etc/nagios/timeperiods.cfg
vim /etc/nagios/timeperiods.cfg
_______________________________________________________________________________
SO: CentOS 5.5
Arquivo: /etc/nagios/timeperiods.cfg (Permissões: -rw-rw-r– 1 root root)
————————————————————————–
# ’24×7′ timeperiod definition
define timeperiod{
timeperiod_name 24×7
alias           24 Hours A Day, 7 Days A Week
sunday          00:00-24:00
monday          00:00-24:00
tuesday         00:00-24:00
wednesday       00:00-24:00
thursday        00:00-24:00
friday          00:00-24:00
saturday        00:00-24:00
}

#|<<<<<<<<<<<<<< #### Configurando o Nagios no CentOS ####
# ‘workhours’ timeperiod definition
define timeperiod{
timeperiod_name workhours
alias           “Normal” Working Hours
monday          08:00-17:00
tuesday         08:00-17:00
wednesday       08:00-17:00
thursday        08:00-17:00
friday          08:00-17:00
}

# ‘nonworkhours’ timeperiod definition
define timeperiod{
timeperiod_name nonworkhours
alias           Non-Work Hours
sunday          00:00-24:00
monday          00:00-09:00,17:00-24:00
tuesday         00:00-09:00,17:00-24:00
wednesday       00:00-09:00,17:00-24:00
thursday        00:00-09:00,17:00-24:00
friday          00:00-09:00,17:00-24:00
saturday        00:00-24:00
}

#|<<<<<<<<<<<<<< #### Configurando o Nagios no CentOS ####
# ‘none’ timeperiod definition
define timeperiod{
timeperiod_name none
alias           No Time Is A Good Time
}
|———-^ Arquivo: /etc/nagios/timeperiods.cfg —————————-|

|<<<<<<<<<<<<<< #### Configurando o Nagios no CentOS ####
### Exemplodo arquivo: /etc/nagios/contacts.cfg
vim /etc/nagios/contacts.cfg
_______________________________________________________________________________
SO: CentOS 5.5
Arquivo: /etc/nagios/contacts.cfg (Permissões: -rw-rw-r– 1 root root)
————————————————————————–

#|<<<<<<<<<<<<<< #### Configurando o Nagios no CentOS ####
# service_notification_options are w,u,c,r,f,n
# w=warning u=unknown c=critical r=recovery f=flapping n=none
# host_notification_options d,u,r,f,n
# d=down u=unreachable r=recovery f=flapping n=none

define contact{
contact_name                    admin
alias                           admin
service_notification_period     24×7
host_notification_period        24×7
service_notification_options    c,r
host_notification_options       d,r
service_notification_commands   notify-by-email
host_notification_commands      host-notify-by-email
email                           nagios@dominio.com.br
}

#|<<<<<<<<<<<<<< #### Configurando o Nagios no CentOS ####
define contact{
contact_name                    you
alias                           you
service_notification_period     workhours
host_notification_period        workhours
service_notification_options    c,r
host_notification_options       d,r
service_notification_commands   notify-by-email
host_notification_commands      host-notify-by-email
email                           you@youremailaddress.whatever
}

#|<<<<<<<<<<<<<< #### Configurando o Nagios no CentOS ####

|———-^ Arquivo: /etc/nagios/contacts.cfg ——————————-|

|<<<<<<<<<<<<<< #### Configurando o Nagios no CentOS ####
### Exemplodo arquivo: /etc/nagios/contactgroups.cfg
vim /etc/nagios/contactgroups.cfg
_______________________________________________________________________________
SO: CentOS 5.5
Arquivo: /etc/nagios/contactgroups.cfg (Permissões: -rw-rw-r– 1 root root)
————————————————————————–

#|<<<<<<<<<<<<<< #### Configurando o Nagios no CentOS ####
# ‘einsteins’ contact group definitions
define contactgroup{
contactgroup_name       einsteins
alias                   einsteins
members                 admin,you
}

}

#|<<<<<<<<<<<<<< #### Configurando o Nagios no CentOS ####

|———-^ Arquivo: /etc/nagios/contactgroups.cfg ————————–|

|<<<<<<<<<<<<<< #### Configurando o Nagios no CentOS ####
### Exemplodo arquivo: /etc/nagios/hosts.cfg
vim /etc/nagios/hosts.cfg
_______________________________________________________________________________
SO: CentOS 5.5
Arquivo: /etc/nagios/hosts.cfg (Permissões: -rw-rw-r– 1 root root)
————————————————————————–
#|<<<<<<<<<<<<<< #### Configurando o Nagios no CentOS ####
# Generic host definitions
define host{
name                            generic-host    ; Generic template name
notifications_enabled           1               ; Host notifications are enabled
event_handler_enabled           1               ; Host event handler is enabled
flap_detection_enabled          1               ; Flap detection is enabled
process_perf_data               1               ; Process performance data
retain_status_information       1               ; Retain status information across program restarts
retain_nonstatus_information    1               ; Retain non-status information across program restarts
register                        0               ; DONT REGISTER THIS DEFINITION – ITS NOT A REAL HOST, JUST A TEMPLATE!
}

#|<<<<<<<<<<<<<< #### Configurando o Nagios no CentOS ####
# This creates a generic template that any host can use.
# Notifies never, checks 15 times before showing critical on CGI interface,

define host{
name                    basic-host
use                     generic-host
check_command           check-host-alive
max_check_attempts      15
notification_interval   0
notification_period     none
notification_options    n
register                0
}

#|<<<<<<<<<<<<<< #### Configurando o Nagios no CentOS ####
# This creates a generic host that your routers can use
# monitors host(s) 24×7, notifies on down and recovery, checks 15 times before going critical,
# notifies the contact_group every 30 minutes

define host{
name                    your-routers-host
use                     generic-host
check_command           check-host-alive
max_check_attempts      15
notification_interval   30
notification_period     24×7
notification_options    d,r
register                0
}

#|<<<<<<<<<<<<<< #### Configurando o Nagios no CentOS ####
define host{
use                     basic-host
host_name               centos
alias                   centos
address                 192.168.56.60
contact_groups          einsteins
#       notification_options    d,r  #overrides the basic-host option
}

#|<<<<<<<<<<<<<< #### Configurando o Nagios no CentOS ####
#define host{
#        use                     your-routers-host
#        host_name               router1
#        alias                   router1
#        address                 192.168.100.100
#        contact_groups          einsteins
#        }

#|<<<<<<<<<<<<<< #### Configurando o Nagios no CentOS ####

|———-^ Arquivo: /etc/nagios/hosts.cfg ———————————-|

|<<<<<<<<<<<<<< #### Configurando o Nagios no CentOS ####
### Exemplodo arquivo: /etc/nagios/hostgroups.cfg
vim /etc/nagios/hostgroups.cfg
_______________________________________________________________________________
SO: CentOS 5.5
Arquivo: /etc/nagios/hostgroups.cfg (Permissões: -rw-rw-r– 1 root root)
————————————————————————–

define hostgroup{
hostgroup_name  basic-clients
alias           basic clients
members         centos
}

#|<<<<<<<<<<<<<< #### Configurando o Nagios no CentOS ####
#define hostgroup{
#        hostgroup_name  your-routers
#        alias           routers
#        members         router1
#        }

|———-^ Arquivo: /etc/nagios/hostgroups.cfg —————————–|

|<<<<<<<<<<<<<< #### Configurando o Nagios no CentOS ####
### Exemplodo arquivo: /etc/nagios/services.cfg
vim /etc/nagios/services.cfg
_______________________________________________________________________________
SO: CentOS 5.5
Arquivo: /etc/nagios/services.cfg (Permissões: -rw-rw-r– 1 root root)
————————————————————————–

# Generic service definition template
define service{
name                            generic-service ; Generic service name
active_checks_enabled           1               ; Active service checks are enabled
passive_checks_enabled          1               ; Passive service checks are enabled/accepted
parallelize_check               1               ; Active service checks should be parallelized (Don’t disable)
obsess_over_service             1               ; We should obsess over this service (if necessary)
check_freshness                 0               ; Default is to NOT check service ‘freshness’
notifications_enabled           1               ; Service notifications are enabled
event_handler_enabled           1               ; Service event handler is enabled
flap_detection_enabled          1               ; Flap detection is enabled
process_perf_data               1               ; Process performance data
retain_status_information       1               ; Retain status information across program restarts
retain_nonstatus_information    1               ; Retain non-status information across program restarts
register                        0               ; DONT REGISTER THIS DEFINITION – NOT A REAL SERVICE, JUST A TEMPLATE!
}

#|<<<<<<<<<<<<<< #### Configurando o Nagios no CentOS ####
# Generic for all services
define service{
use                             generic-service
name                            basic-service
is_volatile                     0
check_period                    24×7
max_check_attempts              15
normal_check_interval           10
retry_check_interval            2
notification_interval           0
notification_period             none
register                        0
}

#|<<<<<<<<<<<<<< #### Configurando o Nagios no CentOS ####
define service{
use                             basic-service
name                            ping-service
notification_options            n
check_command                   check_ping!1000.0,20%!2000.0,60%
register                        0
}

#|<<<<<<<<<<<<<< #### Configurando o Nagios no CentOS ####
define service{
use                             ping-service
service_description             PING
contact_groups                  einsteins
hostgroup_name                  basic-clients,your-routers
#       host_name                       one_client
}

|———-^ Arquivo: /etc/nagios/services.cfg ——————————-|

### Para reiniciar o serviço do Nagios:
service nagios restart

|<<<<<<<<<<<<<< #### Configurando o Nagios no CentOS ####
### Configurando o Nagios para iniciar automaticamente:
chkconfig nagios on

### Para testar as configurações do Nagios:
## (Para checar as configurações do Nagios)
nagios -v /etc/nagios/nagios.cfg

|##########^ Configurando o Nagios no CentOS #################################|

############################################################################### # Configurando o Nagios no Debian:
###############################################################################

### Veja também:
# Configurando o Nagios no CentOS, acima.

(Fonte: http://www.dicas-l.com.br/arquivo/configurando_o_nagios_3_no_debian_lenny.php)

### Depende da instalação/compilação:
/usr/local/nagios/etc

|<<<<<<<<<<<<<< #### Configurando o Nagios no Debian ####
vim /usr/local/nagios/etc/nagios.cfg
_______________________________________________________________________________
SO: Debian 5.0 Lenny
Arquivo: /usr/local/nagios/etc/nagios.cfg (Permissões: -rw-rw-r– 1 nagios nagios)
————————————————————————-
.
..

#### Configurar o arquivo de log do Nagios:
# LOG FILE
# This is the main log file where service and host events are logged
# for historical purposes.  This should be the first option specified
# in the config file!!!
log_file=/var/log/nagios/nagios.log

#### Para especificar os objetos:
# You can specify individual object config files as shown below:
cfg_file=/usr/local/nagios/etc/objects/hosts.cfg
cfg_file=/usr/local/nagios/etc/objects/services.cfg

..
.

|———-^ Arquivo: /usr/local/nagios/etc/nagios.cfg ———————–|

|<<<<<<<<<<<<<< #### Configurando o Nagios no Debian ####

_______________________________________________________________________________
SO: Debian 5.0 Lenny
Arquivo: /usr/local/nagios/etc/objects/hosts.cfg
(Permissões: -rw-r–r– 1 nagios nagios)
————————————————————————-

#>>> Adicionado:
# Generic host definitions
define host{
name                            generic-host    ; Generic template name
notifications_enabled           1               ; Host notifications are enabled
event_handler_enabled           1               ; Host event handler is enabled
flap_detection_enabled          1               ; Flap detection is enabled
process_perf_data               1               ; Process performance data
retain_status_information       1               ; Retain status information across program restarts
retain_nonstatus_information    1               ; Retain non-status information across program restarts
register                        0               ; DONT REGISTER THIS DEFINITION – ITS NOT A REAL HOST, JUST A TEMPLATE!
}

# This creates a generic template that any host can use.
# Notifies never, checks 15 times before showing critical on CGI interface,

define host{
name                    basic-host
use                     generic-host
check_command           check-host-alive
max_check_attempts      15
notification_interval   0
notification_period     none
notification_options    n
register                0
}

define host{
use             host-seguranca
host_name       nome_do_server
alias           Servidor do Filtro de Conteudo – Servidor de Gerencia
address         10.10.10.20
}

..
.

|———-^ Arquivo: /usr/local/nagios/etc/objects/hosts.cfg —————-|

_______________________________________________________________________________
SO: Debian 5.0 Lenny
Arquivo: /usr/local/nagios/etc/objects/services.cfg
(Permissões: -rw-r–r– 1 nagios nagios)
————————————————————————-
.
..

define service{
use                     servico-essencial
host_name               nome_do_server
service_description     SERVICO DE FILTRO
check_command           check_nt!SERVICESTATE!-d SHOWALL -l ‘Nome do Sevico no Windows’
}

..
.

|———-^ Arquivo: /usr/local/nagios/etc/objects/services.cfg ————-|

### Para testar as configurações do Nagios:
## (Para checar as configurações do Nagios)
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

#### Para recarregar os arquivos de configuração:
/etc/init.d/nagios reload

## Ou:
invoke-rc.d nagios reload

|##########^ Configurando o Nagios no Debian #################################|

############################################################################### # Configurando os Clientes Windows:
###############################################################################

_______________________________________________________________________________
SO: Windows
Arquivo: c:\Program Files\NSClient++\NSC.ini
————————————————————————-

; Hosts permitidos (Rede ou IP do servidor do Nagios)
allowed_hosts=172.21.0.0/24

|———-^ Arquivo: c:\Program Files\NSClient++\NSC.ini ——————–|

|<<<<<<<<<<<<<< #### Configurando o Servidor de OpenLDAP ####

|##########^ Configurando os Clientes Windows ################################|

############################################################################### # Gerenciando o Servidor do Nagios:
###############################################################################

## Diretório onde ficam os plugins dos Nagios:
/usr/local/nagios/libexec

./check_dns -H www.uol.com.br

### Para testar o servidor de OpenLDAP:
./check_ldap -H ldap.dominio.com.br -b ou=dominio,dc=com,dc=br

### Arquivo de Logs:
/var/log/nagios/nagios.log

|##########^ Gerenciando o Servidor do Nagios ################################|

############################################################################### # Gerenciando o Nagios:
###############################################################################

## Diretório onde ficam os plugins dos Nagios:
/usr/local/nagios/libexec

(Fonte: http://nagios.sourceforge.net/docs/3_0/verifyconfig.html)
### Para verificar a configuração do Nagios:
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

./check_dns -H www.uol.com.br

|<<<<<<<<<<<<<< #### Gerenciando o Nagios ####
(Fonte: http://nagios.sourceforge.net/docs/3_0/monitoring-windows.html)
### Testando a utilização de CPU de um seridor:
check_nt -H 10.10.10.65 -p 12489 -v CPULOAD -l 5,80,90

check_nt -H 10.10.10.65  -p 12489 -v PROCSTATE -d SHOWALL -l rtvscan.exe

|<<<<<<<<<<<<<< #### Gerenciando o Nagios ####
### Nagios: para testar um servidor http:
check_http -I 10.10.10.65 -u http://www.dominio.com.br

### Nagios: para testar um servidor http na porta 8080:
check_http -I 10.10.10.65 -u http://www.dominio.com.br -p 8080

|##########^ Gerenciando o Nagios ############################################|

###############################################################################
# Testes
###############################################################################

## Para testar a conexão SNMP:
snmpwalk -Os -c public -v 1 127.0.0.1 system
snmpwalk -Os -c public -v 1 localhost interface

###############################################################################
# Troubleshooting
###############################################################################
>Troubleshooting

To reset the admin password logon on the appliance console and run the following command lines:

* mysql cacti
* update user_auth set password(md5)=’admin’ where username=’admin’;

|<<<<<<<<<<<<<< #### Troubleshooting ####
——————————————————————————-
### Erros conhecidos:  (Known Errors)
## Questão/ Problema: (Question/Issue)

Erro ao tentar rodar o script de preparação “./configure” para
compilar o Nagios.

## Sintomas: (Symptom)

Erro ao tentar rodar o script de preparação “./configure” para
compilar o Nagios.

checking for gcc… no
checking for cc… no
checking for cl.exe… no
configure: error: no acceptable C compiler found in $PATH
See `config.log’ for more details.

|<<<<<<<<<<<<<< #### Troubleshooting ####
## Causa: (Cause)

Este erro pode acontecer porque o gcc não está instalado.

## Solução: (Solution)

Instalar o gcc.

—————————————
Instalar o gcc no Debian 5.0 Lenny:

apt-get install gcc
—————————————

—————————————
Instalar o gcc no SUSE 10 SP2:

zypper install gcc
—————————————

|—————————————————————————–|

|<<<<<<<<<<<<<< #### Troubleshooting ####
——————————————————————————-
### Erros conhecidos:  (Known Errors)
## Questão/ Problema: (Question/Issue)

Ao tentar rodar o comando make, aparece mensagem de erro.

## Sintomas: (Symptom)

Ao tentar rodar o comando make, aparece mensagem de erro abaixo:

-su: make: command not found

|<<<<<<<<<<<<<< #### Troubleshooting ####
## Causa: (Cause)

O comando não foi encontrado.

Causa provável, o comando make não está instalado.

## Solução: (Solution)

Instalar o make.

—————————————
Instalar o gcc no Debian 5.0 Lenny:

apt-get install make
—————————————

—————————————
Instalar o gcc no SUSE 10 SP2:

zypper install make
—————————————

|—————————————————————————–|

|<<<<<<<<<<<<<< #### Troubleshooting ####
——————————————————————————-
### Erros conhecidos:  (Known Errors)
## Questão/ Problema: (Question/Issue)

Ao rodar o comando “nagios -v nagios -v /etc/nagios/nagios.cfg”
aparece mensagem de erro.

## Sintomas: (Symptom)

Ao rodar o comando “nagios -v nagios -v /etc/nagios/nagios.cfg”
aparece a mensagem de erro abaixo:

Error: Cannot open config file ‘/etc/nagios/localhost.cfg’ for reading: No such file or directory

|<<<<<<<<<<<<<< #### Troubleshooting ####
## Causa: (Cause)

O arquivo /etc/nagios/localhost.cfg não existe.

## Solução: (Solution)

1) Crie o arquivo /etc/nagios/localhost.cfg, com as informações
necessárias.

2) Ou comente a linha que refere a este arquivo no arquivo:
nagios.cfg

————————————————————-
CentOS: /etc/nagios/nagios.cfg

# Host and service definitions for monitoring this machine
#cfg_file=/etc/nagios/localhost.cfg
|———————————————————–|

|—————————————————————————–|

|<<<<<<<<<<<<<< #### Troubleshooting ####
——————————————————————————-
### Erros conhecidos:  (Known Errors)
## Questão/ Problema: (Question/Issue)

Ao rodar o comando “nagios -v nagios -v /etc/nagios/nagios.cfg”
aparece mensagem de erro.

## Sintomas: (Symptom)

Ao rodar o comando “nagios -v nagios -v /etc/nagios/nagios.cfg”
aparece a mensagem de erro abaixo:

Error: Could not find any hostgroup matching ‘your-routers’
Error: Could not expand hostgroups and/or hosts specified in service (config file ‘/etc/nagios/services.cfg’, starting on line 40)

|<<<<<<<<<<<<<< #### Troubleshooting ####
## Causa: (Cause)

your-routers estava configurado erroneamente.

## Solução: (Solution)

1) Configurá-lo em todos arquivos configurados; ou

2) Retirar o “your-routers” da configuração do arquivo:
/etc/nagios/services.cfg

|—————————————————————————–|

|<<<<<<<<<<<<<< #### Troubleshooting ####
——————————————————————————-
### Erros conhecidos:  (Known Errors)
## Questão/ Problema: (Question/Issue)

A página do Nagios não abre no Google Chrome.

## Sintomas: (Symptom)

Ao tentar acessar a página do Nagios o Google Chrome baixa o arquivo
index.html, mas não abre a página. Ao abrir o arquivo baixado é possível
ver a seguinte mensagem de erro:

This webpage is not found.

No webpage was found for the web address: file:///home/alessandro/Download/Chrome%20Downloads/main.php

## Causa: (Cause)

Pode ter havido problema em acessar a página do Nagios uma vez, assim
a página ficou em cache no Google Chrome e mesmo com o servidor
Apache e Nagios funcionando direito, a página trazida era do cache.

## Solução: (Solution)

Limpado o cache do Google Chrome.

|—————————————————————————–|

|<<<<<<<<<<<<<< #### Troubleshooting ####
——————————————————————————-
### Erros conhecidos:  (Known Errors)
## Questão/ Problema: (Question/Issue)

Acesso negado para ver as informações do Nagios.

## Sintomas: (Symptom)

Ao tentar acessar o Nagios aparece a mensagem de erro abaixo no
Browser:

It appears as though you do not have permission to view information for any of the hosts you requested…
If you believe this is an error, check the HTTP server authentication requirements for accessing this CGI
and check the authorization options in your CGI configuration file.

## Causa: (Cause)

## Solução: (Solution)

|—————————————————————————–|

|<<<<<<<<<<<<<< #### Troubleshooting ####
——————————————————————————-
### Erros conhecidos:  (Known Errors)
## Questão/ Problema: (Question/Issue)

Erro ao acessar o Nagios.

## Sintomas: (Symptom)

Ao acessar o Nagios aparece o erro abaixo:

Error: Could not read host and service status information!

The most common cause of this error message (especially for new users), is the fact that Nagios is not actually running

## Causa: (Cause)

The most common cause of this error message (especially for new users), is the fact that Nagios is not actually running

|<<<<<<<<<<<<<< #### Troubleshooting ####
## Solução: (Solution)

O serviço do Nagios foi iniciado.

—————————————
Iniciar o serviço do Nagios no Debian:

invoke-rc.d nagios start
—————————————

Colocado o Nagios para inicializar automaticamente:

——————————————————–
Iniciar o serviço do Nagios no Debian automaticamente:

update-rc.d nagios start 81 2 . stop 81 0 1 .
——————————————————–

|—————————————————————————–|

|<<<<<<<<<<<<<< #### Troubleshooting ####
——————————————————————————-
### Erros conhecidos:  (Known Errors)
## Questão/ Problema: (Question/Issue)

## Sintomas: (Symptom)

## Causa: (Cause)

## Solução: (Solution)

|—————————————————————————–|

|<<<<<<<<<<<<<< #### Troubleshooting ####
|##########^ Troubleshooting #################################################|

###############################################################################
# Referências:
###############################################################################

Nagios en Debian:

  1. Nenhum comentário ainda.
  1. Nenhum trackbacks ainda.

Deixe uma resposta

Preencha os seus dados abaixo ou clique em um ícone para log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Sair / Alterar )

Imagem do Twitter

You are commenting using your Twitter account. Sair / Alterar )

Foto do Facebook

You are commenting using your Facebook account. Sair / Alterar )

Connecting to %s

Seguir

Obtenha todo post novo entregue na sua caixa de entrada.