I want to create my own MIB. I'm struggling on this from couple of weeks. I followed this tutorial and using net-snmp 5.7.3. What I'm doing is:
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
My MIB files are in this path: /usr/share/snmp/mibs
which is the default search path. I've already compiled it and generated .c and .h files successfully with the command: mib2c -c mib2c.int_watch.conf objectName
. And than configured the snmp like this:
root@snmp-agent:# ./configure --with-mib-modules="objectName"
root@snmp-agent:# make
root@snmp-agent:# make install
Everything worked fine. After this when I do (on the agent) snmptranslate
I get the output as:
root@snmp-agent:snmptranslate -IR objectName.0
MAJOR-MIB::objectName.0
And with the command snmptranslate -On objectName.0
I get output as:
root@snmp-agent:# snmptranslate -On MAJOR-MIB::objectName.0
.1.3.6.1.4.1.4331.2.1.0
So, I'm getting the expected outputs on the agent system. Now my problem is I don't know how to get the same values from my server!
When I run snmpget
, from the server, I get this error:
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
Output when specified the 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
Output when I do these:
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)
I have searched it and still searching but no luck. What should I do? How should I use snmpget
from my server on my own MIBs? I mean something like I do with sysDescr.0
from my server.
I want to do this: snmpget 192.168.5.21 myObjectName.0
and get the values.
EDIT: I have already seen these answers, but doesn't works. snmp extend not working and snmp no such object...
UPDATE 2:
When I do snmpwalk
on server:
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 = ""
When I do snmpget with 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"
So where am I going wrong? And what is pingFullCompliance.15.46.49.46.51.46.54.46.49.46.50.46.49.46.56.48 ? Why such a long OID?
Where am I going wrong? Can anyone point me in the right direction? Any suggestions are greatly appreciated.