Eu quero criar meu próprio MIB. Eu estou lutando com isso de algumas semanas. Eu segui este tutorial e usando net-snmp 5.7.3 . O que estou fazendo é:
My setup: I have two VM's, both Ubuntu 16
, one is snmp-server with IP:192.168.5.20 and the other snmp-agent with IP:192.168.5.21. I wrote a MIB, which compiles good without any error (This compilation is done only on the agent system, not on the server). I have already done this:
root@snmp-agent:# MIBS=+MAJOR-MIB
root@snmp-agent:# MIBS=+DEPENDENT-MIB
root@snmp-agent:# export MIBS
root@snmp-agent:# MIBS=ALL
Meus arquivos MIB estão neste caminho: /usr/share/snmp/mibs
, que é o caminho de pesquisa padrão. Eu já compilei e gerou arquivos .c e .h com sucesso com o comando: mib2c -c mib2c.int_watch.conf objectName
. E que configurado o snmp assim:
root@snmp-agent:# ./configure --with-mib-modules="objectName"
root@snmp-agent:# make
root@snmp-agent:# make install
Tudo funcionou bem. Depois disso, quando eu faço (no agente) snmptranslate
eu recebo a saída como:
root@snmp-agent:snmptranslate -IR objectName.0
MAJOR-MIB::objectName.0
E com o comando snmptranslate -On objectName.0
, recebo a saída como:
root@snmp-agent:# snmptranslate -On MAJOR-MIB::objectName.0
.1.3.6.1.4.1.4331.2.1.0
Então, estou obtendo as saídas esperadas no sistema do agente. Agora meu problema é que não sei como obter os mesmos valores do meu servidor!
Quando executo snmpget
do servidor, recebo este erro:
root@snmp-server:# snmpget -v2c -c public 192.168.5.21 MAJOR-MIB::objectName.0
MAJOR-MIB::objectName.0 = No Such Instance currently exists at this OID
Saída quando especificado o OID:
root@snmp-server:# snmpget -v2c -c public 192.168.5.21 .1.3.6.1.4.1.4331.2.1
SNMPv2-SMI::enterprises.4331.2.1 = No Such Instance currently exists at this OID
Saída quando eu fizer isso:
root@snmp-server:# snmpget -v2c -c public 192.168.5.21 sysDescr.0
SNMPv2-MIB::sysDescr.0 = STRING: Linux snmp-agent 4.10.0-33-generic #37~16.04.1-Ubuntu SMP Fri Aug 11 14:07:24 UTC 2017 x86_64
root@snmp-server:# snmpwalk -v2c -c public 192.168.5.21 .1.3.6.1.4.1.4331.2.1
SNMPv2-SMI::enterprises.4331.2.1 = No more variables left in this MIB View (It is past the end of the MIB tree)
Eu pesquisei e ainda estou procurando, mas sem sorte. O que devo fazer? Como devo usar snmpget
do meu servidor nos meus próprios MIBs? Quero dizer algo como eu faço com sysDescr.0
do meu servidor.
Eu quero fazer isso: snmpget 192.168.5.21 myObjectName.0
e obter os valores.
EDIT: I have already seen these answers, but doesn't works. snmp extend not working and snmp no such object...
UPDATE 2:
Quando faço snmpwalk
no servidor:
snmp-server:# snmpwalk -v 2c -c ncs -m DISMAN-PING-MIB 192.168.5.21 .1.3.6.1.2.1.80
DISMAN-PING-MIB::pingObjects.0 = INTEGER: 1
DISMAN-PING-MIB::pingFullCompliance.15.46.49.46.51.46.54.46.49.46.50.46.49.46.56.48 = STRING: "/bin/echo"
DISMAN-PING-MIB::pingMinimumCompliance.15.46.49.46.51.46.54.46.49.46.50.46.49.46.56.48 = ""
DISMAN-PING-MIB::pingCompliances.4.15.46.49.46.51.46.54.46.49.46.50.46.49.46.56.48 = ""
DISMAN-PING-MIB::pingCompliances.5.15.46.49.46.51.46.54.46.49.46.50.46.49.46.56.48 = INTEGER: 5
DISMAN-PING-MIB::pingCompliances.6.15.46.49.46.51.46.54.46.49.46.50.46.49.46.56.48 = INTEGER: 1
DISMAN-PING-MIB::pingCompliances.7.15.46.49.46.51.46.54.46.49.46.50.46.49.46.56.48 = INTEGER: 1
DISMAN-PING-MIB::pingCompliances.20.15.46.49.46.51.46.54.46.49.46.50.46.49.46.56.48 = INTEGER: 4
DISMAN-PING-MIB::pingCompliances.21.15.46.49.46.51.46.54.46.49.46.50.46.49.46.56.48 = INTEGER: 1
DISMAN-PING-MIB::pingIcmpEcho.1.15.46.49.46.51.46.54.46.49.46.50.46.49.46.56.48 = ""
DISMAN-PING-MIB::pingIcmpEcho.2.15.46.49.46.51.46.54.46.49.46.50.46.49.46.56.48 = ""
DISMAN-PING-MIB::pingIcmpEcho.3.15.46.49.46.51.46.54.46.49.46.50.46.49.46.56.48 = INTEGER: 1
DISMAN-PING-MIB::pingIcmpEcho.4.15.46.49.46.51.46.54.46.49.46.50.46.49.46.56.48 = INTEGER: 0
DISMAN-PING-MIB::pingMIB.4.1.2.15.46.49.46.51.46.54.46.49.46.50.46.49.46.56.48.1 = ""
Quando faço snmpget com pingFullCompliance.15.46.49.46.51.46.54.46.49.46.50.46.49.46.56.48
:
root@snmp-server:# snmpget 192.168.5.21 DISMAN-PING-MIB::pingFullCompliance.15.46.49.46.51.46.54.46.49.46.50.46.49.46.56.48
DISMAN-PING-MIB::pingFullCompliance.15.46.49.46.51.46.54.46.49.46.50.46.49.46.56.48 = Wrong Type (should be INTEGER): STRING: "/bin/echo"
Então, onde estou indo errado? E o que é pingFullCompliance.15.46.49.46.51.46.54.46.49.46.50.46.49.46.56.48
? Por que um longo OID?
Onde estou indo errado? Alguém pode me apontar na direção certa? Qualquer sugestão é muito apreciada.