[AGENT++] Multiple SNMP agents in single application

Frank Fock fock at agentpp.com
Tue Mar 12 19:55:50 CET 2013


Hi Claus,

Within the standard constructor, you cannot know the context. This is a 
limitation of
the AGENT++ design (I solved that better with SNMP4J-Agent).

Nevertheless, there is a workaround. Subclass MibLeaf with your own class.
That class can be generic and with the AgenPro 'leafSuperClass' property
you can then generate each class to use that super class instead of MibLeaf.
The constructor of that super class then takes the context as additional 
parameter.

If your code can be reorganized to use context information only at "runtime"
when Requests are processed, then it would be easy to get the context
information from the Request.

Best regards,
Frank

Am 12.03.2013 06:10, schrieb Claus Klein:
> Hi,
>
> there are 2 little unresolved problems with the same mib under 
> different context values.
> How to get the context value and how to work with this static instance 
> variable:
>
> netSnmpExampleInteger::netSnmpExampleInteger():
>    MibLeaf(oidNetSnmpExampleInteger, READWRITE, new NS_SNMP 
> SnmpInt32(42), (VMODE_LOCKED | VMODE_DEFAULT)) {
>    // This leaf object is a singleton. In order to access it use
>    // the static pointer netSnmpExampleInteger::instance.
>    instance = this;
>    //--AgentGen BEGIN=netSnmpExampleInteger::netSnmpExampleInteger
>    //FIXME how to get mycontext?
>    //XXX if (netSnmpHostsEntry::contextmap[mycontext])
>    if (netSnmpHostsEntry::instance) {
>        // NOTE register a call of 
> netSnmpExampleInteger::change_notification()
> netSnmpHostsEntry::instance->register_for_notifications(this);
>    }
>    //--AgentGen END
> }
>
> On 08.03.2013, at 21:14, Jochen Katz wrote:
>
>> Hi,
>>
>>> I need to host the same MIB at multiple ports within a single 
>>> application.
>>> Each hosted MIB (at a different port) will end up accessing 
>>> different data
>>> within the application.
>>>
>>> Can I do this within agent++/snmp++? If so, how? I see that 
>>> instances are
>>> used for each MIB object, so I am unsure how I can have a single MIB 
>>> that
>>> is hosted multiple times access different data within a single 
>>> application.
>>
>> there can only be one instance of agent++ Mib class in an application
>> and the same is true for other classes of agent++/snmp++.
>>
>> You can add your MIB objects for several contexts and then either use
>> SNMPv3 with different contextEngineIDs or map several SNMPv1/v2c
>> communities to the different contexts.
>>
>> Regards,
>> Jochen
>> _______________________________________________
>> AGENTPP mailing list
>> AGENTPP at agentpp.org
>> http://lists.agentpp.org/mailman/listinfo/agentpp
>
> _______________________________________________
> AGENTPP mailing list
> AGENTPP at agentpp.org
> http://lists.agentpp.org/mailman/listinfo/agentpp

-- 
---
AGENT++
Maximilian-Kolbe-Str. 10
73257 Koengen, Germany
https://agentpp.com
Phone: +49 7024 8688230
Fax:   +49 7024 8688231



More information about the AGENTPP mailing list