Package org.snmp4j

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
        if (LOG.isDebugEnabled()) {
            LOG.debug("Starting OID poller on {} using {} protocol", endpoint.getAddress(), endpoint.getProtocol());
        }
View Full Code Here


            // 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

       
        super.doStop();
    }

    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(),
View Full Code Here

      target.setCommunity(new OctetString(community));
      target.setAddress(targetAddress);
      target.setRetries(0);
      target.setTimeout(200);
      target.setVersion(SnmpConstants.version2c);
      PDU pdu = new PDU();
      pdu.add(new VariableBinding(new OID(oid), new Integer32(value)));
      pdu.setType(PDU.SET);
      ResponseListener listener = new ResponseListener() {
        public void onResponse(ResponseEvent event) {
        // Always cancel async request when response has been received
        // otherwise a memory leak is created! Not canceling a request
        // immediately can be useful when sending a request to a broadcast
View Full Code Here

      comtarget.setCommunity(new OctetString(community));
      comtarget.setVersion(SnmpConstants.version1);
      comtarget.setAddress(targetaddress);
      comtarget.setRetries(2);
      comtarget.setTimeout(5000);
      PDU pdu = new PDU();
      ResponseEvent response;
      Snmp snmp;
      pdu.add(new VariableBinding(new OID(oid)));
      pdu.setType(PDU.GET);
      snmp = new Snmp(transport);
      response = snmp.get(pdu,comtarget);
      if(response != null) {
        String errorStatus =
          response.getResponse().getErrorStatusText();
        if(errorStatus.equalsIgnoreCase("Success")) {
          PDU pduresponse = response.getResponse();
          String str =
            pduresponse.getVariableBindings().firstElement().toString();
          if(str.contains("=")) {
            int len = str.indexOf("=");
            str=str.substring(len+1, str.length());
          }
          str = str.trim();
View Full Code Here

      throws IOException {

    checkNoNulls(address, listener, oids);

    final Target target = this.createTarget(address);
    final PDU requestPdu = this.createRequestPdu(PDU.GET, target, VariableBindings.wrapOids(oids));
    this.snmp.send(requestPdu, target, handle, listener);
  }
View Full Code Here

      throws IOException {

    checkNoNulls(address, listener, oids);

    final Target target = this.createTarget(address);
    final PDU requestPdu = this.createRequestPdu(PDU.GETNEXT, target, VariableBindings.wrapOids(oids));
    this.snmp.send(requestPdu, target, handle, listener);
  }
View Full Code Here

  public ResponseEvent getNextSync(final A address, final OID... oids) throws IOException {

    checkNoNulls(address, oids);

    final Target target = this.createTarget(address);
    final PDU requestPdu = this.createRequestPdu(PDU.GETNEXT, target, VariableBindings.wrapOids(oids));
    return this.snmp.send(requestPdu, target);
  }
View Full Code Here

  public ResponseEvent getSync(final A address, final OID... oids) throws IOException {

    checkNoNulls(address, oids);

    final Target target = this.createTarget(address);
    final PDU requestPdu = this.createRequestPdu(PDU.GET, target, VariableBindings.wrapOids(oids));
    return this.snmp.send(requestPdu, target);
  }
View Full Code Here

      final VariableBinding... bindings) throws IOException {

    checkNoNulls(address, listener, bindings);

    final Target target = this.createTarget(address);
    final PDU requestPdu = this.createRequestPdu(PDU.SET, target, bindings);
    this.snmp.send(requestPdu, target, handle, listener);
  }
View Full Code Here

TOP

Related Classes of org.snmp4j.PDU

Copyright © 2018 www.massapicom. 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.