Java Code Examples for org.snmp4j.PDU#GETBULK

The following examples show how to use org.snmp4j.PDU#GETBULK . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: mts   File: MsgSnmp.java    License: GNU General Public License v3.0 5 votes vote down vote up
/** This methods HAS TO be quick to execute for performance reason */
   @Override
public String toShortString() throws Exception 
   {
   	String ret = super.toShortString();
       ret += "\n";
       ret += "<MESSAGE type:" + PDU.getTypeString(pdu.getType()) + ", requestId:" + pdu.getRequestID();
       if(pdu.getType() != PDU.GETBULK)
           ret += ", errorStatus:" + pdu.getErrorStatusText() + ", errorIndex:" + pdu.getErrorIndex();
       else
           ret += ", nonRepeaters:" + pdu.getNonRepeaters() + ", maxRepetitions:" + pdu.getMaxRepetitions();
       ret += "/>";
	return ret;
}
 
Example 2
Source Project: mts   File: MsgSnmp.java    License: GNU General Public License v3.0 5 votes vote down vote up
/** 
   * Convert the message to XML document 
   */
  @Override
  public String toXml() throws Exception 
  {
  	String xml = "";
try {
	xml += "type: " + PDU.getTypeString(pdu.getType()) + ", requestId: " + pdu.getRequestID();
          if(pdu instanceof PDUv1 && (pdu.getType() == PDU.V1TRAP))//specific for TRAP in SNMPV1
              xml += ", enterprise: " + ((PDUv1)pdu).getEnterprise() + ", agentAddress: " + ((PDUv1)pdu).getAgentAddress() + 
                     ", genericTrap: " + ((PDUv1)pdu).getGenericTrap() + ", specificTrap: " + ((PDUv1)pdu).getSpecificTrap() +
                     ", timestamp: " + ((PDUv1)pdu).getTimestamp();
          else if(pdu.getType() != PDU.GETBULK)
          xml += ", errorStatus: " + pdu.getErrorStatusText() + ", errorIndex: " + pdu.getErrorIndex();
      else
          xml += ", nonRepeaters: " + pdu.getNonRepeaters() + ", maxRepetitions: " + pdu.getMaxRepetitions();

          xml += "\r\n";
          if(pdu.getVariableBindings().size() > 0)
          {
              xml += "VariableBinding: " + pdu.getVariableBindings().toString();
          }
	
} catch (Exception e) {
          GlobalLogger.instance().getApplicationLogger().warn(TextEvent.Topic.PROTOCOL, e, "An error occured while logging the SMTP message : ", xml);
}
return xml;
  }
 
Example 3
Source Project: snmpman   File: AbstractSnmpmanTest.java    License: Apache License 2.0 4 votes vote down vote up
public static List<TableEvent> getResponse(final OID query, int port, final String community) throws Exception {
    final Address targetAddress = GenericAddress.parse(String.format("127.0.0.1/%d", port));
    final Snmp snmp = new Snmp(new DefaultUdpTransportMapping());
    snmp.listen();

    final CommunityTarget target = getCommunityTarget(community, targetAddress);

    // creating PDU
    final PDUFactory pduFactory = new DefaultPDUFactory(PDU.GETBULK);
    final TableUtils utils = new TableUtils(snmp, pduFactory);

    return utils.getTable(target, new OID[]{query}, null, null);
}