免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 3296 | 回复: 1
打印 上一主题 下一主题

Eclipse里运行正常,放到批处理就失败,求教? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2011-07-03 10:10 |只看该作者 |倒序浏览
Snmp4j开源包里自带了一个命令行Snmp工具,但使用过程发现用它来获取网络设备Snmp性能时失败.命令参数:-c !xmcT%^&8 -v 2c -Ot -t 1000 10.4.3.144 1.3.6.1.2.1.2.2.1.2.

调试源码发现在 Eclipse可以取到远端mib数据,但是打包放到 批处理bat文件里调用就失败.
跟踪 org.snmp4j.tools.console.SnmpRequest.java 发现 下面代码中的synchronized (counter) 同步块在批处理执行时失效,直接线程中断退出了。

请教为何在Eclipse可以执行的得到结果,在批处理里执行却不行?

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 = ((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);
  }
  try {
  counter.wait(timeout);
  }
  catch (InterruptedException ex) {
  Thread.currentThread().interrupt();
  }
  }

  //System.out.println("Table received in "+
  // (System.currentTimeMillis()-startTime)+" milliseconds.");
  snmp.close();
  }

论坛徽章:
0
2 [报告]
发表于 2011-07-03 12:16 |只看该作者
直觉说:classpath缺包
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP