当前位置: 首页>>代码示例>>Java>>正文


Java PDU.getErrorStatusText方法代码示例

本文整理汇总了Java中org.snmp4j.PDU.getErrorStatusText方法的典型用法代码示例。如果您正苦于以下问题:Java PDU.getErrorStatusText方法的具体用法?Java PDU.getErrorStatusText怎么用?Java PDU.getErrorStatusText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.snmp4j.PDU的用法示例。


在下文中一共展示了PDU.getErrorStatusText方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: validateResponse

import org.snmp4j.PDU; //导入方法依赖的package包/类
protected void validateResponse(ResponseEvent event) {
  final Exception error = event.getError();
  if (error != null) {
    throw new RuntimeException(error);
  }
  PDU response = event.getResponse();
  if (response == null) {
    throw new TimeoutException();
  }
  if (response.getErrorStatus() != 0) {
    throw new RuntimeException("response indicates " 
        + response.getErrorStatusText()
        + " at index " + response.getErrorIndex());
  }
}
 
开发者ID:soulwing,项目名称:tnm4j,代码行数:16,代码来源:AbstractOperation.java

示例2: getResponse

import org.snmp4j.PDU; //导入方法依赖的package包/类
private OperationResult getResponse(ResponseEvent event) {
    PDU response = event.getResponse();
    log.info("set result " + response);
    int errorIndex = response.getErrorIndex();
    int errorStatus = response.getErrorStatus();
    String errorStatusText = response.getErrorStatusText();
    OperationResult result = new OperationResult();
    Configuration config = result.getComplexResults();
    config.setSimpleValue(ERROR_INDEX, valueOf(errorIndex));
    config.setSimpleValue(ERROR_STATUS, valueOf(errorStatus));
    config.setSimpleValue(ERROR_STATUS_TEXT, valueOf(errorStatusText));
    if (errorStatus != SnmpConstants.SNMP_ERROR_SUCCESS)
        result.setErrorMessage(response.toString());
    return result;
}
 
开发者ID:genman,项目名称:rhq-plugins,代码行数:16,代码来源:SetOperation.java

示例3: main

import org.snmp4j.PDU; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception
{
  System.out.println("SNMP GET-NEXT Simple Request");

  // Create TransportMapping and Listen
  TransportMapping transport = new DefaultUdpTransportMapping();
  transport.listen();

  // Create Target Address object
  CommunityTarget comtarget = new CommunityTarget();
  comtarget.setCommunity(new OctetString(community));
  comtarget.setVersion(snmpVersion);
  comtarget.setAddress(new UdpAddress(ipAddress + "/" + port));
  comtarget.setRetries(2);
  comtarget.setTimeout(1000);

  // Create the PDU object
  PDU pdu = new PDU();
  pdu.add(new VariableBinding(new OID(oidValue))); 
  pdu.setRequestID(new Integer32(1));
  pdu.setType(PDU.GETNEXT);
  
  // Create Snmp object for sending data to Agent
  Snmp snmp = new Snmp(transport);

  System.out.println("Sending GetNext Request to Agent ...");
  
  ResponseEvent response = snmp.getNext(pdu, comtarget);

  // Process Agent Response
  if (response != null)
  {
    System.out.println("\nResponse:\nGot GetNext Response from Agent...");
    PDU responsePDU = response.getResponse();

    if (responsePDU != null)
    {
      int errorStatus = responsePDU.getErrorStatus();
      int errorIndex = responsePDU.getErrorIndex();
      String errorStatusText = responsePDU.getErrorStatusText();

      if (errorStatus == PDU.noError)
      {
        System.out.println("Snmp GetNext Response for sysObjectID = " + responsePDU.getVariableBindings());
      }
      else
      {
        System.out.println("Error: Request Failed");
        System.out.println("Error Status = " + errorStatus);
        System.out.println("Error Index = " + errorIndex);
        System.out.println("Error Status Text = " + errorStatusText);
      }
    }
    else
    {
      System.out.println("Error: GetNextResponse PDU is null");
    }
  }
  else
  {
    System.out.println("Error: Agent Timeout... ");
  }
  snmp.close();
}
 
开发者ID:javiroman,项目名称:flume-snmp-source,代码行数:65,代码来源:testSNMPQuery.java


注:本文中的org.snmp4j.PDU.getErrorStatusText方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。