How to list nodes from a custom mib file using snmpwalk? - snmp

I'm trying to add a custom mib file that contains few nodes.
For an example I tried loading SNMP-COMMUNITY-MIB as it's a standard mib and thus shouldn't throw errors.
I copied the mib into the path
~/.snmp/mibs
and also updated snmpd.conf as:
mibdirs +$HOME/.snmp/mibs
mibs +SNMP-COMMUNITY-MIB
I tried to print the oid of one of the nodes "snmpCommunityName" using:
snmptranslate -m +SNMP-COMMUNITY-MIB -IR -On snmpCommunityName
it worked fine and the oid was printed.
I then tried to list all using snmpwalk:
snmpwalk -v2c -c public localhost
But the nodes from my mib and its oid's were not printed.
How can I have my oids listed on snmpwalk?

I accidentally noticed that when I run snmpwalk without an OID, I get only 593 variables from my device, and the device-specific variables are missing. But if I add 1 as the OID, I get 2527 variables, including the ones which are the most useful. So in your case try adding 1 at the end of the snmpwalk command:
snmpwalk -v2c -c public localhost 1
Edit: The above method worked on an APC PDU, and on a Supermicro BMC. The BMC was a bit confusing because it did not use the OID names from the MIB file, but all the information I need is there.

Related

SNMP (Ubuntu 18.04) on AudioCodes M500L not working

i try to monitor values with nagios over snmp from my two audiocodes SBCs (M500L).
For these i download two MIBs "AC-ALARM-MIB" + "IP-MIB_rfc4293" from https://github.com/librenms/librenms/tree/master/mibs/audiocodes rename it to .txt at the end and upload it to my ubuntu server in path /usr/share/snmp/mibs/.
Then i try to use the following command in command line.
snmpget -v3 -l authPriv -u xxxxxx -a SHA -A xxxxx -x AES -X xxxxx 123.456.789.100 AcAlarm:acActiveAlarmName
and i get the following output
AcAlarm::acActiveAlarmName = No Such Instance currently exists at this OID
I try to find out the OID from these in MIB Browser - seems like it is " .1.3.6.1.4.1.5003.11.1.1.1.1.5". When i use these OID i get same output.
Anyone has an idea?
SNMP treats all values as being entries in some database. OIDs are used to identify entries in this conceptual database. MIB files allow an SNMP manager to translate OIDs into a human-readable string, with an accompanying textual description.
The issue here is not that the MIB files are bad, or the OIDs are wrong, the problem is that, either the devices that hold this (imaginary) database do not support the entries you are trying to access, or that your user is not authorized to access those entries. A simple way to find out what OIDs are supported would be to do a full walk of the database, using something like snmpwalk <hostname> 1.3.6.1

Enabling MIB file with Net-SNMP

I'm using Net-SNMP 5.5.0-2.x64 on Windows 10 1803. I'm trying to get SNMP values from a Ricoh printer. I've downloaded Printer-MIB and placed it in my C:\usr\share\snmp\mibs folder. I also downloaded and placed IANA-CHARSET-MIB and IANA-PRINTER-MIB. I also double checked snmp.conf to make sure they're in the right mibdirs folder.
I'm trying to access the value for black toner. I found some OIDs here, which I was trying to use for my example.
When I try to access the value for black toner:
snmpwalk -v 1 -c public -m Printer-MIB x.x.x.x 1.3.6.1.4.1.367.3.2.1.2.24.1.1.5.1
I get
SNMPv2-SMI::enterprises.367.3.2.1.2.24.1.1.5.1 = INTEGER: 80
I get the same result when I try -m ALL as well. Also if I try added Printer-MIB::printmib at the end, I get the same exact message.
When I try the command:
snmptranslate -IR -Td Printer-MIB::prtMarkerSuppliesLevel.1.1
I get
Printer-MIB::prtMarkerSuppliesLevel.1.1
prtMarkerSuppliesLevel OBJECT-TYPE
-- FROM Printer-MIB
SYNTAX Integer32 (-3..2147483647)
MAX-ACCESS read-write
STATUS current
DESCRIPTION "The current level if this supply is a container; the remaining
space if this supply is a receptacle. If this supply
container/receptacle can reliably sense this value, the value
is reported by the printer and is read-only; otherwise, the
value may be written (by a Remote Control Panel or a Management
Application). The value (-1) means other and specifically
indicates that the sub-unit places no restrictions on this
parameter. The value (-2) means unknown. A value of (-3) means
that the printer knows that there is some supply/remaining
space, respectively."
::= { iso(1) org(3) dod(6) internet(1) mgmt(2) mib-2(1) printmib(43) prtMarkerSupplies(11) prtMarkerSuppliesTable(1) prtMarkerSuppliesEntry(1) prtMarkerSuppliesLevel(9) 1 1 }
So doesn't that mean SNMP sees the file and can parse it?
Edit:
I was able to get the MIB file to work, but the OID values are confusing me. I ran snmpwalk -v 1 -c public x.x.x.x Printer-MIB::printmib and now the values with their MIB tags print. However, when I come across the value for black ink, the OID doesn't match the one I had found online, but they return the same value.
C:\usr\bin>snmpwalk -v 1 -c public x.x.x.x Printer-MIB::prtMarkerSuppliesLevel.1.1
Printer-MIB::prtMarkerSuppliesLevel.1.1 = INTEGER: 80
and
C:\usr\bin>snmpwalk -v 1 -c public x.x.x.x 1.3.6.1.4.1.367.3.2.1.2.24.1.1.5.1 Printer-MIB::printmib
SNMPv2-SMI::enterprises.367.3.2.1.2.24.1.1.5.1 = INTEGER: 80
If I run snmptranslate, I get a completely different OID than the one I had been using before:
C:\usr\bin>snmptranslate -On Printer-MIB::prtMarkerSuppliesLevel.1.1
.1.3.6.1.2.1.43.11.1.1.9.1.1
Not sure why the OID I found online works to retrieve the value, but not to work with the MIB file. Some sort of mix between proprietary and public MIB data?
Try the right OID
snmpwalk ... 1.3.6.1.2.1.43.5.1.1.16

OID addressing with net-snmp

I am extending my snmp agent with a self developed MIB file.
What I've noticed is that when I do a walk it prints my variables as
MY-MIB::myvariable.0
But I've specifically placed the variable at at an OID which is does not end at 0.
I am using the net-snmp library functions:
netsnmp_create_handler_registration
and also
netsnmp_register_read_only_ulong_instance
to register my instances.
It only seems to happen with netsnmp_create_handler_registration. But when I specify reg_oid_len one shorter, it double registers some of the variables.
I am going in to this assuming that your question is 'Why is a 0 appended to my OID?'
In order to access any scalar value you have to append a .0 to the leaf node of the tree. If you were attempting to address a table entry you would need to append the index of the entry into the table. Not using the .0 on a scalar will typically cause problems if you're not using the OID as the argument to something like a bulkget or a walk, i.e.
$ snmpget -v2c -c public 192.168.1.120 1.3.6.1.2.1.1.1.0
SNMPv2-MIB::sysDescr.0 = STRING: things, stuff
$ snmpget -v2c -c public 192.168.1.120 1.3.6.1.2.1.1.1
SNMPv2-MIB::sysDescr = No Such Instance currently exists at this OID
$ snmpwalk -v2c -c public 192.168.1.120 1.3.6.1.2.1.1.1
SNMPv2-MIB::sysDescr.0 = STRING: things, stuff
see this net-snmp mailing list entry for more explicit detail on why scalars end in 0.

set additional folder for snmp MIBs

I am rebuilding an Icinga server that has been left behind by a previous employee. I have everything up and running, except for a bunch of MIB files for 3com switches that I cannot get to work.
The server is a CentOS 6 OpenVZ container.
In the original server there is a bunch of mib files in the default location at /usr/share/snmp/mibs/ and the 3com ones at /usr/share/snmp/mibs/3Com_4500/MIBs. The 3Com mibs work fine:
/usr/lib/nagios/plugins/check_snmp -H 10.10.111.11 -P 2c -C public -o hwDevMFanStatus.65536 -s "active(1)" -m A3COM-HUAWEI-LswDEVM-MIBSNMP OK - active(1) |
In the new server, the MIBs in the 3com folder do not get acknowledged and I get errors like the following:
/usr/lib/nagios/plugins/check_snmp -H 10.10.111.11 -P2c -C someuser -o hwDevMFanStatus.65536 -s "active(1)" -m A3COM-HUAWEI-LswDEVM-MIB
External command error: No log handling enabled - turning on stderr logging
Cannot find module (A3COM-HUAWEI-LswDEVM-MIB): At line 0 in (none)
hwDevMFanStatus.65536: Unknown Object Identifier (Sub-id not found: (top) -> hwDevMFanStatus)
/etc/snmp/snmpd.conf is identical for both servers and so is /etc/sysconfig/snmp.
set does not show any ENV variable related to snmp or mib.
Thanks
You are confusing snmpd.conf and snmp.conf the former being the configuration file for the SNMP daemon whereas Net-SNMP applications use snmp.conf.
The mibs/mibdirs directives you are interested in would be specified in snmp.conf (see also man snmp.conf.

Snmpget returns noSuchName but snmpwalk works, not a instance number issue

I recently hooked up an APC battery backup to one of my servers, I installed the powerchute agent on the server and have verified that I can remotely access the agent and the APC through the agent.
I am trying to get my Cacti install to retrieve my APC data, and everything is working except that it is returning "Result from SNMP not valid. Partial Result: U" and I suspect it is do to the SNMP problem I am having. How can I fix it so the MIB works with the instance number?
From the command line I can successfully GET other OIDs.
----WORKS----
$ snmpget -v1 -cpublic 192.168.1.2 .1.3.6.1.2.1.1.3.0
iso.3.6.1.2.1.1.3.0 = Timeticks: (140629508) 16 days, 6:38:15.08
From the command line I can snmpwalk the powerchute MIB as long as I do not add the final instance number. Adding the instance number causes nothing to be returned.
----WORKS----
$ snmpwalk -v1 -cpublic 192.168.1.2 .1.3.6.1.4.1.318.1.1.1.2.2.3
iso.3.6.1.4.1.318.1.1.1.2.2.3.0 = Timeticks: (72000) 0:12:00.00
----FAILS----
$ snmpwalk -v1 -cpublic 192.168.1.2 .1.3.6.1.4.1.318.1.1.1.2.2.3.0
$
However I can not snmpget any of the powerchute OIDs with or without the instance number.
----FAILS----
$ snmpget -v1 -cpublic 192.168.1.2 .1.3.6.1.4.1.318.1.1.1.2.2.3.0
Error in packet
Reason: (noSuchName) There is no such variable name in this MIB.
Failed object: iso.3.6.1.4.1.318.1.1.1.2.2.3.0
----FAILS----
$ snmpget -v1 -cpublic 192.168.1.2 .1.3.6.1.4.1.318.1.1.1.2.2.3
Error in packet
Reason: (noSuchName) There is no such variable name in this MIB.
Failed object: iso.3.6.1.4.1.318.1.1.1.2.2.3
The fact that snmpwalk returns an OID that you consequently cannot snmpget indicates a bug in the SNMP agent of the device you are accessing.
As frustrating as this is it isn't uncommon, even in enterprise equipment. I've encountered SNMP agent bugs in Cisco and Nortel telecommunications equipment costing hundreds of thousands of dollars.
You do have a work-around. Consider writing a BASH script to snmpwalk the desired value and scrape the result. And tell Cacti to use your custom script instead of accessing via SNMP directly.

Resources