Please create an account to participate in the Slashdot moderation system

 



Forgot your password?
typodupeerror
×
Programming IT Technology

Writing SNMP MIBs from C Structs? 23

darthtuttle asks: "So I'm working on collecting some stats from the Solaris kernel via the kstat interface and a few others, and I'm going to advertise them via SNMP and graph them with MRTG, however...writing the MIB is going to take forever, not to mention handling three versions of Solaris and different information based on what class of machine. My questions is, does anyone know of a way to take a C structure, mix some additional info (like where in the MIB it goes) and output a MIB definition? I swear, writing the MIB definition is harder then writing the C code to compile in to net-snmp!"
This discussion has been archived. No new comments can be posted.

Writing SNMP MIBs from C Structs?

Comments Filter:
  • by Anonymous Coward
    Sometimes it's easier to write a program to write the program than to write the program.

    Perl, awk, sed, tcsh, bash, Java, and Python are your friends...

  • That's no troll. It's the truth. I too am mystified. Perhaps the Men In Black want to keep it that way.
  • by PD ( 9577 )
    But, does that make the original poster a troll? Perhaps you should RTFM and find out what a troll is and how that's different than offtopic?
  • by PD ( 9577 ) <slashdotlinux@pdrap.org> on Friday June 01, 2001 @11:50AM (#185017) Homepage Journal
    Decisions, decisions. Post at +2 or not? It's an extra click to post at +1, so +2 it is. Taco should change the default to +1.

    If the original message was a waste of electrons, then your threads are a waste too. Have you considered that all electrons are actually recycled, and thus you can't really waste them?
  • My point is that regardless of whether or not the poster trolled or is offtopic they didn't have a clue and shouldn't have posted in the first place.

    Furthermore, regardless of how the comment was moderated it was a waste of electrons to post in the first place.

    Lastly, IMO using your +2 to post a response to poor moderation is a waste as well, and draws attention away from the actual point of the post.
  • Ack!

    To write that you're right or not to write that you're right.

    Bottom line: you're right. :)

    Cheers! Have a good weekend.
  • From http://foldoc.doc.ic.ac.uk/foldoc/foldoc.cgi?query =mib&action=Search

    Management Information Base
    (MIB) A database of managed objects acessed by network management protocols. An SNMP MIB is a set of parameters which an SNMP management station can query or set in the SNMP agent of a network device (e.g. router).

    SNMP has two standard MIBs. The first, MIB I, was established in RFC 1156, was defined to manage TCP/IP-based internets. MIB II, defined in RFC 1213, is basically an update to MIB I.

    Standard minimal MIBs have been defined, and many hardware (and certain software, e.g. DBMS) providers have developed private MIBs in ASN.1 format allowing them to be compiled for use in a Nework Management System. In theory, any SNMP manager can talk to any SNMP agent with a properly defined MIB.

    See also client-server model.

    (1994-11-14)
  • I'm pretty sure that he's trying to expose data gathered from statistics on the machine and expose it via SNMP so that external clients can access it in a standard way.

    Once the data is exposed via SNMP he can use standard SNMP tools (like MTRG) to get and analyze the data.

    The problem that he's having is in exposing the data.

    I took a quick peek at yahoo for info on how to write a MIB... go to http://google.yahoo.com/bin/query?p=how+to+write+a +MIB&hc=0&hs=0

    I think that your best bet is to search for examples on the net.

    I suggest that you read The Simple Book (and check out this listing [yahoo.com]).

    (The tools that I work on use MIBs for network discovery)

  • I suggest that if you don't know about a topic in Ask Slashdot that you go do a little web searching rather than simply post statements like "I don't get it."

    Try helping yourself. I was able to find tons of information by just doing a 5 second search.
    • MRTG [ee.ethz.ch] Multi Router Traffic Grapher
    • SNMP [google.com] Simple Network Management Protocol
    • MIB [google.com] Management Information Base

    I still don't have the faintest idea what he wants to do, though, but I'd like to get enlightened ;)

  • If you want to know more about SNMP, check out this PDF [ddri.com].

    One could also check out my friend's homepage [www.bunk.cc], where he offers SNMP walks [net.bunk.cc] of his badass Olicom Switch [net.bunk.cc]. Node 2 [net.bunk.cc] is interesting.

    Bo
  • its a data format to output to -- kinda like an XML tree with data populated into it that SNMP management devices can use to gather info on the device being queried. well..thats the easy explanation anyway.
    for the poster -- i know what youre trying to do -- ive dont it myself and its a bitch. took me two weeks. :)
    good luck..i havent found any tools to do this and you need to do it manually from my experience...read the RFC and crunch on it.
  • Can someone quickly explain MIB?

    Thanks.
  • I still don't have the faintest idea what he wants to do, though, but I'd like to get enlightened ;)

    Ditto. It sounds like he's trying something that I'd like to be able to do, but what exactly does he mean by
    "
    output a MIB definition"?
    Does he want to write one of those MIB text files? Or create a C structure to use internally in net-snmp code? Or something else?
  • I can't imagine a tool that would take a header file and convert it into a MIB. Too much additional info would be required, and providing all of that info would be just as tedious as constructing the MIB by hand: either way, you would need to learn some funky new syntax and type a whole bunch of text.

    Building a MIB isn't as hard as you make it sound. Yes, all of the different possible field attributes can be daunting. Yes, the syntax is arcane (and probably should be replaced by an XML schema). But really, you should only need the bare minimum to get access to the data you want.

    My advice: skim the SNMP RFC, then hunt around and find a simple third-party MIB to use as a template. Don't try to write it from scratch. Finally, fire up an agent with the MIB, and talk to it using some standard snmpget/snmpset tools to make sure it's all happy before you try to patch it into your larger system.

    Good luck!
  • Are there other languages with advantages in the areas you seek? Like Java?
  • I can't believe I'm actually gonna reply to this but... C is going to magically disappear after being around for over 30 years? I don't think so. There still is no valid replacement for C for the niche it occupies. Java is a joke- that's the bottom line. Maybe when a Java run time machine can run Java at a speed that doesn't feel like me going over a remote X connection, then I'll use it. But for now, Java is still much of a joke and while C may not be appropriate for everything, it beats Java at the vast majority of things it does.
  • No offense intended, but C's day has come and gone. You're opening up yourself to a world of pain by sticking to it. C occupies a non-existant middle ground between high-level languages like Java and low-level languages like assembly.

    Your best solution is to write just enough C code to send the data over a TCP/IP socket, and then write the actual presental code in a real language which reads the data from the C program and analyzes the data.

  • Never mind. I seriously misinterpreted what you were asking about.
  • If you need speed, great, use assembly. If you need portability, wonderful, use Java. Or, if you're feeling the need for speed and are willing to sacrifice readability, use C++. IF your manager forces you at gunpoint, wonderful, use C. That's all there is to it.
  • The SNMP daemon I'm using (and every one I've seen) is written in C. The API to get this information is in C, and I need to access the information quickly and use the least amount of resrouces on the system, so C seems the obvious choice. Oh, and the data structures I'm working with are already defined in C in the systems header files.
    --
    Darthtuttle
    Thought Architect
  • I've done plenty of the basic stuff, it's when I get in to doing three or four dimentional arrays. The tables get just plain nasty. I'm making use of copy and paste like it's going out of style, but after a few weeks of typing my eyes are starting to go blurry and I wake up at night in a cold sweat chanting

    pagesOut OBJECT-TYPE
    SYNTAX Integer32
    MAX-ACCESS read-only
    STATUS current
    DESCRIPTION
    "The pages paged out"
    ::= { vminfo 1 }


    over and over and over and over agian...
    The thing about all this is that the data structures are already defined for me in C. I'm pulling kernel structures out of a Solaris box using the kstat interface. I should at least have a skeleton of a MIB created.

    I guess I'll just have to write it and convince my employer to let me release it in the wild.

    --
    Darthtuttle
    Thought Architect
  • Download UCD-SNMP. It's got a lot of the kstat stuff already in it. I use it an MRTG to graph just about everything worth graphing on my Solaris boxen. :)

I have hardly ever known a mathematician who was capable of reasoning. -- Plato

Working...