Examples of PDU


Examples of org.snmp4j.PDU

            comtarget.setCommunity(community1);
            comtarget.setVersion(SnmpConstants.version1);
            comtarget.setAddress(tHost);
            comtarget.setRetries(2);
            comtarget.setTimeout(5000);
            PDU pdu = new PDU();
            pdu.add(new VariableBinding(new OID(strOID)));
            pdu.setType(PDU.GET);
            snmp = new Snmp(transport);
            response = snmp.get(pdu, comtarget);
            if (response != null) {
                if (response.getResponse().getErrorStatusText().equalsIgnoreCase("Success")) {
                    PDU pduresponse = response.getResponse();
                    strResponse = pduresponse.getVariableBindings().firstElement().toString();
                    if (strResponse.contains("=")) {
                        String strNewResponse[] = null;
                        int len = strResponse.indexOf("=");
                        strNewResponse = strResponse.split("=");
                        //System.out.println("The SNMP response to the OID requested is : " + strNewResponse[1]); //FOR DEBUG
View Full Code Here

Examples of org.snmp4j.PDU

            target.setCommunity(new OctetString(community));
            target.setAddress(tHost);
            target.setRetries(2);
            target.setTimeout(5000);
            target.setVersion(SnmpConstants.version1); //Set the correct SNMP version here
            PDU pdu = new PDU();
            //Depending on the MIB attribute type, appropriate casting can be done here
            pdu.add(new VariableBinding(new OID(strOID), new Integer32(Integer.valueOf(value))));
            pdu.setType(PDU.SET);
            ResponseListener listener = new ResponseListener() {

                public void onResponse(ResponseEvent event) {
                    PDU strResponse;
                    String result;
                    ((Snmp) event.getSource()).cancel(event.getRequest(), this);
                    strResponse = event.getResponse();
                    if (strResponse != null) {
                        result = strResponse.getErrorStatusText();
                        System.out.println("Set Status is: " + result);
                    }
                }
            };
            snmp.send(pdu, target, null, listener);
View Full Code Here

Examples of org.snmp4j.PDU

            comtarget.setCommunity(community1);
            comtarget.setVersion(SnmpConstants.version1);
            comtarget.setAddress(tHost);
            comtarget.setRetries(2);
            comtarget.setTimeout(5000);
            PDU pdu = new PDU();
            pdu.add(new VariableBinding(new OID(strOID)));
            pdu.setType(PDU.GET);
            snmp = new Snmp(transport);
            response = snmp.get(pdu, comtarget);
            if (response != null) {
                if (response.getResponse().getErrorStatusText().equalsIgnoreCase("Success")) {
                    PDU pduresponse = response.getResponse();
                    strResponse = pduresponse.getVariableBindings().firstElement().toString();
                    if (strResponse.contains("=")) {
                        String strNewResponse[] = null;
                        int len = strResponse.indexOf("=");
                        strNewResponse = strResponse.split("=");
                        //System.out.println("The SNMP response to the OID requested is : " + strNewResponse[1]); //FOR DEBUG
View Full Code Here

Examples of org.snmp4j.PDU

            target.setCommunity(new OctetString(community));
            target.setAddress(tHost);
            target.setRetries(2);
            target.setTimeout(5000);
            target.setVersion(SnmpConstants.version1); //Set the correct SNMP version here
            PDU pdu = new PDU();
            //Depending on the MIB attribute type, appropriate casting can be done here
            pdu.add(new VariableBinding(new OID(strOID), new Integer32(Integer.valueOf(value))));
            pdu.setType(PDU.SET);
            ResponseListener listener = new ResponseListener() {

                public void onResponse(ResponseEvent event) {
                    PDU strResponse;
                    String result;
                    ((Snmp) event.getSource()).cancel(event.getRequest(), this);
                    strResponse = event.getResponse();
                    if (strResponse != null) {
                        result = strResponse.getErrorStatusText();
                        System.out.println("Set Status is: " + result);
                    }
                }
            };
            snmp.send(pdu, target, null, listener);
View Full Code Here

Examples of org.snmp4j.PDU

            comtarget.setCommunity(community1);
            comtarget.setVersion(SnmpConstants.version1);
            comtarget.setAddress(tHost);
            comtarget.setRetries(2);
            comtarget.setTimeout(5000);
            PDU pdu = new PDU();
            pdu.add(new VariableBinding(new OID(strOID)));
            pdu.setType(PDU.GET);
            snmp = new Snmp(transport);
            response = snmp.get(pdu, comtarget);
            if (response != null) {
                if (response.getResponse().getErrorStatusText().equalsIgnoreCase("Success")) {
                    PDU pduresponse = response.getResponse();
                    strResponse = pduresponse.getVariableBindings().firstElement().toString();
                    if (strResponse.contains("=")) {
                        String strNewResponse[] = null;
                        int len = strResponse.indexOf("=");
                        strNewResponse = strResponse.split("=");
                        //System.out.println("The SNMP response to the OID requested is : " + strNewResponse[1]); //FOR DEBUG
View Full Code Here

Examples of org.snmp4j.PDU

   */
  private void createRequestPDU() {
    SnmpRequest request = (SnmpRequest)
        ((AgentXSearchRange) searchRanges.get(0))
        .getReferenceSubRequest().getRequest();
    PDU requestPDU = request.getInitiatingEvent().getPDU();
    switch (requestPDU.getType()) {
      case PDU.GETBULK: {
        short maxRep = getMaxRepetitions(request, requestPDU);
        agentXRequestPDU =
            new AgentXGetBulkPDU(request.getContext(),
                                 maxRep, nonRepeater,
                                 (MOScope[]) searchRanges.toArray(
                                     new MOScope[searchRanges.size()]));
        break;
      }
      case PDU.GET: {
        OID[] oids = new OID[searchRanges.size()];
        for (int i = 0; i < oids.length; i++) {
          AgentXSearchRange sr = (AgentXSearchRange) searchRanges.get(i);
          oids[i] = sr.getLowerBound();
        }
        agentXRequestPDU = new AgentXGetPDU(request.getContext(), oids);
        break;
      }
      case PDU.GETNEXT: {
        agentXRequestPDU =
            new AgentXGetNextPDU(request.getContext(),
                                 (MOScope[]) searchRanges.toArray(
                                     new MOScope[searchRanges.size()]));
        break;
      }
      default: {
        logger.error("Failed to create AgentX PDU for PDU type " +
                     requestPDU.getType());
      }
    }
  }
View Full Code Here

Examples of org.snmp4j.PDU

       
        super.doStop();
    }

    public void processPdu(CommandResponderEvent event) {
        PDU pdu = event.getPDU();
        // check PDU not null
        if (pdu != null) {
            processPDU(pdu);
        } else {
            LOG.debug("Received invalid trap PDU: " + pdu);
View Full Code Here

Examples of org.snmp4j.PDU

        target.setRetries(this.endpoint.getRetries());
        target.setTimeout(this.endpoint.getTimeout());
        target.setVersion(this.endpoint.getSnmpVersion());

        // creating PDU
        this.pdu = new PDU();
        // listen to the transport
        this.transport.listen();
    }
View Full Code Here

Examples of org.snmp4j.PDU

            // ignore null requests/responses
            LOG.debug("Received invalid snmp event. Request: " + event.getRequest() + " / Response: " + event.getResponse());
            return;
        }
       
        PDU pdu = event.getResponse();
        processPDU(pdu);
    }
View Full Code Here

Examples of org.snmp4j.PDU

public class SnmpMessage extends DefaultMessage {
    private PDU pdu;

    public SnmpMessage() {
        this(new PDU());
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.