Solved

Simple MIB and how to use it from sending application

Posted on 2011-09-07
7
403 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Prevent DDOS attack 16 74
audit software installed on each Personal computer in my company LAN 3 144
Network Switches Keep Failing 8 86
New firewall implementation guidance 12 57
How to set-up an On Demand, IPSec, Site to SIte, VPN from a Draytek Vigor Router to a Cyberoam UTM Appliance. A concise guide to the settings required on both devices
Why pager replacement is still an issue OnPage has what some might call a “hate/hate” relationship with pagers. Not much room for love. As we see it, pagers are an antiquated bit of technology. Pagers are dinosaurs which, like most dinosaurs, sho…
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…
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…

816 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

7 Experts available now in Live!

Get 1:1 Help Now