Instalando e configurando o serviço snmpd no red hat 5.3 cent_os

4
SNMP é usado como parte de monitoramento de utilização de recursos em dispositivos ligados na rede, informa utilização de CPU, tráfego de rede, status de serviços e etc. Estou escrevendo esse artigo por que será pré-requisito na configuração e instalação do Cacti para “grafar” os recursos dos dispositivos monitorados. Pré-requisitos Instalação mínima do CentOS e RedHat 5.3 Instalação do serviço SNMPd A instalação será feita via Yum É interessante garantir que o serviço será iniciado no boot Configurando o serviço SNMP Depois de instalado, o SNMP precisa ser configurado para responder a uma comunidade e em que modo ele irá responder. Também é interessante colocar uma descrição de quem é o responsável pelo servidor e onde está localizado o equipamento. Para iniciar a configuração, vá ao diretório /etc/snmp e apague o arquivo original que está lá ou renomeie, caso queira futuramente consultá-lo. Inicie o processo de configuração com o comando snmpconf, faz parte do pacote net-snmp-utils e é uma mão na roda, diga-se de passagem Uma série de questionários será apresentada. Na primeira fase Selecione 1 para gerar o arquivo snmpd.conf que é o responsável por colher as métricas de utilização de recursos do SO. Aqui nessa sessão da configuração tem uma pegadinha: nem sempre a ordem apresentada é a mesma, então, preste atenção na opção escolhida. A primeira configuração é informações de acesso, então é a opção 2 “Access Control Setup” yum install net‐snmp.i386 net‐snmp‐libs.i386 net‐snmp‐utils.i386 ... Installed: net‐snmp.i386 1:5.3.2.2‐5.el5_3.2 net‐snmp‐libs.i386 1:5.3.2.2‐5.el5_3.2 net‐snmp‐utils.i386 1:5.3.2.2‐5.el5_3.2 Dependency Installed: lm_sensors.i386 0:2.10.7‐4.el5 Complete! chkconfig ‐‐levels 35 snmpd on 1 cd /etc/snmp 2 mv snmpd.conf snmpd.conf.orig 1 cd /etc/snmp 2 snmpconf 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: 1 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: Monitor Various Aspects of the Running Host 2: Access Control Setup 3: Extending the Agent 4: Trap Destinations 5: System Information Setup 6: Agent Operating Mode Other options: finished Select section: 2 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 Instalando e configurando o serviço SNMPd no Red Hat 5.3 / CentOS 5.3... http://www.fogonacaixadagua.com.br/2009/09/instalando-e-configuran... 1 de 4 11/8/2011 13:42

Transcript of Instalando e configurando o serviço snmpd no red hat 5.3 cent_os

Page 1: Instalando e configurando o serviço snmpd no red hat 5.3   cent_os

SNMP é usado como parte de monitoramento de utilização de recursos em dispositivos ligados na rede, informa utilização de CPU, tráfego de rede,status de serviços e etc.

Estou escrevendo esse artigo por que será pré-requisito na configuração e instalação do Cacti para “grafar” os recursos dos dispositivos monitorados.

Pré-requisitos

Instalação mínima do CentOS e RedHat 5.3

Instalação do serviço SNMPd

A instalação será feita via Yum

É interessante garantir que o serviço será iniciado no boot

Configurando o serviço SNMP

Depois de instalado, o SNMP precisa ser configurado para responder a uma comunidade e em que modo ele irá responder.

Também é interessante colocar uma descrição de quem é o responsável pelo servidor e onde está localizado o equipamento.

Para iniciar a configuração, vá ao diretório /etc/snmp e apague o arquivo original que está lá ou renomeie, caso queira futuramente consultá-lo.

Inicie o processo de configuração com o comando snmpconf, faz parte do pacote net-snmp-utils e é uma mão na roda, diga-se de passagem

Uma série de questionários será apresentada.

Na primeira fase

Selecione 1 para gerar o arquivo snmpd.conf que é o responsável por colher as métricas de utilização de recursos do SO.

Aqui nessa sessão da configuração tem uma pegadinha: nem sempre a ordem apresentada é a mesma, então, preste atenção na opção escolhida.

A primeira configuração é informações de acesso, então é a opção 2 “Access Control Setup”

yum install net‐snmp.i386 net‐snmp‐libs.i386 net‐snmp‐utils.i386

...Installed: net‐snmp.i386 1:5.3.2.2‐5.el5_3.2 net‐snmp‐libs.i386 1:5.3.2.2‐5.el5_3.2 net‐snmp‐utils.i3861:5.3.2.2‐5.el5_3.2Dependency Installed: lm_sensors.i386 0:2.10.7‐4.el5Complete!

chkconfig ‐‐levels 35 snmpd on

1 cd /etc/snmp2 mv snmpd.conf snmpd.conf.orig

1 cd /etc/snmp2 snmpconf

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: 1

The configuration information which can be put into snmpd.conf is dividedinto sections. Select a configuration section for snmpd.confthat you wish to create: 1: Monitor Various Aspects of the Running Host 2: Access Control Setup 3: Extending the Agent 4: Trap Destinations 5: System Information Setup 6: Agent Operating Mode Other options: finished Select section: 2

Section: Access Control SetupDescription: This section defines who is allowed to talk to your running snmp agent. Select from: 1: a SNMPv3 read‐write user

Instalando e configurando o serviço SNMPd no Red Hat 5.3 / CentOS 5.3... http://www.fogonacaixadagua.com.br/2009/09/instalando-e-configuran...

1 de 4 11/8/2011 13:42

Page 2: Instalando e configurando o serviço snmpd no red hat 5.3   cent_os

Permitir acesso somente leitura aos dados do servidor. Evita algumas surpresas :)

Opção escolhida: 3 “SNMPv1/SNMPv2c read-only access community name”

Nome da comunidade, não coloque “public” por que é muito manjada, e qualquer network scanner vai testar por isso, escolha uma mais difícil, colocandonúmeros e letras maiúsculas e minúsculas, evite colocar símbolos como $, #, % etc, vai confundir e gerar problemas futuros para scripts e para o próprioCacti. Se utilizar o Nagios então, tá perdido ;)

O nome escolhido aqui foi 5nMPC0mmunity

Quem vai ter acesso ao serviço SNMP, se pressionar direto vai liberar pra todos que souberem o nome da comunidade, caso queira restringir a um host apenas,coloque o IP do host, se é para um rede, coloque a rede aqui no formato 192.168.0.0/24

Se quer permitir a visualização de apenas alguns recursos, coloque o OID do recurso aqui, no caso, vou deixar liberado para todos os recursos seremvisualizados

Finalizada a configuração de controle de acesso, vai voltar para a sessão própria. Como está terminado escreva finished ou apenas f para sair e voltar aomenu principal.

Próxima fase, informar detalhes do dispositivo, como contato e localização física.

Escolha a opção 5 “System Information Setup” e pressione

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: 3

Configuring: rocommunityDescription: a SNMPv1/SNMPv2c read‐only access community name arguments: community [default|hostname|network/bits] [oid] The community name to add read‐only access for: 5nMPC0mmunity

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

The OID that this community should be restricted to [RETURN for no‐restriction]:

Section: Access Control SetupDescription: 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: finished

The configuration information which can be put into snmpd.conf is dividedinto sections. Select a configuration section for snmpd.confthat you wish to create: 1: Monitor Various Aspects of the Running Host 2: Access Control Setup 3: Extending the Agent 4: Trap Destinations 5: System Information Setup 6: Agent Operating Mode Other options: finished Select section: 5

Section: System Information SetupDescription: 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

Instalando e configurando o serviço SNMPd no Red Hat 5.3 / CentOS 5.3... http://www.fogonacaixadagua.com.br/2009/09/instalando-e-configuran...

2 de 4 11/8/2011 13:42

Page 3: Instalando e configurando o serviço snmpd no red hat 5.3   cent_os

Opção escolhida 1, para informações de localização do equipamento

Informado onde está o equipamento Data Center, Rack 3, pressione quando terminar.

Voltando para a tela de configuração com informações do equipamento, selecione a opção 2 para dizer quem é o responsável

Informe alguns dados que facilitem a localização do responsável. Aqui foi informado Daniel Kühl Lima. Pressione quando terminar e voltará para a tela deconfiguração de informações.

Sessão terminada, dá pra sair dessa tela e voltar ao menu principal. Escreve finished ou f para sair.

Voltando para o menu principal, e como está tudo configurado como desejamos, escreva finished ou f para salvar e terminar a tarefa.

Select section: 1

Configuring: syslocationDescription: 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: Data Center, Rack 3

Section: System Information SetupDescription: 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: 2

Configuring: syscontactDescription: 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: Daniel Kühl Lima

Section: System Information SetupDescription: 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: finished

The configuration information which can be put into snmpd.conf is dividedinto sections. Select a configuration section for snmpd.confthat you wish to create: 1: Monitor Various Aspects of the Running Host 2: Access Control Setup 3: Extending the Agent 4: Trap Destinations 5: System Information Setup 6: Agent Operating Mode Other options: finished Select section: finished

I can create the following types of configuration files for you.Select the file type you wish to create:

Instalando e configurando o serviço SNMPd no Red Hat 5.3 / CentOS 5.3... http://www.fogonacaixadagua.com.br/2009/09/instalando-e-configuran...

3 de 4 11/8/2011 13:42

Page 4: Instalando e configurando o serviço snmpd no red hat 5.3   cent_os

Escreva quit para sair de vez.

Iniciando o serviço SNMP

Com o serviço configurado é hora de iniciar.

Verificando o funcionamento

Pra verificar se está tudo a contento, execute o comando a seguir que irá se conectar ao serviço SNMP e retornará as métricas do sistema.

SNMPv2-MIB::sysDescr.0 = STRING: Linux localhost.localdomain 2.6.30.5-fogonacaixadagua #7 SMP Fri Sep 11 11:32:29 BRT 2009 i686SNMPv2-MIB::sysObjectID.0 = OID: NET-SNMP-MIB::netSnmpAgentOIDs.10DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (13823) 0:02:18.23SNMPv2-MIB::sysContact.0 = STRING: "Daniel Kühl Lima"SNMPv2-MIB::sysName.0 = STRING: localhost.localdomainSNMPv2-MIB::sysLocation.0 = STRING: "Data Center, Rack 3"SNMPv2-MIB::sysORLastChange.0 = Timeticks: (9) 0:00:00.09

...

No final do processo o arquivo /etc/snmp/snmpd.conf ficou assim:

############################################################################# snmpd.conf## - created by the snmpconf configuration program#

############################################################################ SECTION: Access Control Setup## This section defines who is allowed to talk to your running# snmp agent.

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

rocommunity 5nMPC0mmunity

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

# syslocation: 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

syslocation "Data Center, Rack 3"

# syscontact: 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

syscontact "Daniel Kühl Lima"

Pronto.

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: quit

1 service snmpd start

1 Starting snmpd: [ OK ]

1 snmpwalk ‐c 5nMPC0mmunity ‐v2c localhost

Instalando e configurando o serviço SNMPd no Red Hat 5.3 / CentOS 5.3... http://www.fogonacaixadagua.com.br/2009/09/instalando-e-configuran...

4 de 4 11/8/2011 13:42