Solved

Simple MIB and how to use it from sending application

Posted on 2011-09-07
7
399 Views
Last Modified: 2012-06-21
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
Comment
Question by:Mi-Jack
  • 4
  • 3
7 Comments
 
LVL 16

Expert Comment

by:SteveJ
ID: 36507719
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
 

Author Comment

by:Mi-Jack
ID: 36509573
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
 
LVL 16

Expert Comment

by:SteveJ
ID: 36510193
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:Mi-Jack
ID: 36510209
Exactly, but how?
I need a one-line example of an MIB entry, then, but this is making more sense already.
0
 

Author Comment

by:Mi-Jack
ID: 36512847
not sure what to do with this question. no input, close it please.
0
 
LVL 16

Accepted Solution

by:
SteveJ earned 500 total points
ID: 36513658

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
 

Author Comment

by:Mi-Jack
ID: 36514261
This gives me sufficient help to get where I need it to be, thank you.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Subnetting Question about CIDR notation 3 83
Is KairosPlanet a fraud? 6 39
Wireshark 7 54
MDT 2013 Sysprep and Capture 1 14
Configuring network clients can be a chore, especially if there are a large number of them or a lot of itinerant users.  DHCP dynamically manages this process, much to the relief of users and administrators alike!
As companies replace their old PBX phone systems with Unified IP Communications, many are finding out that legacy applications such as fax do not work well with VoIP. Fortunately, Cloud Faxing provides a cost-effective alternative that works over an…
After creating this article (http://www.experts-exchange.com/articles/23699/Setup-Mikrotik-routers-with-OSPF.html), I decided to make a video (no audio) to show you how to configure the routers and run some trace routes and pings between the 7 sites…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now