Writing this post because I didn’t really find a lot of great full walk-throughs for doing this when I had to today. Basically what I’m doing here is I’ve got a relatively uncommon device (ControlByWeb PLC) that I’m looking to monitor via SNMP with Zabbix. In the past I think I’ve used some SNMP walk tools to walk the MIB and create a Zabbix template from it, but I didn’t really have much luck figuring out how to do that this time around, so here is the walk-through for opening up a MIB file and creating Host Items in Zabbix for the things you’d like to monitor.

First things first, I didn’t really have much knowledge of SNMP MIBs other than importing them into SNMP-based tools to tell them how to query the device for the particular data that we’re looking for. I’ve never actually had to build a MIB file or write an SNMP query. With that in mind, I opened up the MIB file to see what it looked like. Below is the top section of the particular MIB I was working with. The reason that I pasted this in is because I had no idea what any of this meant, so I want to walk through what I’ve learned.

XYTRONIX-MIB DEFINITIONS ::= BEGIN

IMPORTS
        enterprises, MODULE-IDENTITY, OBJECT-TYPE, NOTIFICATION-TYPE
                FROM SNMPv2-SMI
        DisplayString
                FROM SNMPv2-TC;

x410 MODULE-IDENTITY
        LAST-UPDATED "201708281200Z"
        ORGANIZATION "Xytronix Research & Design"
        CONTACT-INFO "www.ControlByWeb.com"
        DESCRIPTION "X-410 MIB"
        REVISION "201708281200Z"
        DESCRIPTION ""
        ::= {enterprises 30586 46}

xytronix          OBJECT IDENTIFIER ::= {enterprises 30586}

io                OBJECT IDENTIFIER ::= {x410 0}
pulseTimer        OBJECT IDENTIFIER ::= {x410 1}
counter           OBJECT IDENTIFIER ::= {x410 2}
onTimer           OBJECT IDENTIFIER ::= {x410 3}
totalOnTimer      OBJECT IDENTIFIER ::= {x410 4}
frequency         OBJECT IDENTIFIER ::= {x410 5}

notifications                 OBJECT IDENTIFIER ::= {x410 100}
ioNotifications               OBJECT IDENTIFIER ::= {notifications 0}
counterNotifications          OBJECT IDENTIFIER ::= {notifications 2}
onTimerNotifications          OBJECT IDENTIFIER ::= {notifications 3}
totalOnTimerNotifications     OBJECT IDENTIFIER ::= {notifications 4}
frequencyNotifications        OBJECT IDENTIFIER ::= {notifications 5}


upstairsThermostat OBJECT-TYPE
  SYNTAX  DisplayString
  MAX-ACCESS  read-only
  STATUS  current
  DESCRIPTION
		"Upstairs Thermostat"
  ::= {io 1}


downstairsThermostat OBJECT-TYPE
  SYNTAX  DisplayString
  MAX-ACCESS  read-only
  STATUS  current
  DESCRIPTION
		"Downstairs Thermostat"
  ::= {io 2}


floodSensor OBJECT-TYPE
  SYNTAX  DisplayString
  MAX-ACCESS  read-only
  STATUS  current
  DESCRIPTION
		"Flood Sensor"
  ::= {io 3}

Since I had no idea at all what I was looking at, I wanted to understand the terms listed (Object Identifier, Object-Type, etc.) so I popped out to the IETF to read through some of the documentation (https://tools.ietf.org/html/rfc2578#page-15 if you are as inclined as I was). This didn’t make as much sense to me as I was hoping it would, but I did find out that Object Identifier seems to be a hierarchical parent to these other types, helpful!

I knew that I still had to put the MIB file on the server (Ubuntu, with SNMP already installed) if you haven’t gotten that far, start here https://l3net.wordpress.com/2013/05/12/installing-net-snmp-mibs-on-ubuntu-and-debian/ then copy your MIB to /usr/share/snmp/mibs/ and restart both SNMP services and Zabbix server, or if you’re like me and want to be sure just reboot it.

Once that is done you should be able to SNMP walk your device from the CLI. This is where I got thrown off. Looking at this documentation (here https://www.zabbix.com/documentation/4.0/manual/config/items/itemtypes/snmp/mibs) it looks like the proper command is snmpwalk -v 2c -c <community> <NETWORK DEVICE IP> ifInOctets which I tried and got nothing but errors (basically for other MIBs that were malformed).

Well, I’m an idiot. Obviously the ifInOctets is supposed to be replaced with the specific Object Identifier that I’m looking for. This is where the above snippet comes in handy. Looking at that, you can see that there are some top-level Object Identifiers identified there, io, pulseTimer, counter, onTimertotalOnTimer, frequency. So I tried snmpwalk -v 2c -c <community> <NETWORK DEVICE IP> X410::io because the name of my MIB file was called X410.mib.

Wrong again. Looking at another MIB that I was currently utilizing and comparing that to the discovery rule in Zabbix, I realized that the MIB file name is not how you are supposed to address them, it is by what is outlined inside the file. Again going back to the snippet, you can see that the file starts out with XYTRONIX-MIB right before the word DEFINITIONS. That’s how we’re supposed to address that MIB. One more time snmpwalk -v 2c -c <community> <NETWORK DEVICE IP> XYTRONIX-MIB::io.

XYTRONIX-MIB::upstairsThermostat = STRING: 0
XYTRONIX-MIB::downstairsThermostat = STRING: 0
XYTRONIX-MIB::floodSensor = STRING: 0
XYTRONIX-MIB::digitalInput4 = STRING: 0
XYTRONIX-MIB::relay1 = STRING: 0
XYTRONIX-MIB::relay2 = STRING: 0
XYTRONIX-MIB::relay3 = STRING: 0
XYTRONIX-MIB::relay4 = STRING: 0
XYTRONIX-MIB::vin = STRING: 0.0
XYTRONIX-MIB::register1 = STRING: 0
XYTRONIX-MIB::sacristyTempSensor = STRING: 58.8
XYTRONIX-MIB::minute45 = STRING: 0

Bingo. Well that’s good, I have successfully tested the MIB file. Now how do I get Zabbix to use it?

I initially started attempting to write some discovery rules to automatically go through and read everything off of the device and create Items for each thing, but that seemed a bit extra complicated for my first day and since this is kind of a one-off anyway I figured I’d just create the Items manually for the Host. (Did you know you could do that? I didn’t. Not a power user of Zabbix that’s for sure)

After having gone through the snmpwalk process as a part of this, creating the Items manually was pretty straightforward. Here’s a screenshot of the first item in the MIB, upstairsThermostat.

And that’s it! Now I’ve got data coming in for that OID (or Object Identifier 😉 ). I’m sure that I will play around with Discovery Rules and once I get them working there will be another post about how to create Discovery Rules.

One thing I will make mention of is that this is a somewhat unique MIB case because the device creates a brand new MIB file for itself every time a configuration change is made, which is why you may have noticed that each individual device was in the MIB by name. A lot of times (from my understanding) a MIB will have a *type* of OID (interface, CPU time, etc.) and then will recursively query to find all of the individual items matching that OID. If that is the case, what you’ll have above instead of XYTRONIX-MIB::upstairsThermostat when you do a snmpwalk you’ll just see multiples of the same type of item. I just did an snmpwalk of another device that I have to give you an example. When creating Items in Zabbix for these, you’ll obviously just use the .1, .2, etc. to identify them.

IF-MIB::ifDescr.1 = STRING: LOOPBACK
IF-MIB::ifDescr.2 = STRING: lance