# How do I associated downloaded MIB files?



## jbruyet (Jan 23, 2014)

Hey all, I'm working on getting my Nagios configured so I can monitor things like toner levels in my network printers. At this point I'm trying to find the OIDs for the different items to monitor and not having much help. I contacted HP and they sent me a MIB file but when I grep for those items in the results of my snmpwalks they aren't there. I don't have much experience with snmp and Googling gives me a ton of hits for everything except what I'm trying to find. My question -- is there a way to associate a MIB file with an snmpwalk so I can figure out which OIDs to monitor and which values to alert on? Or how about a good tutorial for snmp? Preferably one that's not devcice-specific. 

Thanks,

Joe B


----------



## SirDice (Jan 24, 2014)

If I remember correctly you have to store those MIBs in /usr/local/share/snmp/mibs/. Here's a tutorial that explains where to put them and how to use them:
http://net-snmp.sourceforge.net/tutoria ... tions.html


----------



## jbruyet (Jan 24, 2014)

Thank you SirDice, I'll do that later today.

Thanks,

Joe B


----------



## SirDice (Jan 24, 2014)

What the MIB files basically do is enable you to use queries like sysDescr instead of having to use numbers like 1.3.6.1.2.1.1.1. You can always access the data by it's numbers, you don't need to have the MIB for that. But those numbers are tricky to remember and it's easy to make a mistake. 

Think of it in the same way as the relation between DNS and IP. Using the IP address always works but humans can more easily remember a name like forums.freebsd.org. It's the same thing with SNMP, the MIBs allow you to translate back and forth between the numbers and names. But the system will always use the numbers.


----------



## jbruyet (Jan 24, 2014)

Thank you for that explanation. Your DNS --> IP analogy made it crystal clear. 

Thanks,

Joe B


----------



## jbruyet (Jan 25, 2014)

Ok, I'm not having any luck here. I have the downloaded MIB in the right location but the system just isn't seeing it: 


```
root@FreeNag:/usr/local/share/snmp/mibs # ls -l | grep HP
-rw-r--r--  1 root  wheel  637037 Jan 24 16:38 HP-LASERJET-COMMON-MIB.mib
-rw-r--r--  1 root  wheel  637037 Jan 24 15:38 HP-LASERJET-COMMON-MIB.mib.txt
root@FreeNag:/usr/local/share/snmp/mibs # snmptranslate -m HP-LASERJET-COMMON-MIB.mib.txt -IR lowToner
MIB search path: /root/.snmp/mibs:/usr/local/share/snmp/mibs
Cannot find module (HP-LASERJET-COMMON-MIB.mib.txt): At line 0 in (none)
Unknown object identifier: lowToner
root@FreeNag:/usr/local/share/snmp/mibs # grep -i lowtoner HP-LASERJET-COMMON-MIB.mib.txt
                    lowToner          2        warning(3)
                lowToner -- Toner is almost gone.  The quality of printed pages will begin
root@FreeNag:/usr/local/share/snmp/mibs #
```

FWIW I've used both the .mib version and the .mib.txt version of the MIB file in my snmptranslate line and I get the same result either way. Also, per the link, I have both the .mib and the .mib.txt lines in my snmpd.conf file: 


```
root@FreeNag:/usr/local/share/snmp # cat snmpd.conf
mibs HP-LASERJET-COMMON-MIB.mib.txt
mibs HP-LASERJET-COMMON-MIB.mib
root@FreeNag:/usr/local/share/snmp #
```

Can anyone see a problem with the way I'm doing this? 

Thanks,

Joe B


----------



## jbruyet (Jan 25, 2014)

ARGH!!!! Ok, I just re-read the page for about the 30th time and saw that my command was slightly off. I removed the .mib part of the command and now I get a stack of errors like these: 


```
Cannot adopt OID in HP-LASERJET-COMMON-MIB: io-buffer-size ::= { settings-io 6 }
Cannot adopt OID in HP-LASERJET-COMMON-MIB: io-buffering ::= { settings-io 5 }
Cannot adopt OID in HP-LASERJET-COMMON-MIB: io-switch ::= { settings-io 2 }
Cannot adopt OID in HP-LASERJET-COMMON-MIB: io-timeout ::= { settings-io 1 }
Cannot adopt OID in HP-LASERJET-COMMON-MIB: status-message ::= { display 2 }
Cannot adopt OID in HP-LASERJET-COMMON-MIB: display-status ::= { display 1 }
Cannot adopt OID in HP-LASERJET-COMMON-MIB: mio2-type ::= { mio2 4 }
```

Per the web page I'm thinking there's a "Cannot find module" message in the output but I can't pipe the output into a file or into less to find it. Any other suggestions? 

Thanks,

Joe B


----------



## jbruyet (Feb 8, 2014)

Well, I'm not sure what to do now. I've downloaded the MIB files from HP but apparently FreeBSD doesn't like the configuration: 


```
root@FreeNag:/usr/local/share/snmp/mibs # snmptranslate HP-LASERJET-COMMON-MIB::hrDeviceStatus
Unlinked OID in HP-LASERJET-COMMON-MIB: hp ::= { enterprises 11 }
Undefined identifier: enterprises near line 5 of /usr/local/share/snmp/mibs/HP-MIB.txt
HP-LASERJET-COMMON-MIB::hrDeviceStatus: Unknown Object Identifier
root@FreeNag:/usr/local/share/snmp/mibs # head -n 10 HP-MIB.txt
-- THIS MIB CREATED TO REDUCE DUPLICATION BETWEEN HP LASERJET MIBS

HP-LASERJET-COMMON-MIB DEFINITIONS ::= BEGIN

hp OBJECT IDENTIFIER ::= { enterprises 11 }
nm OBJECT IDENTIFIER ::= { hp 2 }
hpsystem OBJECT IDENTIFIER ::= { nm 3 }
net-peripheral OBJECT IDENTIFIER ::= { hpsystem 9 }
netdm OBJECT IDENTIFIER ::= { net-peripheral 4 }
dm OBJECT IDENTIFIER ::= {  netdm 2}
root@FreeNag:/usr/local/share/snmp/mibs #
```
Anybody have any idea why it doesn't like this line? 


```
hp OBJECT IDENTIFIER ::= { enterprises 11 }
```

Thanks,

Joe B


----------



## SirDice (Feb 8, 2014)

Sometimes an MIB depends on other MIBs. You have to include them all or you get errors.


----------



## jbruyet (Feb 8, 2014)

Sigh, I just grabbed the one MIB from HP's site. I'll head back there and see what I can come up with.

Thanks,

Joe B


----------

