Nagios - Configuração no Ubuntu

O Nagios é um sistema de monitoramento eficiente, porém trabalhoso. Decidi ajudar, pois tudo o que eu encontrei na Net, foram artigos que não me satisfizeram em sua totalidade. Quando terminei, documentei o processo e acabou resultando neste texto. Só uma observação, eu utilizei neste artigo partes de outros, até do VOL, que funcionaram comigo.

[ Hits: 40.338 ]

Por: Rodrigo Garcia em 04/02/2012


Máquinas Windows (NSClient++)



Para adicionar máquinas Windows, é necessário baixar um plugin para Windows chamado 'Nsclient++'.

A versão utilizada é a '0.3.8', para 32 bits:
A instalação no Windows é bem simples, basta avançar até pedir o endereço IP do servidor Nagios, na senha deixe em branco, vamos configurá-la mais tarde.

Após a instalação, o arquivo "c:\Arquivos de Programas\NSclient\NSC.ini" deve ser alterado da forma abaixo.

As seguintes linhas devem ser descomentadas:

[modules]
FileLogger.dll
CheckSystem.dll
CheckDisk.dll
NSClientListener.dll
SysTray.dll
CheckEventLog.dll
CheckHelpers.dll
CheckWMI.dll

[Settings]
use_file=1
allowed_hosts=

[NSClient]
allowed_hosts=
port=1248


E na linha da 'Password', você escolherá uma senha para que o Nagios se conecte ao 'Nsclient++'.

Adicionando Máquinas Windows (Configuração do Servidor)

Agora vamos configurar o servidor, editando primeiro o arquivo "/etc/nagios-plugins/config/nt.cfg" e inserindo a senha que foi digitada no arquivo de configuração do Nsclient:

define command {
          command_name check_nt
          command_line /usr/lib/nagios/plugins/check_nt -H $HOSTADDRESS$ -s password -p 1248 -v $ARG1$ -v $ARG2$
          }


Basta incluir o parâmetro "-s" e a senha digitada no arquivo. Devemos adicionar também as seguinte linhas:

define command {
          command_name check_nt_disk
          command_line '$USER1$'/check_nt -H $HOSTADDRESS$ -p 1248 -s password -v USEDDISKSPACE -l $ARG1$ -w 80 -c 90
          }


Essas linhas serão utilizadas para monitorar o espaço em disco da máquina Windows. Em seguida devemos criar o arquivo de template dos serviços que serão monitorados da seguinte forma:

# Servico de Verificacao Ping

define service{
          name                              ICMP-Windows
          service_description          ICMP-Windows
          is_volatile                       0
          check_command               check_ping!300,20%!900,52%!
          max_check_attempts         3
          normal_check_interval      2
          retry_check_interval         2
          active_checks_enabled      1
          passive_checks_enabled    1
          check_period                    24x7
          retain_status_information  1
          notification_interval          0
          notification_period            24x7
          notification_options           u,c,r
          register                           0
          }


# Servico de Verificacao de Particao

define service{
          name                             Particao
          service_description         Particao
          is_volatile                      0
          max_check_attempts        3
          normal_check_interval     2
          retry_check_interval        2
          active_checks_enabled    1
          passive_checks_enabled  1
          check_period                  24x7
          retain_status_information 1
          notification_interval         0
          notification_period           24x7
          notification_options         u,c,r
          register                          0
          }


Aqui estão os serviços que vamos monitorar (Ping e Espaço em Disco). Agora vamos criar o arquivo do Host windows em "/etc/nagios/conf.d/maquinas":

define host{
          use               generic-host
          host_name     host-windows
          alias             Maquina-Windows01
          address         192.168.1.4
          }

define service{
          use                       ICMP-Windows
          host_name             host-windows
          service_description ICMP-Windows
          contact_groups       admins
}
define service{
          use                       Particao
          host_name             host-windows
          service_description Particao
          check_command     check_nt_disk!C
          contact_groups       admins
          }


Pronto! A máquina Windows também será monitorada!

Página anterior     Próxima página

Páginas do artigo
   1. Instalação e Configuração do Nagios
   2. Configurando NRPE no Host e no Servidor
   3. Máquinas Windows (NSClient++)
   4. Configurações Adicionais
Outros artigos deste autor
Nenhum artigo encontrado.
Leitura recomendada

Instalar um LAMP com boa performance

Recuperando RouterOS na RouterBOARD 450

Sound Blaster 128 PCI Ensonic - Modulo es1371

google-drive-ocamlfuse - Monte seu Google Drive usando o FUSE

Como configurar o Apache com PHP e SSL de um jeito mais seguro e sem complicações

  
Comentários
[1] Comentário enviado por levi linux em 05/02/2012 - 11:08h

Parabéns, pelo excelente artigo. Não conhecia esse software, mas pelo seu artigo deu para perceber a grande versatilidade e utilidade do mesmo. 10!

[2] Comentário enviado por jcb em 06/02/2012 - 15:21h

Parabéns pelo artigo,

segui passo a passo seu tutorial, quando abro a tela de nagiosadmin, em MAP, mostra a seguinte mensagem 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. If Nagios is indeed not running, this is a normal error message. It simply indicates that the CGIs could not obtain the current status of hosts and services that are being monitored. If you've just installed things, make sure you read the documentation on starting Nagios.

Some other things you should check in order to resolve this error include:

Check the Nagios log file for messages relating to startup or status data errors.
Always verify configuration options using the -v command-line option before starting or restarting Nagios!
Make sure you read the documentation on installing, configuring and running Nagios thoroughly before continuing. If all else fails, try sending a message to one of the mailing lists. More information can be found at http://www.nagios.org.


[3] Comentário enviado por adrianoti10 em 06/02/2012 - 15:35h

excelente arquivo, qual o nome que coloco no arquivo de host q é para salvar dentro do diretorio etc/nagios/conf.d/maquinas . valeu

[4] Comentário enviado por r.garcia em 06/02/2012 - 15:36h

Boa tarde JCB,

Desculpa mas tenho que perguntar: Qual distro está usando? O serviço foi iniciado? Caso não teinha sido iniciado você pode fazê-lo com o seguinte comando sudo service nagios3 start... depois poste o resultado!

Abração,

Rodrigo

[5] Comentário enviado por r.garcia em 06/02/2012 - 15:48h

Adriano,

Eu recomendo que você nomeie o arquivo com algo que faça referência ao host monitorado, porém não tem uma regra, apenas que termine com a extensão ".cfg".

Abração,

Rodrigo

[6] Comentário enviado por adrianoti10 em 06/02/2012 - 16:22h

ok Rodrigao muito obrigado cara !!!

[7] Comentário enviado por r.garcia em 06/02/2012 - 17:05h

Também estou aprendendo sobre o Nagios...

Abraço,

Rodrigo

[8] Comentário enviado por adrianoti10 em 06/02/2012 - 17:08h

Rodrigo um detalhe >> no post >> Aqui estão os serviços que vamos monitorar (Ping e Espaço em Disco). Agora vamos criar o arquivo do Host windows em "/etc/nagios/conf.d/maquinas": <<<< aqui seria o diretorio nagios3 certo ????

[9] Comentário enviado por r.garcia em 06/02/2012 - 17:26h

Adriano, está correto!!!

[10] Comentário enviado por marcoaw em 07/02/2012 - 17:15h

Interessante este artigo, vou implantar !!!

[11] Comentário enviado por clovesf em 12/02/2012 - 13:45h

Rodrigo muito bom o artigo
quando eu /etc/init.d/nagios3 restart
dar um erro na linha 22 do arquivo teste.cfg
Error: Could not find any host matching 'zombie' (config file '/etc/nagios3/conf.d/maquinas/teste.cfg', starting on line 22)
o arquivo esta assim

1 define service{
2 use generic-service
3 host_name zombie
4 service_description Espaco em Disco
5 check_command check_nrpe_1arg!check_sda1
6 }
7
8 define service{
9 use generic-service
10 host_name zombie
11 service_description Usuarios Logados
12 check_command check_nrpe_1arg!check_users
13 }
14
15 define service{
16 use generic-service
17 host_name zombie
18 service_description Processos Ativos
19 check_command check_nrpe_1arg!check_total_procs
20 }
21
22 define service{
23 use generic-service
"teste.cfg" 28L, 918C 1,1 Topo

[12] Comentário enviado por r.garcia em 16/02/2012 - 07:59h

Clovisf,

Nas linhas onde está escrito "zombie", você deve alterar para o nome da máquina que vai monitorar. E o nome do arquivo deve ter o mesmo nome da máquina com a extensão ".cfg"

Abraço

[13] Comentário enviado por adrianoti10 em 17/02/2012 - 09:17h

Error: Could not find any host matching 'host-windows' (config file '/etc/nagios3/conf.d/hostgroups_nagios2.cfg', starting on line 4)
Error: Could not expand members specified in hostgroup (config file '/etc/nagios3/conf.d/hostgroups_nagios2.cfg', starting on line 4)
Error processing object config files!


***> One or more problems was encountered while processing the config files...

Check your configuration file(s) to ensure that they contain valid
directives and data defintions. If you are upgrading from a previous
version of Nagios, you should be aware that some variables/definitions
may have been removed or modified in this version. Make sure to read
the HTML documentation regarding the config files, as well as the
'Whats New' section to find out what has changed.


pode me ajudar com esse erro cara!!! to meio perdido!!

[14] Comentário enviado por r.garcia em 17/02/2012 - 09:45h

Adriano,

No lugar de "host-windows" coloque o nome da máquina Windows.

Abraço

[15] Comentário enviado por adrianoti10 em 17/02/2012 - 10:07h

blz cara deu certo, agora apareceu esse erro, nao sei oq esta errado pode me ajudar mais uma vez..

Running pre-flight check on configuration data...

Checking services...
Error: Service check command 'check_nrpe_1arg' specified in service 'Carga Atual' for host 'ti10' not defined anywhere!
Error: Service check command 'check_nrpe_1arg' specified in service 'Espaco em Disco' for host 'ti10' not defined anywhere!
Error: Service check command 'check_nrpe_1arg' specified in service 'Processos Ativos' for host 'ti10' not defined anywhere!
Checked 10 services.
Checking hosts...
Checked 3 hosts.
Checking host groups...
Checked 5 host groups.
Checking service groups...
Checked 0 service groups.
Checking contacts...
Checked 1 contacts.
Checking contact groups...
Checked 1 contact groups.
Checking service escalations...
Checked 0 service escalations.
Checking service dependencies...
Checked 0 service dependencies.
Checking host escalations...
Checked 0 host escalations.
Checking host dependencies...
Checked 0 host dependencies.
Checking commands...
Checked 151 commands.
Checking time periods...
Checked 4 time periods.
Checking for circular paths between hosts...
Checking for circular host and service dependencies...
Checking global event handlers...
Checking obsessive compulsive processor commands...
Checking misc settings...

Total Warnings: 0
Total Errors: 3

[16] Comentário enviado por r.garcia em 17/02/2012 - 11:02h

Adriano falha minha! Faltou eu dizer que deve se instalar no servidor o pacote nagios-nrpe-plugin.

[17] Comentário enviado por adrianoti10 em 17/02/2012 - 11:58h

BLZ CARA AGORA DEU CERTO !!! VALEU...

[18] Comentário enviado por kumazawa em 23/02/2012 - 16:48h

Boa tarde!
Meus caros, sou inciante nos dois sistemas: Linux e Nagios.
Onde eu gravo as informações #Servico de Verificacao e Ping # Servico de Verificacao de Particao? Continuo no arquivo: "/etc/nagios-plugins/config/nt.cfg"?

Muito obrigado

[19] Comentário enviado por adrianoti10 em 23/02/2012 - 17:05h

vc deve adicionar as configuraçoes de >> "/etc/nagios-plugins/config/nt.cfg na sequencia q esta no tutorial..



define command {
command_name check_nt
command_line /usr/lib/nagios/plugins/check_nt -H $HOSTADDRESS$ -s password -p 1248 -v $ARG1$ -v $ARG2$
}



define command {
command_name check_nt_disk
command_line '$USER1$'/check_nt -H $HOSTADDRESS$ -p 1248 -s password -v USEDDISKSPACE -l $ARG1$ -w 80 -c 90
}



define service{
name ICMP-Windows
service_description ICMP-Windows
is_volatile 0
check_command check_ping!300,20%!900,52%!
max_check_attempts 3
normal_check_interval 2
retry_check_interval 2
active_checks_enabled 1
passive_checks_enabled 1
check_period 24x7
retain_status_information 1
notification_interval 0
notification_period 24x7
notification_options u,c,r
register 0
}


# Servico de Verificacao de Particao

define service{
name Particao
service_description Particao
is_volatile 0
max_check_attempts 3
normal_check_interval 2
retry_check_interval 2
active_checks_enabled 1
passive_checks_enabled 1
check_period 24x7
retain_status_information 1
notification_interval 0
notification_period 24x7
notification_options u,c,r
register 0
}

[20] Comentário enviado por egomes em 29/02/2012 - 15:11h


Aparece esse erro???





Error: Could not find any host matching '10.100.0.2' (config file '/etc/nagios3/conf.d/maquinas/test.cfg', starting on line 28)
Error: Could not expand hostgroups and/or hosts specified in service (config file '/etc/nagios3/conf.d/maquinas/test.cfg', starting on line 28)
Error processing object config files!


***> One or more problems was encountered while processing the config files...

Check your configuration file(s) to ensure that they contain valid
directives and data defintions. If you are upgrading from a previous
version of Nagios, you should be aware that some variables/definitions
may have been removed or modified in this version. Make sure to read
the HTML documentation regarding the config files, as well as the
'Whats New' section to find out what has changed.

* errors in config!


Error: Could not find any host matching '10.100.0.252' (config file '/etc/nagios3/conf.d/maquinas/test.cfg', starting on line 28)
Error: Could not expand hostgroups and/or hosts specified in service (config file '/etc/nagios3/conf.d/maquinas/test.cfg', starting on line 28)
Error processing object config files!


***> One or more problems was encountered while processing the config files...

Check your configuration file(s) to ensure that they contain valid
directives and data defintions. If you are upgrading from a previous
version of Nagios, you should be aware that some variables/definitions
may have been removed or modified in this version. Make sure to read
the HTML documentation regarding the config files, as well as the
'Whats New' section to find out what has changed.

* errors in config!

[21] Comentário enviado por pauloholiveria em 17/08/2012 - 11:39h

Bom dia!

para acrescentar uma máquina com windows 2003: Estou acrescentando uma linha de comando no arquivo:

#nano /etc/nagios3/nagios.cfg

cfg_file=/etc/nagios3/objects/jupter.cfg


Em seguida criei o arquivo:

:/etc/nagios3/objects#nano jupter.cfg

Dentro do arquivo coloqueio o script e estou reiniciando o serviço da o seguinte erro:

Warning: Duplicate definition found for command 'check_nt_disk' (config file '/etc/nagios3/objects/jupter.cfg', starting on line 54)
Error: Could not add object property in file '/etc/nagios3/objects/jupter.cfg' on line 55.
Error processing object config files!


***> One or more problems was encountered while processing the config files...


Este é o meu script:

### ------------ Definições de Host ---------------------------------###

define host{
name TemplateHostJupter
alias TemplateHostJupter
check_command check-host-alive
max_check_attempts 3
check_interval 5
active_checks_enabled 1
passive_checks_enabled 0
check_period 24x7
retain_status_information 1
#contact_groups Admin
notification_interval 0
notification_period 24x7
notification_options d,u,r
register 0
}

define host{
host_name Jupter
use TemplateHostJupter
alias Servidor Jupter Local
address 10.50.101.8
}

### ----------- Definições de Serviço -------------------- ####
define service{
name ICMP-Jupter
service_description ICMP-Jupter
is_volatile 0
check_command check_ping!300,20%!900,52%!
max_check_attempts 3
normal_check_interval 5
retry_check_interval 5
active_checks_enabled 1
passive_checks_enabled 0
check_period 24x7
retain_status_information 1
notification_interval 0
notification_period 24x7
notification_options u,c,r
register 0
}

define service{
host_name Jupter
service_description ICMP-Jupter
use ICMP-Jupter
#contact_groups Admin
}

### ---------- Definições do Plugin ----------- #### ### (OBS: Tudo junto e misturado no mesmo arquivo) ##
define command{
command_name check_nt_disk
command_line $USER1$/check_nt -H $HOSTADDRESS$ -p 12489 \
-v USEDDISKSPACE -l $ARG1$ -w 80 -c 90
}

## Criando o template de monitoração para partições do Windows

define service{
name Particao
service_description Particao
is_volatile 0
max_check_attempts 3
normal_check_interval 5
retry_check_interval 5
active_checks_enabled 1
passive_checks_enabled 0
check_period 24x7
notification_options u,c,r
register 0
}

define service{
host_name Jupter
service_description Particao
use Particao
check_command check_nt_disk!C
#contact_groups Admin
}

[22] Comentário enviado por sebastiaoln em 26/07/2013 - 12:09h


[8] Comentário enviado por adrianoti10 em 06/02/2012 - 17:08h:

Rodrigo um detalhe >> no post >> Aqui estão os serviços que vamos monitorar (Ping e Espaço em Disco). Agora vamos criar o arquivo do Host windows em "/etc/nagios/conf.d/maquinas": <<<< aqui seria o diretorio nagios3 certo ????


rgarcia, criei o arquivo test.cfg dentro de /etc/nagios3/conf.d e deu erro. Dizendo que o arquivo não pode ser adicionado dentro de conf.d. O que pode ter ocorrido?

Warning: Duplicate definition found for host 'test' (config file '/etc/nagios3/conf.d/maquinas/test.cfg', starting on line 3)
Error: Could not add object property in file '/etc/nagios3/conf.d/maquinas/test.cfg' on line 5.

Abraços,


Contribuir com comentário




Patrocínio

Site hospedado pelo provedor RedeHost.
Linux banner

Destaques

Artigos

Dicas

Tópicos

Top 10 do mês

Scripts