本文整理汇总了Java中org.snmp4j.PDU.REPORT属性的典型用法代码示例。如果您正苦于以下问题:Java PDU.REPORT属性的具体用法?Java PDU.REPORT怎么用?Java PDU.REPORT使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.snmp4j.PDU
的用法示例。
在下文中一共展示了PDU.REPORT属性的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processResponse
/**
* TODO: Merge this logic with {@link Snmp4JWalker.Snmp4JResponseListener#processResponse(PDU response)}
*/
private static SnmpValue[] processResponse(Snmp4JAgentConfig agentConfig, ResponseEvent responseEvent) throws IOException {
SnmpValue[] retvalues = { null };
if (responseEvent.getResponse() == null) {
log().warn("processResponse: Timeout. Agent: "+agentConfig);
} else if (responseEvent.getError() != null) {
log().warn("processResponse: Error during get operation. Error: "+responseEvent.getError().getLocalizedMessage(), responseEvent.getError());
} else if (responseEvent.getResponse().getType() == PDU.REPORT) {
log().warn("processResponse: Error during get operation. Report returned with varbinds: "+responseEvent.getResponse().getVariableBindings());
} else if (responseEvent.getResponse().getVariableBindings().size() < 1) {
log().warn("processResponse: Received PDU with 0 varbinds.");
} else if (responseEvent.getResponse().get(0).getSyntax() == SMIConstants.SYNTAX_NULL) {
log().info("processResponse: Null value returned in varbind: " + responseEvent.getResponse().get(0));
} else {
retvalues = convertResponseToValues(responseEvent);
if (log().isDebugEnabled()) {
log().debug("processResponse: SNMP operation successful, value: "+Arrays.toString(retvalues));
}
}
return retvalues;
}
示例2: processResponse
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())) {
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++) {
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);
}
}
示例3: processPdu
public void processPdu(CommandResponderEvent event) {
PDU pdu = event.getPDU();
// check PDU not null
if (pdu != null) {
// check for INFORM
// code take from the book "Essential SNMP"
if ((pdu.getType() != PDU.TRAP) && (pdu.getType() != PDU.V1TRAP) && (pdu.getType() != PDU.REPORT)
&& (pdu.getType() != PDU.RESPONSE)) {
// first response the inform-message and then process the
// message
pdu.setErrorIndex(0);
pdu.setErrorStatus(0);
pdu.setType(PDU.RESPONSE);
StatusInformation statusInformation = new StatusInformation();
StateReference ref = event.getStateReference();
try {
event.getMessageDispatcher().returnResponsePdu(event.getMessageProcessingModel(),
event.getSecurityModel(),
event.getSecurityName(),
event.getSecurityLevel(), pdu,
event.getMaxSizeResponsePDU(), ref,
statusInformation);
if (LOG.isDebugEnabled()) {
LOG.debug("response to INFORM sent");
}
} catch (MessageException ex) {
getExceptionHandler().handleException(ex);
}
}
processPDU(pdu, event);
} else {
LOG.debug("Received invalid trap PDU: " + pdu);
}
}
示例4: processPdu
/**
* This method will be called whenever a pdu is received on the given port specified in the listen() method
*/
public synchronized void processPdu(CommandResponderEvent cmdRespEvent)
{
System.out.println("Received PDU...");
PDU pdu = cmdRespEvent.getPDU();
if (pdu != null)
{
System.out.println("Trap Type = " + pdu.getType());
System.out.println("Variable Bindings = " + pdu.getVariableBindings());
int pduType = pdu.getType();
if ((pduType != PDU.TRAP) && (pduType != PDU.V1TRAP) && (pduType != PDU.REPORT)
&& (pduType != PDU.RESPONSE))
{
pdu.setErrorIndex(0);
pdu.setErrorStatus(0);
pdu.setType(PDU.RESPONSE);
StatusInformation statusInformation = new StatusInformation();
StateReference ref = cmdRespEvent.getStateReference();
try
{
System.out.println(cmdRespEvent.getPDU());
cmdRespEvent.getMessageDispatcher().returnResponsePdu(cmdRespEvent.getMessageProcessingModel(),
cmdRespEvent.getSecurityModel(), cmdRespEvent.getSecurityName(), cmdRespEvent.getSecurityLevel(),
pdu, cmdRespEvent.getMaxSizeResponsePDU(), ref, statusInformation);
}
catch (MessageException ex)
{
System.err.println("Error while sending response: " + ex.getMessage());
LogFactory.getLogger(SnmpRequest.class).error(ex);
}
}
}
}
示例5: isRequestPDU
/**
* @param command
* @return
*/
private boolean isRequestPDU(PDU command) {
return (command.getType() != PDU.TRAP) &&
(command.getType() != PDU.V1TRAP) &&
(command.getType() != PDU.REPORT) &&
(command.getType() != PDU.RESPONSE);
}