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 .188.8.131.52.4.1.43184.108.40.206
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 .220.127.116.11.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 .18.104.22.168.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.
When I do
snmpwalk on server:
snmp-server:# snmpwalk -v 2c -c ncs -m DISMAN-PING-MIB 192.168.5.21 .22.214.171.124.2.1.80 DISMAN-PING-MIB::pingObjects.0 = INTEGER: 1 DISMAN-PING-MIB::pingFullCompliance.126.96.36.199.188.8.131.52.184.108.40.206.220.127.116.11 = STRING: "/bin/echo" DISMAN-PING-MIB::pingMinimumCompliance.18.104.22.168.22.214.171.124.126.96.36.199.188.8.131.52 = "" DISMAN-PING-MIB::pingCompliances.184.108.40.206.220.127.116.11.18.104.22.168.22.214.171.124.48 = "" DISMAN-PING-MIB::pingCompliances.126.96.36.199.188.8.131.52.184.108.40.206.220.127.116.11.48 = INTEGER: 5 DISMAN-PING-MIB::pingCompliances.18.104.22.168.22.214.171.124.126.96.36.199.188.8.131.52.48 = INTEGER: 1 DISMAN-PING-MIB::pingCompliances.184.108.40.206.220.127.116.11.18.104.22.168.22.214.171.124.48 = INTEGER: 1 DISMAN-PING-MIB::pingCompliances.126.96.36.199.188.8.131.52.184.108.40.206.220.127.116.11.48 = INTEGER: 4 DISMAN-PING-MIB::pingCompliances.18.104.22.168.22.214.171.124.126.96.36.199.188.8.131.52.48 = INTEGER: 1 DISMAN-PING-MIB::pingIcmpEcho.184.108.40.206.220.127.116.11.18.104.22.168.22.214.171.124.48 = "" DISMAN-PING-MIB::pingIcmpEcho.126.96.36.199.188.8.131.52.184.108.40.206.220.127.116.11.48 = "" DISMAN-PING-MIB::pingIcmpEcho.18.104.22.168.22.214.171.124.126.96.36.199.188.8.131.52.48 = INTEGER: 1 DISMAN-PING-MIB::pingIcmpEcho.184.108.40.206.220.127.116.11.18.104.22.168.22.214.171.124.48 = INTEGER: 0 DISMAN-PING-MIB::pingMIB.126.96.36.199.188.8.131.52.184.108.40.206.220.127.116.11.18.104.22.168 = ""
When I do snmpget with
root@snmp-server:# snmpget 192.168.5.21 DISMAN-PING-MIB::pingFullCompliance.22.214.171.124.126.96.36.199.188.8.131.52.184.108.40.206 DISMAN-PING-MIB::pingFullCompliance.220.127.116.11.18.104.22.168.22.214.171.124.126.96.36.199 = Wrong Type (should be INTEGER): STRING: "/bin/echo"
So where am I going wrong? And what is pingFullCompliance.188.8.131.52.184.108.40.206.220.127.116.11.18.104.22.168 ? Why such a long OID?
Where am I going wrong? Can anyone point me in the right direction? Any suggestions are greatly appreciated.