org.snmp4j.PDU.getErrorIndex()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(7.9k)|赞(0)|评价(0)|浏览(169)

本文整理了Java中org.snmp4j.PDU.getErrorIndex()方法的一些代码示例,展示了PDU.getErrorIndex()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。PDU.getErrorIndex()方法的具体详情如下:
包路径:org.snmp4j.PDU
类名称:PDU
方法名:getErrorIndex

PDU.getErrorIndex介绍

[英]Gets the error index.
[中]获取错误索引。

代码示例

代码示例来源:origin: org.snmp4j/snmp4j

response.getRequestID() +
", errorIndex=" +
response.getErrorIndex() + ", " +
"errorStatus=" + response.getErrorStatusText() +
"(" + response.getErrorStatus() + ")");
response.getRequestID() +
", errorIndex=" +
response.getErrorIndex() + ", " +
"errorStatus=" + response.getErrorStatusText() +
"(" + response.getErrorStatus() + ")");

代码示例来源:origin: com.rogueai/snmp2bean

protected void checkResponseError(PDU responsePDU) throws SnmpException {
  if (responsePDU == null) {
    SnmpException e = new SnmpException(SnmpException.NO_RESPONSE_PDU, -1);
    e.setSnmpErrorMsgProvider(getSnmpErrorMsgProvider());
    throw e;
  }
  if (responsePDU.getErrorStatus() != 0) {
    SnmpException e = new SnmpException(responsePDU.getErrorStatus(), responsePDU.getErrorIndex());
    e.setSnmpErrorMsgProvider(getSnmpErrorMsgProvider());
    throw e;
  }
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.snmp4j

response.getRequestID() +
", errorIndex=" +
response.getErrorIndex() + ", " +
"errorStatus=" + response.getErrorStatusText() +
"(" + response.getErrorStatus() + ")");
response.getRequestID() +
", errorIndex=" +
response.getErrorIndex() + ", " +
"errorStatus=" + response.getErrorStatusText() +
"(" + response.getErrorStatus() + ")");

代码示例来源:origin: org.kaazing/snmp4j

response.getRequestID() +
", errorIndex=" +
response.getErrorIndex() + ", " +
"errorStatus=" + response.getErrorStatusText() +
"(" + response.getErrorStatus() + ")");
response.getRequestID() +
", errorIndex=" +
response.getErrorIndex() + ", " +
"errorStatus=" + response.getErrorStatusText() +
"(" + response.getErrorStatus() + ")");

代码示例来源:origin: fbacchella/jrds

throw new IOException("SNMP Timeout");
} else {
  int index = response.getErrorIndex() - 1;
  VariableBinding vb = response.get(index);
  logger.warn(response.getErrorStatusText() + " on " + vb.getOid().toString());

代码示例来源:origin: OpenNMS/opennms

private void processResponse(final PDU response) throws SnmpException {
  try {
    LOG.debug("Received a tracker PDU of type {} from {} of size {}, errorStatus = {}, errorStatusText = {}, errorIndex = {}", PDU.getTypeString(response.getType()), getAddress(), response.size(), response.getErrorStatus(), response.getErrorStatusText(), response.getErrorIndex());
    if (response.getType() == PDU.REPORT) {
      handleAuthError("A REPORT PDU was returned from the agent.  This is most likely an authentication problem.  Please check the config");
    } else {
      if (!processErrors(response.getErrorStatus(), response.getErrorIndex())) {
        if (response.size() == 0) { // NMS-6484
          handleError("A PDU with no errors and 0 varbinds was returned from the agent at " + getAddress() + ". This seems to be related with a broken SNMP agent.");
        } else {
          for (int i = 0; i < response.size(); i++) {
            final VariableBinding vb = response.get(i);
            final SnmpObjId receivedOid = SnmpObjId.get(vb.getOid().getValue());
            final SnmpValue val = new Snmp4JValue(vb.getVariable());
            Snmp4JWalker.this.processResponse(receivedOid, val);
          }
        }
      }
      buildAndSendNextPdu();
    }
  } catch (final RuntimeException|SnmpException e) {
    handleFatalError(e);
  }
}

代码示例来源:origin: org.opennms.core.snmp/org.opennms.core.snmp.implementations.snmp4j

private void processResponse(final PDU response) throws SnmpException {
  try {
    LOG.debug("Received a tracker PDU of type {} from {} of size {}, errorStatus = {}, errorStatusText = {}, errorIndex = {}", PDU.getTypeString(response.getType()), getAddress(), response.size(), response.getErrorStatus(), response.getErrorStatusText(), response.getErrorIndex());
    if (response.getType() == PDU.REPORT) {
      handleAuthError("A REPORT PDU was returned from the agent.  This is most likely an authentication problem.  Please check the config");
    } else {
      if (!processErrors(response.getErrorStatus(), response.getErrorIndex())) {
        if (response.size() == 0) { // NMS-6484
          handleError("A PDU with no errors and 0 varbinds was returned from the agent at " + getAddress() + ". This seems to be related with a broken SNMP agent.");
        } else {
          for (int i = 0; i < response.size(); i++) {
            final VariableBinding vb = response.get(i);
            final SnmpObjId receivedOid = SnmpObjId.get(vb.getOid().getValue());
            final SnmpValue val = new Snmp4JValue(vb.getVariable());
            Snmp4JWalker.this.processResponse(receivedOid, val);
          }
        }
      }
      buildAndSendNextPdu();
    }
  } catch (final RuntimeException|SnmpException e) {
    handleFatalError(e);
  }
}

代码示例来源:origin: org.opendaylight.cardinal/cardinal-impl

int errorIndex = responsePDU.getErrorIndex();
String errorStatusText = responsePDU.getErrorStatusText();

代码示例来源:origin: org.opennms.lib.snmp/org.opennms.lib.snmp.snmp4j

private void processResponse(PDU response) {
  try {
    if (log().isDebugEnabled()) {
      log().debug("Received a tracker PDU of type "+PDU.getTypeString(response.getType())+" from "+getAddress()+" of size "+response.size()+", errorStatus = "+response.getErrorStatus()+", errorStatusText = "+response.getErrorStatusText()+", errorIndex = "+response.getErrorIndex());
    }
    if (response.getType() == PDU.REPORT) {
      handleAuthError("A REPORT PDU was returned from the agent.  This is most likely an authentication problem.  Please check the config");
    } else {
      if (!processErrors(response.getErrorStatus(), response.getErrorIndex())) {
        for (int i = 0; i < response.size(); i++) {
          VariableBinding vb = response.get(i);
          SnmpObjId receivedOid = SnmpObjId.get(vb.getOid().getValue());
          SnmpValue val = new Snmp4JValue(vb.getVariable());
          Snmp4JWalker.this.processResponse(receivedOid, val);
        }
      }
      buildAndSendNextPdu();
    }
  } catch (Throwable e) {
    handleFatalError(e);
  }
}

代码示例来源:origin: org.opendaylight.cardinal/cardinal-impl

int errorIndex = responsePDU.getErrorIndex();
String errorStatusText = responsePDU.getErrorStatusText();

代码示例来源:origin: OpenNMS/opennms

if (command.getType() == PDU.INFORM) {
  int errorIndex = command.getErrorIndex();
  int errorStatus = command.getErrorStatus();
  int type = command.getType();

代码示例来源:origin: org.opennms.core.snmp/org.opennms.core.snmp.implementations.snmp4j

if (command.getType() == PDU.INFORM) {
  int errorIndex = command.getErrorIndex();
  int errorStatus = command.getErrorStatus();
  int type = command.getType();

代码示例来源:origin: OpenNMS/opennms

/**
 * @param request
 * @return
 */
private PDU processGetNext(PDU request) {
  PDU response = request;
  response.setErrorIndex(0);
  response.setErrorStatus(0);
  response.setType(PDU.RESPONSE);
  
  Vector<? extends VariableBinding> varBinds = response.getVariableBindings();
  for(int i = 0; i < varBinds.size(); i++) {
    VariableBinding varBind = varBinds.get(i);
    VariableBinding nextVarBind = m_agent.getNext(varBind.getOid());
    if (nextVarBind == null) {
      if (response instanceof PDUv1) {
        if (response.getErrorIndex() == 0) {
          response.setErrorIndex(i+1);
          response.setErrorStatus(PDU.noSuchName);
        } 
      } else {
        varBind.setVariable(Null.endOfMibView);
      }
    } else {
      response.set(i, nextVarBind);
    }
  }
  
  return response;
}

代码示例来源:origin: OpenNMS/opennms

/**
 * @param request
 * @return
 */
private PDU processGet(PDU request) {
  PDU response = request;
  response.setErrorIndex(0);
  response.setErrorStatus(0);
  response.setType(PDU.RESPONSE);
  
  Vector<? extends VariableBinding> varBinds = response.getVariableBindings();
  for(int i = 0; i < varBinds.size(); i++) {
    VariableBinding varBind = varBinds.get(i);
    VariableBinding nextVarBind = m_agent.get(varBind.getOid());
    if (nextVarBind == null) {
      if (response instanceof PDUv1) {
        if (response.getErrorIndex() == 0) {
          response.setErrorIndex(i+1);
          response.setErrorStatus(PDU.noSuchName);
        } 
      } else {
        varBind.setVariable(Null.endOfMibView);
      }
    } else {
      response.set(i, nextVarBind);
    }
  }
  
  return response;
}

代码示例来源:origin: org.snmp4j/snmp4j-agent

translatedResponse.setErrorIndex(respPDU.getErrorIndex());
  translatedResponse.setErrorStatus(respPDU.getErrorStatus());
} else {

代码示例来源:origin: org.kaazing/snmp4j-agent

translatedResponse.setErrorIndex(respPDU.getErrorIndex());
translatedResponse.setErrorStatus(respPDU.getErrorStatus());

相关文章