Package org.snmp4j.event

Examples of org.snmp4j.event.ResponseEvent


   
    try {
      DefaultUdpTransportMapping udpTransportMap = new
        DefaultUdpTransportMapping();
      Snmp snmp = new Snmp(udpTransportMap);
      ResponseEvent response =  snmp.send(pdu, target);
      logger.debug("trap pdu: " + pdu);
      logger.trace("response: " + response);
     
      snmp.close();
    } catch (IOException e) {
View Full Code Here


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

    if (operation == WALK) {
      walk(snmp, request, target);
      return null;
    }
    else {
      ResponseEvent responseEvent;
      long startTime = System.currentTimeMillis();
      responseEvent = snmp.send(request, target);
      if (responseEvent != null) {
        response = responseEvent.getResponse();
        System.out.println("Received response after "+
                           (System.currentTimeMillis()-startTime)+" millis");
      }
    }
    snmp.close();
View Full Code Here

    for (final SNMPv2<UdpAddress> v2Client : this.v2Clients) {

      final OID system = new OID("1.3.6.1.2.1.1");
      final OID ifTableRow1 = new OID("1.3.6.1.2.1.2.2.1.1");
      final OID ifTableRow2 = new OID("1.3.6.1.2.1.2.2.1.2");
      final ResponseEvent response = v2Client.getBulkSync(this.address,
          2, 1, system, ifTableRow1, ifTableRow2);
      final Map<OID, Variable> bindings = ResponseEvents
          .extractBindings(response);
      Assert.assertEquals(5, bindings.size());
      Assert.assertTrue(bindings.containsKey(new OID(system.toString()
View Full Code Here

  @Test
  public void testGetNextSync() throws IOException {

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

      final ResponseEvent response = client.getNextSync(this.address,
          new OID("1.3.6.1.2.1.1.1"));
      Assert.assertNotNull(response);
      Assert.assertTrue(ResponseEvents.extractBindings(response)
          .containsKey(SnmpConstants.sysDescr));
    }
View Full Code Here

  @Test
  public void testGetSync() throws IOException {

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

      final ResponseEvent response = client.getSync(this.address,
          SnmpConstants.sysDescr);
      Assert.assertNotNull(response);
      Assert.assertTrue(ResponseEvents.extractBindings(response)
          .containsKey(SnmpConstants.sysDescr));
    }
View Full Code Here

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

      final OID beforeSysDescr = new OID("1.3.6.1.2.1.1.1");
      final OID beforeSysLocation = new OID("1.3.6.1.2.1.1.6");
      final ResponseEvent response = client.getNextSync(this.address,
          beforeSysDescr, beforeSysLocation);
      Assert.assertNotNull(response);
      Assert.assertTrue(ResponseEvents.extractBindings(response)
          .containsKey(SnmpConstants.sysDescr));
      Assert.assertTrue(ResponseEvents.extractBindings(response)
View Full Code Here

  @Test
  public void testMultiGetSync() throws IOException {

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

      final ResponseEvent response = client.getSync(this.address,
          SnmpConstants.sysDescr, SnmpConstants.sysLocation);
      Assert.assertNotNull(response);
      Assert.assertTrue(ResponseEvents.extractBindings(response)
          .containsKey(SnmpConstants.sysDescr));
      Assert.assertTrue(ResponseEvents.extractBindings(response)
View Full Code Here

  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

      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

TOP

Related Classes of org.snmp4j.event.ResponseEvent

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.