Re: Defining multiples OID's in a single handler module
Rodolfo Leffa <[email protected]>
| Newsgroups | gmane.network.net-snmp.user |
|---|---|
| Message-ID | <[email protected]> |
On Mon, Feb 9, 2009 at 9:19 AM, Dave Shield <[email protected]>wrote: > 2009/2/6 Rodolfo Leffa <[email protected]>: > >> > I'd like to deal with all requests to a subtree of my mib in a single > >> > handler, but i don't know how to do it. > >> > >> Registering the root using 'netsnmp_register_handler()' does exactly > >> this. But it does mean that you have to deal with *everything* under > >> the specified root yourself. That can get quite complex. > > > > I think I will take my chances! I'm already dealing with the request to > get > > the information I want from the devices managed, so i'll put some extra > code > > to recognize when a request is not part of my MIB. > > Simply recognising when a request isn't part of your MIB is relatively > straightforward. That's not where the problems tend to arise. > > GET requests are simple - it's handling GETNEXT that takes more work. > You've got to take an (arbitrary) OID that falls within your MIB, and > decide > which is the next valid instance. Hm, I havent seen this problem because I'm only implementing the GET operation. Now I'm doubt if I should implement GETNEXT, or it's okay to have an agent that don't reponse to this kind of requisition. > > > > > > >> What is the structure of the MIB you are trying to implement? > > > > The MIB is all consisted of Integers and Strings and enums. Like This: > > > > k3lDeviceCount OBJECT-TYPE > > SYNTAX Integer32 > > MAX-ACCESS read-only > > STATUS current > > DESCRIPTION "Numero de placas ativas no sistema." > > ::= { KhompDataDeviceCount} > > Errr... that doesn't look valid. > I'd normally expect to see something like > > k3lDeviceCount .... ::== { khompDataDeviceCount 1 } > > (and similarly for k3lDeviceType) > > > > linkCount OBJECT-TYPE > > SYNTAX Integer32 > > MAX-ACCESS read-only > > STATUS current > > DESCRIPTION "Numero de links." > > ::= { KhompDataDeviceConfig 1 } > > > > channelCount OBJECT-TYPE > > SYNTAX Integer32 > > MAX-ACCESS read-only > > STATUS current > > DESCRIPTION "Numero de canais." > > ::= { KhompDataDeviceConfig 2 } > > Those look better - except that the parent name ought to start > with a lower-case letter. > You probably ought to run your MIB through some form of > MIB validation (e.g. http://www.simpleweb.org/ietf/mibs/validate/) > The Net-SNMP MIB parsing code is relatively forgiving, and will > accept invalid input. Thanks for this tips. I'll try to validate the MIB. > > > > > The MIB is all consisted of Integers and Strings and enums. > > If they are all single values (rather than tables), then I'd > suggest you use "netsnmp_register_scalar()" to register > the objects individually, or "netsnmp_register_scalar_group()" > to register them in clumps. The problem for me to register the objects individually by "netsnmp_register_scalar()" was that this registers single OID's. The problem of that to me is that I'm using the OID passed to my handler to identify devices on the system my agent is running on. ( I've sent a mail few days ago asking about how to send information throug snmpget.) The solution I found was to implement a single handler for any requisition to my agent. So, I could put some more information on this request and uses it on my agent to select wich device I should get the info. Could you answer me something: when implementing a agent that handles with all a subtree like I'm doing, it's necessary to have a MIB? I'm asking that because I have defined some information on my handler that is not on the MIB, and I've got no errors. > > > Dave > Thanks, []s -- Rodolfo Leffa de Oliveira ------------------------------------------------------------------------------ Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM) software. With Adobe AIR, Ajax developers can use existing skills and code to build responsive, highly engaging applications that combine the power of local resources and data with the reach of the web. Download the Adobe AIR SDK and Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com _______________________________________________ Net-snmp-users mailing list [email protected] Please see the following page to unsubscribe or change other options: https://lists.sourceforge.net/lists/listinfo/net-snmp-users