Examples of Snmp


Examples of org.snmp4j.Snmp

            this.transport = new DefaultUdpTransportMapping();
        } else {
            throw new IllegalArgumentException("Unknown protocol: " + endpoint.getProtocol());
        }

        this.snmp = new Snmp(this.transport);
        this.usm = new USM(SecurityProtocols.getInstance(), new OctetString(MPv3.createLocalEngineID()), 0);
        SecurityModels.getInstance().addSecurityModel(usm);

        // setting up target
        target = new CommunityTarget();
View Full Code Here

Examples of org.snmp4j.Snmp

                check.getState().name(),
                url(check),
                alerts.size());

        // Create the SNMP instance
        Snmp snmp = createSnmpConnection();

        // Specify receiver
        Address targetaddress = new UdpAddress(seyrenConfig.getSnmpHost() + "/" + seyrenConfig.getSnmpPort());
        CommunityTarget target = new CommunityTarget();
        target.setCommunity(octetString(seyrenConfig.getSnmpCommunity()));
View Full Code Here

Examples of org.snmp4j.Snmp

        }
    }

    private Snmp createSnmpConnection() {
        try {
            return new Snmp(new DefaultUdpTransportMapping());
        } catch (IOException e) {
            throw new NotificationFailedException("Sending notification via SNMP trap failed.", e);
        }
    }
View Full Code Here

Examples of org.snmp4j.Snmp

        _target = new CommunityTarget();
        _target.setCommunity(new OctetString(community));
        _target.setVersion(SnmpConstants.version2c);
        _target.setAddress(new UdpAddress(address));
        try {
            _snmp = new Snmp(new DefaultUdpTransportMapping());
        } catch (IOException e) {
            _snmp = null;
            throw new CloudRuntimeException(" Error in crearting snmp object, " + e.getMessage());
        }
    }
View Full Code Here

Examples of org.snmp4j.Snmp

    comtarget.setAddress(new UdpAddress(ipAddress + "/" + Settings.getInt("snmp.port", 161)));
    comtarget.setRetries(2);
    comtarget.setTimeout(1000);
    // Create the PDU object
    // Create Snmp object
    Snmp snmp = new Snmp(transport);
    // Iterating over map
    for (Entry<Object, Object> entry : p.entrySet()) {
      oidValue = entry.getValue().toString();
      descr = entry.getKey().toString();
      PDU pdu = new PDU();
      pdu.add(new VariableBinding(new OID(oidValue)));
      pdu.setRequestID(new Integer32(1));
      pdu.setType(PDU.GET);

      try {
        response = snmp.get(pdu, comtarget);
      } catch (IOException e) {
      }
      // Process Agent Response
      if (response != null) {
        PDU responsePDU = response.getResponse();
        if (responsePDU != null) {
          int errorStatus = responsePDU.getErrorStatus();
          int errorIndex = responsePDU.getErrorIndex();
          String errorStatusText = responsePDU.getErrorStatusText();

          if (errorStatus == PDU.noError) {
            String resp = (String) responsePDU.getVariableBindings().toString();
            // Split answer into OID and description
            String[] helperArray = resp.replaceAll("[\\[|\\]]", "").split(" = ");
            if (helperArray.length > 1) {
              oid.put(descr, helperArray[1]);
              //count++;
            } else {
              Logger.debug("SNMP: Request failed" + ": Error status = " + errorStatus + ": Error sndex = " + errorIndex + ": Error text = " + errorStatusText);
            }
          } else {
            Logger.debug("SNMP: GetNextResponse PDU is null");
          }
        } else {
          Logger.debug("SNMP: Timeout");
        }
      }
    }
    try {
      snmp.close();
    } catch (IOException e) {
      Logger.error("SNMP: couldn't close connection");
    }
    return oid;
  }
View Full Code Here

Examples of org.snmp4j.Snmp

      if (SnmpBinding.community != null) {
        CommunityTarget target = new CommunityTarget();
        target.setCommunity(new OctetString(SnmpBinding.community));
      }

      snmp = new Snmp(transport);

      transport.listen();
      logger.debug("SNMP binding is listening on " + address);
    } catch (IOException ioe) {
      logger.error("SNMP binding couldn't listen to " + address, ioe);
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.