terça-feira, 28 de abril de 2009

Configurando SNMP

Atualmente eu tive uns problemas com a configuração do SNMP e achei legal postar aqui a solução do meu problema.
Revisando... SNMP é Simple Network Management Protocol, que resumindo é o protocolo de gerência de rede. Não irei falar a fundo sobre isso, pois eu não tenho todo o conhecimento sobre isso ^^'

Bom, em primeiro lugar, se o snmp não está instalado, instale-o... isso pode ser feito com o yum install snmp (distribuições derivadas do Red Hat) ou apt-get install snmp (distribuições derivadas do Debian)... E então seguem as configurações:


1° passo: Abra um terminal (shell) e execute o comando snmpconf:
O comando vai te dar uma saída assim:

------------------------------------------------------------------------------
The following installed configuration files were found:

1: /etc/snmp/snmpd.conf
2: /etc/snmp/snmptrapd.conf

Would you like me to read them in? Their content will be merged with the
output files created by this session.

Valid answer examples: "all", "none","3","1,2,5"

Read in which (default = all):
-------------------------------------------------------------------------------

Isso é para saber se você quer importar configurações de arquivos existentes. Escolha "none", pois não importaremos nada.


2° passo: Agora ele vai perguntar sobre que agente de configuração você quer:

-----------------------------------------------------------------------------
I can create the following types of configuration files for you.
Select the file type you wish to create:
(you can create more than one as you run this program)

1: snmpd.conf
2: snmp.conf
3: snmptrapd.conf

Other options: quit

Select File:
-------------------------------------------------------------------------------

Escolha a opção 1 para configurar o agente snmpd, sim, esta é a opção a se escolher ^^.

3° passo: Configurando o snmpd.conf

A próxima mensagem que será exibida é

OBS: É importante lembrar que algumas vezes a ordem da numeração pode vairar, então apenas coloque o numero equivalente a opção escolhida e não haverá problema.

------------------------------------------------------------------------------
The configuration information which can be put into snmpd.conf is divided
into sections. Select a configuration section for snmpd.conf
that you wish to create:

1: Trap Destinations
2: System Information Setup
3: Access Control Setup
4: Extending the Agent
5: Monitor Various Aspects of the Running Host
6: Agent Operating Mode

Other options: finished

Select section:
---------------------------------------------------------------------------

Começaremos escolhendo a opção 2, para configurações do sistema (um pouco óbvio não?)

--------------------------------------------------------------------------
Section: System Information Setup
Description:
This section defines some of the information reported in
the "system" mib group in the mibII tree.

Select from:

1: The [typically physical] location of the system.
2: The contact information for the administrator
3: The proper value for the sysServices object.

Other options: finished, list

Select section:
------------------------------------------------------------------------

Escolha a opção 1

Agora você define onde é o local da sua máquina:

------------------------------------------------------------------------
Configuring: syslocation
Description:
The [typically physical] location of the system.
Note that setting this value here means that when trying to
perform an snmp SET operation to the sysLocation.0 variable will make
the agent return the "notWritable" error code. IE, including
this token in the snmpd.conf file will disable write access to
the variable.
arguments: location_string

The location of the system:
------------------------------------------------------------------------

Escolha o local do sistema.

Após isso ele voltará para a tela anterior, onde tinha 3 opções e escolhemos a opção 1 para definir o local da máquina, e depois pedirá para escolher uma nova opção... Agora escolheremos a opção 2 onde definimos quem será o contato do sistema:

Então uma nova mensagem é exibida:
---------------------------------------------------------------------
Configuring: syscontact
Description:
The contact information for the administrator
Note that setting this value here means that when trying to
perform an snmp SET operation to the sysContact.0 variable will make
the agent return the "notWritable" error code. IE, including
this token in the snmpd.conf file will disable write access to
the variable.
arguments: contact_string

The contact information:
---------------------------------------------------------------------

Escreva o nome da pessoa, ou seu e-mail ou algo assim.

Após isso ele voltará à primeira tela (aquela com as 3 opções) e agora escolheremos a opção 3, onde definiremos os serviços de sua máquina.

Ele mostrará itens onde você deve responder com "0" ou "1"

---------------------------------------------------------------------
Other options: finished, list

Select section: 3


Configuring: sysservices
Description:
The proper value for the sysServices object.
arguments: sysservices_number

does this host offer physical services (eg, like a repeater) [answer 0 or 1]:
--------------------------------------------------------------------

Lembrando que 0 é não e 1 é sim.
Agora ele voltará para a primeira tela (de novo...) e então digite finished, pois as configurações " System Information Setup" acabaram...

4° passo: Voltamos então a tela:

-------------------------------------------------------------------
The configuration information which can be put into snmpd.conf is divided
into sections. Select a configuration section for snmpd.conf
that you wish to create:

1: Trap Destinations
2: System Information Setup
3: Access Control Setup
4: Extending the Agent
5: Monitor Various Aspects of the Running Host
6: Agent Operating Mode

Other options: finished

Select section:
----------------------------------------------------------------------

Escolheremos a opção 3.
A próxima tela a se exibir é:
----------------------------------------------------------------------
Section: Access Control Setup
Description:
This section defines who is allowed to talk to your running
snmp agent.

Select from:

1: a SNMPv3 read-write user
2: a SNMPv3 read-only user
3: a SNMPv1/SNMPv2c read-only access community name
4: a SNMPv1/SNMPv2c read-write access community name

Other options: finished, list

Select section:
----------------------------------------------------------------------

Agora entramos no lado pessoal um pouco, particularmente eu prefiro definir a opção 3, pois eu trabalho com SNMP v2c que na minha opinião é mais viável que o v3 e deixo apenas o acesso a leitura pela comunidade.
Então escolha a opção 3

Após isso a seguinte tela será exibida:

----------------------------------------------------------------------

Select section: 3

Configuring: rocommunity
Description:
a SNMPv1/SNMPv2c read-only access community name
arguments: community [default|hostname|network/bits] [oid]

The community name to add read-only access for:
-----------------------------------------------------------------------

Aqui você escreve o nome da sua comunidade
Depois você verá

------------------------------------------------------------------------
The hostname or network address to accept this community name from [RETURN for all]:
------------------------------------------------------------------------

Tecle ENTER para aceitar todos (isto implicará em uso de qualquer local)
E faça isso com todas as funções... Quando terminar digite Finished.

E depois você voltará ao menu de escolha de agente snmp:

------------------------------------------------------------------------
Select the file type you wish to create:
(you can create more than one as you run this program)

1: snmpd.conf
2: snmp.conf
3: snmptrapd.conf

Other options: quit

Select File:
-----------------------------------------------------------------------

Agora digite quit para sairmos e então será criado o arquivo snmpd.conf no diretório que você digitou o comando "snmpconf". Depois disso você verá o seguinte:

-----------------------------------------------------------------------
The following files were created:

snmpd.conf

These files should be moved to /usr/share/snmp if you
want them used by everyone on the system. In the future, if you add
the -i option to the command line I'll copy them there automatically for you.

Or, if you want them for your personal use only, copy them to
/root/.snmp . In the future, if you add the -p option to the
command line I'll copy them there automatically for you.

------------------------------------------------------------------------

5° passo: Agora o arquivo snmpd.conf foi criado, você deve copiá-lo para o endereço /etc/snmpd ou /etc/snmp em algumas outras versões, com o comando

cp snmpd.conf /etc/snmp

Agora reinicie o daemon e seu snmp estará configurado, utilizando o comando:

/etc/init.d/snmp restart

Lembrando que isso foi feito em derivado do Debian, talvez seja diferente para algumas outras derivações, eu não testei em outras.

OBS: Faça um backup desse arquivo, ele é muito importante, se você perdê-lo, você pode recriá-lo, mas vai dar muito trablho, então é mais fácil fazer um backup.

Perguntem se tiverem dúvida, não ando aparecendo muito mas tentarei resolver problemas referentes a isso... Não sou um gênio, estou aprendendo ainda, mas talevez possa ajudar ^^'

Valeu pessoal! o/~

Um comentário:

Anônimo disse...

Obrigado!
foi de grande ajuda!