[SNMP4J] How to hook up a trap trigger from application?

Binh Le lpbinh at gmail.com
Tue Jun 7 19:36:57 CEST 2011


Thanks Franks for the guideline. That's really helpful, but I'm still
stuck at one point to move on with my learning on your SNMP4J stack:

As far as I understand so far, there are more than one way to create the agent.

1. An agent is created via AgentConfigManager like in the SampleAgent
example, and we can get the agent's NotificationOriginator via the
interface getNotificationOriginator().

2. An agent can also be created by implementing the BaseAgent as in
the TestAgent example. In that case, how can I reach the
AgentConfigManager in order to access the agent's
NotificationOriginator?

To be more specific, here is what I'm doing:

- Implement IF-MIB based on the code generated by Agent Pro.
- Hooking snmp4jAgentHBEvent() for testing notification generation, to
trigger this notification every time ifNumber is inquiry :).

Thanks a lot in advance,
Binh

On Thu, Jun 2, 2011 at 4:48 PM, Frank Fock <fock at agentpp.com> wrote:
> Hi Binh,
>
> To send notifications from a SNMP4J-Agent
> agent use the NotificationOriginator
> interface:
>
> http://www.snmp4j.org/agent/doc/org/snmp4j/agent/NotificationOriginator.html
>
> You can access it through the AgentConfigManager:
> http://www.snmp4j.org/agent/doc/org/snmp4j/agent/AgentConfigManager.html#getNotificationOriginator()
>
> Best regards,
> Frank
>
> On 02.06.2011 23:24, Binh Le wrote:
>> Greetings,
>>
>> I'm new to SNMP4J so forgive me if I'm taking a foreign language as example :).
>>
>> In NetSNMP/C for example, we can just define a function
>> send_xyz_trap(int value1, int value2, ...) and call the function from
>> wherever a trap is need to be triggered.
>>
>> Can someone please help to tell whether we can do that, and how, via SNMP4J?
>>
>> Let take snmp4jAgentHBEvent in SNMP4J-HEARTBEAT-MIB as the example.
>> How can I trigger the trap from with just a passing Counter32 value
>> (snmp4jAgentHBCtrlEvents which is a varbind of the snmp4jAgentHBEvent
>> notification, per the MIB's definition) from another java class, and
>> the notification will be sent to all trap receivers defined in V3
>> related MIBs?
>>
>> Thanks,
>> Binh
>> _______________________________________________
>> SNMP4J mailing list
>> SNMP4J at agentpp.org
>> http://lists.agentpp.org/mailman/listinfo/snmp4j
>
> --
> AGENT++
> http://www.agentpp.com
> http://www.snmp4j.com
> http://www.mibexplorer.com
> http://www.mibdesigner.com
>
> _______________________________________________
> SNMP4J mailing list
> SNMP4J at agentpp.org
> http://lists.agentpp.org/mailman/listinfo/snmp4j
>



More information about the SNMP4J mailing list