Examples of ResponseEvent


Examples of org.snmp4j.event.ResponseEvent

  public void testMultiRequest() throws IOException {

    for (final SNMP<UdpAddress> client : this.allClients) {

      /* Do a get()... */
      ResponseEvent response = client.getSync(this.address,
          SnmpConstants.sysDescr);
      Assert.assertNotNull(response);
      Assert.assertTrue(ResponseEvents.extractBindings(response)
          .containsKey(SnmpConstants.sysDescr));

View Full Code Here

Examples of org.snmp4j.event.ResponseEvent

      final OctetString descr = new OctetString("SECRET DEVICE " + random);
      final VariableBinding binding1 = new VariableBinding(
          SnmpConstants.sysLocation, location);
      final VariableBinding binding2 = new VariableBinding(
          SnmpConstants.sysDescr, descr);
      ResponseEvent response = client.setSync(this.address, binding1,
          binding2);
      Assert.assertNotNull(response);
      Assert.assertTrue(ResponseEvents.extractBindings(response)
          .containsKey(SnmpConstants.sysLocation));
      Assert.assertTrue(ResponseEvents.extractBindings(response)
View Full Code Here

Examples of org.snmp4j.event.ResponseEvent

  @Test
  public void testMultiUserV3() throws IOException {

    /* Test a valid security name */
    ResponseEvent response = this.v3Client.getSync(this.address,
        SnmpConstants.sysDescr);
    Assert.assertNotNull(response);
    Assert.assertTrue(ResponseEvents.extractBindings(response).containsKey(
        SnmpConstants.sysDescr));

View Full Code Here

Examples of org.snmp4j.event.ResponseEvent

    for (final SNMP<UdpAddress> client : this.allClients) {

      final VariableBinding binding = new VariableBinding(
          SnmpConstants.sysLocation, new OctetString("SECRET SITE #"
              + Integer.toString(new Random().nextInt(100))));
      final ResponseEvent response = client
          .setSync(this.address, binding);
      Assert.assertNotNull(response);
      Assert.assertTrue(ResponseEvents.extractBindings(response)
          .containsKey(SnmpConstants.sysLocation));
    }
View Full Code Here

Examples of org.snmp4j.event.ResponseEvent

    if (address == null || !PortScan.isOpen(address, Settings.getInt("snmp.port", 161))) {
      return null;
    }
    String ipAddress = address.toString();
    HashMap<String, String> oid = new HashMap<String, String>();
    ResponseEvent response = null;
    TransportMapping transport = null;
    String oidValue = "0";
    //int count = 0;
    Properties p = new Properties();
    final File f = new File(IO.userDir, "MIB");
    String descr;
    // read from File MIB the oids to request over SNMP
    Logger.debug("Loading MIB");
    FileInputStream fis = null;
    try {
      fis = new FileInputStream(f);
      p.load(fis);
    } catch (IOException e) {
      Logger.error("Failed to open MIB.", e);
    } finally {
      try {
        fis.close();
      } catch (Exception e) {
      }
    }// end reading

    try {
      transport = new DefaultUdpTransportMapping();
      transport.listen();
    } catch (IOException e) {
    }
    // Create Target Address object
    CommunityTarget comtarget = new CommunityTarget();
    comtarget.setCommunity(new OctetString(Settings.get("snmp.community", "public")));
    comtarget.setVersion(SnmpConstants.version1);
    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();
View Full Code Here

Examples of org.springframework.data.rest.shell.context.ResponseEvent

      }
    }

    outputRequest(method.name(), requestUri, buffer);
    contextCmds.variables.put("response", response);
    ctx.publishEvent(new ResponseEvent(requestUri, method, response));
    outputResponse(response, buffer);

    if (null != outputPath) {
      FileWriter writer = null;
      try {
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.