Why do SNMP agents need MIB files?

You have a fundamental misunderstanding of how SNMP works. Quick and dirty comparison: SNMP MIBs are the like hostnames. MIBs map OIDs to a friendly name -- for example
.1.3.6.1.2.1.1.1.0 => SNMPv2-MIB::sysDescr.0 => Host Description (uname output).

In order to retrieve information from an SNMP server (agent) that information must be published at a specific OID.
In order for an SNMP daemon to publish information it needs (typically) two things:

  1. A way of getting that information (script, program, etc.)
  2. A place to put that information (an OID)
    (Some SNMP daemons may also require a MIB file mapping the OID)

In order for you to retrieve the information you must know the OID - this can either be a numeric OID or a "friendly" name out of a MIB file on your SNMP Client.

SNMP "browsers" typically require a MIB file because without one all they can present to you is a meaningless list of numbers.

So the answer to your question is "You don't NEED MIB files, they're just helpful for humans who need to interact with SNMP".


Taking your example (reporting a queue length), it sounds from the tutorial you liked to like you're using net-snmp (UCD-SNMP).
net-snmp includes built-in facilities for this sort of thing -- read through the man page and example configuration file (pay special attention to the exec directive for running external scripts: Typically you would run a script that prints the queue length, and query that OID in your monitoring software/SNMP Client)