Why do SNMP agents need MIB files

net-snmpsnmp

After reading up on SNMP and some of the questions help here I think understand the agent role as a SNMP service to device (Like SQL, it is an API to storage).

When you execute a SQL query the SQL engine does all the work and returns the result – You don't need to be aware of how the storage and where the storage is done.

But MIBs are not actual storage , so what is the role of my agent?
if the agent only register the MIB like i follow in this tutorial, so it not used as handler at all and it means that there is a pyhiscal storage that you can set and get to there without bypass the handler.
in the tutorial all you do it this:

netsnmp_register_int_instance("my example int variable",
                                  my_registration_oid,
                                  OID_LENGTH(my_registration_oid),
                                  &example1, NULL);

no need in handler to process calls.

Say that I want monitor my application's pending request queue, so I want an agent that all SNMP request for application_pending_request will be fired for it and it will return the queue depth. Why do I need to have an actual MIB when all I need to poll my application queue in order to get result?

Best Answer

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)

Related Topic