[SNMP4J] RE Agent request listener

mathieu carrolle mathieu.carrolle at hotmail.fr
Thu Jul 10 17:56:12 CEST 2008


Hello,
I found the solution so i post it for helping people :

public static void main(String[] args) {
        String address = "127.0.0.1/4700";
        BasicConfigurator.configure();

        try {
CopyOfAgent testAgent1 = new CopyOfAgent(new File(
                    "SNMP4JTestAgentBC.cfg"), new File(
                    "SNMP4JTestAgentConfig.cfg"));
........
//Add the listenner
testAgent1.getSession().addCommandResponder(new MORequestListener());
....

Now you implement the interface RequestStatusListenner :

public class MORequestListener implements MOChangeListener, RequestStatusListener, CommandResponder {
    @Override
    public void processPdu(CommandResponderEvent event) {
       
        PDU pdu = event.getPDU();
        if(pdu.getType()==PDU.GET){
            System.out.println(event.toString());
        }     
    }
}

Bye

> From: mathieu.carrolle at hotmail.fr
> To: snmp4j at agentpp.org
> Date: Thu, 10 Jul 2008 12:04:51 +0200
> Subject: [SNMP4J] RE Agent request listener
> 
> 
> Hello,
> 
> I try the snmp4j TestAgent.java exemple.
> When a request is doing by a manager, for exemple  :
>                     "snmpget -v 1 -c public <mysnmpagent_address> enterprises.4890.1.1.0"
> In my agent how can get the content of the request (oid, type of command ...) ?
> 
> Sorry for my poor english.
> Thanks

_________________________________________________________________
Votre contact a choisi Hotmail, l'e-mail nouvelle génération. Créez un compte. 
http://www.windowslive.fr/hotmail/default.asp


More information about the SNMP4J mailing list