[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 430
  • Last Modified:

Simple MIB and how to use it from sending application

Hi all,

I'm new to SNMP, and
I need to create a very simple MIB file, with maybe 3-4 OIDs, and then send a trap that would contain one of them.
I tried to do my homework, but I'm baffled with complexity and incoherence of presentation, so please help.
An extremely simple example of an MIB and an example of how to send it (from C#, C++, a utility that does that - anything, as long as the list of parameters is intelligible or explained) will be perfect.
Kinda taking an easy way out here, but it doesn't hurt to try ;-)
Any help is appreciated,
Gene
0
Mi-Jack
Asked:
Mi-Jack
  • 4
  • 3
1 Solution
 
Steve JenningsIT ManagerCommented:
Creating your own MIB is non-trivial. You dont want to write your own code to do it. You need to get a C SNMP library and call it from your code. You should be able to google for sample C code and a library. No offense, but if you are having trouble at this stage you may be way in over your head. Look at PERL and snmp lib for some examples.

Good liuck,
Steve
0
 
Mi-JackAuthor Commented:
I can send and receive in both C++ and C#, I just don't know how utilize an MIB, thats all.
Meaning: if I have an MIB that is specific to a company or product, how do I send a trap to reference that specific information? I can reference an OID defined in that MIB, but what else? How?

Sorry if I didn't make myself clear.
0
 
Steve JenningsIT ManagerCommented:
So you C code is acting as thr agent? I see. Sorry. Then you need the conf files to be able to map the mib to. EG, "threshold reached" might be OID 1.2.3.4.5. So you find that oid in the MIB and send the variables associated with it. That is. 1.2 might be the company, 3 might be the entity (CPU) 4 might be five minute rate and 5 might be exceeded.

Good luck,
Steve
0
Will You Be GDPR Compliant by 5/28/2018?

GDPR? That's a regulation for the European Union. But, if you collect data from customers or employees within the EU, then you need to know about GDPR and make sure your organization is compliant by May 2018. Check out our preparation checklist to make sure you're on track today!

 
Mi-JackAuthor Commented:
Exactly, but how?
I need a one-line example of an MIB entry, then, but this is making more sense already.
0
 
Mi-JackAuthor Commented:
not sure what to do with this question. no input, close it please.
0
 
Steve JenningsIT ManagerCommented:

So here's part of a MIB entry.

********************************************************************
ifOperStatus OBJECT-TYPE
    SYNTAX  INTEGER {
                up(1),        -- ready to pass packets
                down(2),
                testing(3),   -- in some test mode
                unknown(4),   -- status can not be determined
                              -- for some reason.
                dormant(5),
                notPresent(6),    -- some component is missing
                lowerLayerDown(7) -- down due to state of
                                  -- lower-layer interface(s)
            }
********************************************************************

And the last number (1 thru 7) in the ASN notation for the MIB would indicate the interface status (ifOperStatus). So an agent on a Cisco router, for example, would receive a SNMP get in the form of an IOD for the status of an iterface. The agent software would query the interface and see that it is up (1) and return an OID with "1" as the last integer. SNMP management software, such as HP OpenView, would read the returned OID, look up the MIB and see that the last digit is a "1" and report the interface as "up".

So if you wanted to create your own MIB you would write it in Abstract Syntax Notation (ASN1) and put it on an SNMP manager. Then you would write an agent that would query for example an Oracle data base and see that some number of users were currently accessing a specific table. Lets say that you wanted a trap to be sent whenever more than 10 users were accessing a table. So your agent would constantly be checking ( or you are a good programmer and your code would be triggered by an event of some sort) for how many users are accessing a table. Your agent (the C code you have written) would sen an SNMP trap or Inform to the SNMP manager and it would be in the form of an OID, so the trap you are sending might look like 1.3.6.1.4.1.777.31.1, where 777 indicates that it is your company (XYZ company) and the .31 indicates it is an Oracle Threshold Event and the .1 indicates that the threshold has been reached.

Your MIB would contain the definition (as in the example above for ifOperStatus) and the SNMP manager would look up the OID string in your MIB and extract the appropriate string data to display indicating that a threshold had been reached.

There are enterprise MIBs that can be assigned to your company (that will always be preceded by the 1.3.6.1.4.1 OID string) that you can use however you like. If you were developing something that you wanted to market, you would need to follow the ASN1 rules for creating the MIB so that someone using a standard SNMP manager could "compile" your MIB so the manager woudl know what to do with it when it received a trap from your agent.

If you have ever seen an SNMP manager display something like:

EVENT: 1.3.6.1.4.1.2.6.3.3.56.6

That is, there was no way to know what the heck happened from looking at the OID, it is because the MIB wasn't defined to the SNMP manager OR the specific OID wasn't contained in any of the MIBs that the SNMP manager was aware of.

Good luck,
Steve
0
 
Mi-JackAuthor Commented:
This gives me sufficient help to get where I need it to be, thank you.
0

Featured Post

Will You Be GDPR Compliant by 5/28/2018?

GDPR? That's a regulation for the European Union. But, if you collect data from customers or employees within the EU, then you need to know about GDPR and make sure your organization is compliant by May 2018. Check out our preparation checklist to make sure you're on track today!

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now