AW: [SNMP4J] How can I deal with cable disconnect when visit table?

fock at agentpp.com fock at agentpp.com
Fri Jul 29 23:37:04 CEST 2005


You can modify the timeout value by using the -t parameter.

Best regards,
Frank

>
>I use command  "snmp4j -v 2c -c public -Ot agentaddress 
>1.3.6.1.4.1.19057.x.x.x(table entry OID)"
>and when command is executing, I plug out cable.this command will wait and no 
>response for a long time.
>I can only use Ctrl-C to break.
>
>I add some print infomation("getTable passed") in table() of SnmpRequest.java 
>
>and then run it.I found stop at counter.wait() and there's no notify() 
>invoked.
>
>Is there method to deal with this case?
>
>  public void table() throws IOException {
>    Snmp snmp = createSnmpSession();
>    this.target = createTarget();
>    target.setVersion(version);
>    target.setAddress(address);
>    target.setRetries(retries);
>    target.setTimeout(timeout);
>    snmp.listen();
>
>    TableUtils tableUtils = new TableUtils(snmp, this);
>    tableUtils.setMaxNumRowsPerPDU(maxRepetitions);
>    Counter32 counter = new Counter32();
>
>    OID[] columns = new OID[vbs.size()];
>    for (int i=0; i<columns.length; i++) {
>      columns[i] = ((VariableBinding)vbs.get(i)).getOid();
>    }
>    long startTime = System.currentTimeMillis();
>    synchronized (counter) {
>
>      TableListener listener;
>      if (operation == TABLE) {
>        listener = new TextTableListener();
>      }
>      else {
>        listener = new CVSTableListener(System.currentTimeMillis());
>      }
>      if (useDenseTableOperation) {
>        tableUtils.getDenseTable(target, columns, listener, counter,
>                                 lowerBoundIndex, upperBoundIndex);
>      }
>      else {
>        tableUtils.getTable(target, columns, listener, counter,
>                            lowerBoundIndex, upperBoundIndex);
>        System.out.println("getTable passed");//added by Leo
>      }
>      try {
>        counter.wait();
>      }
>      catch (InterruptedException ex) {
>       ex.printStackTrace();
>      }
>    }
>    System.out.println("Table received in "+
>                       (System.currentTimeMillis()-startTime)+" 
>milliseconds.");
>    snmp.close();
>  }
>_______________________________________________
>SNMP4J mailing list
>SNMP4J at agentpp.org
><a 
>href="http://lists.agentpp.org/mailman/listinfo/snmp4j">http://lists.agentpp.or
>g/mailman/listinfo/snmp4j</a>



More information about the SNMP4J mailing list