tags:

views:

401

answers:

2

I need to create a monitoring mechanism using SNMP (in .Net). I think we'll be using an nsoftware component to handle most of the work.

It appears we must use 'traps' to communicate from the agent to the server. We'll have a number of different traps and various information detailing each trap. What is the best way to implement custom traps? That is, what is the best way to not only send a trap, but also send the information describing the trap to our 'snmp manager'? I think this is done through "variable bindings". To use "variable bindings" do we need to create our own "enterprise number" and use an "enterpriseSpecific" trap? Should we implement our own, custom MIBs or can we just send the data we need with the trap (via variable bindings)?

Thanks.

+1  A: 

Unless you want to notify about one of the 5 predefined traps (e.g. cold start, warm start): yes, you will have to define an enterpriseSpecific trap, and you will need to allocate object identifiers (and plenty of them).

Parameters are indeed transmitted in variable bindings; these are structures defined as

VarBind ::=
         SEQUENCE {
           name ObjectName,
           value ObjectSyntax
         }

VarBindList ::= SEQUENCE OF VarBind

ObjectName ::= OBJECT IDENTIFIER
ObjectSyntax ::= CHOICE {
     simple SimpleSyntax,
     application-wide ApplicationSyntax
}

SimpleSyntax ::= CHOICE {
     number INTEGER,
     string OCTET STRING,
     object OBJECT IDENTIFIER,
     empty  NULL
}

ApplicationSyntax ::=  CHOICE {
      address  NetworkAddress,
      counter  Counter,
      gauge    Gauge,
      ticks    TimeTicks,
      arbitrary  Opaque
}

You somehow need to tell your library what the name and the value is; the library should provide API to support the various data types available as values. Notice that the variable "names" are again object identifiers.

Martin v. Löwis
A: 

I suggest you first determine how many cases your agent will send data back to server/monitor.

Then you need to decide how to distinguish those cases (using different ID or packaging different variable bindings).

And now write down several packets on a piece of paper and start to author the trap definition in MIB document.

What's next depends on which library you utilize to implement the conversation. Well, 'nsoftware one is a nice choice.

BTW, I rather send out TRAP v2 packet or INFORM instead of TRAP v1.

Regards,

Lex Li http://sharpsnmplib.codeplex.com

Lex Li