Package org.snmp4j.smi

Examples of org.snmp4j.smi.VariableBinding


  }

  @Test
  public void testNotify() throws IOException {
    for (final SNMPv2<UdpAddress> v2Client : this.v2Clients) {
      v2Client.notify(this.address, new VariableBinding(
          SnmpConstants.sysDescr));
    }
  }
View Full Code Here


      final TestResponseListener testListener = new TestResponseListener();

      final OctetString location = new OctetString("SECRET SITE #"
          + Integer.toString(new Random().nextInt(100)));
      final VariableBinding binding = new VariableBinding(
          SnmpConstants.sysLocation, location);
      client.setAsync(this.address, testListener, "handle", binding);
      testListener.waitForCallback();
      Assert.assertNotNull(testListener.getResponse());
      Assert.assertTrue(ResponseEvents.extractBindings(
View Full Code Here

  @Test
  public void testSetSync() throws IOException {

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

  }

  @Test
  public void testTrap() throws IOException {
    this.v1Client.trap(this.address, new OID(new int[] { 1, 3, 6, 1, 6, 3,
        1, 1, 5 }), PDUv1.WARMSTART, 0, new VariableBinding(new OID(
        new int[] { 1, 3, 6, 1, 6, 3, 1, 1, 5, 3 }), new Integer32(7)));
  }
View Full Code Here

        this.pdu.clear();
        this.pdu.setType(PDU.GET);

        // prepare the request items
        for (OID oid : this.endpoint.getOids()) {
            this.pdu.add(new VariableBinding(oid));
        }

        // send the request
        snmp.send(pdu, target, null, this);
View Full Code Here

        PDU trap = new PDU();
        trap.setType(PDU.TRAP);

        int alertType = snmpTrapInfo.getAlertType() + 1;
        if (alertType > 0) {
            trap.add(new VariableBinding(SnmpConstants.snmpTrapOID, getOID(CsSnmpConstants.TRAPS_PREFIX + alertType)));
            if (snmpTrapInfo.getDataCenterId() != 0) {
                trap.add(new VariableBinding(getOID(CsSnmpConstants.DATA_CENTER_ID), new UnsignedInteger32(snmpTrapInfo.getDataCenterId())));
            }

            if (snmpTrapInfo.getPodId() != 0) {
                trap.add(new VariableBinding(getOID(CsSnmpConstants.POD_ID), new UnsignedInteger32(snmpTrapInfo.getPodId())));
            }

            if (snmpTrapInfo.getClusterId() != 0) {
                trap.add(new VariableBinding(getOID(CsSnmpConstants.CLUSTER_ID), new UnsignedInteger32(snmpTrapInfo.getClusterId())));
            }

            if (snmpTrapInfo.getMessage() != null) {
                trap.add(new VariableBinding(getOID(CsSnmpConstants.MESSAGE), new OctetString(snmpTrapInfo.getMessage())));
            } else {
                throw new CloudRuntimeException(" What is the use of alert without message ");
            }

            if (snmpTrapInfo.getGenerationTime() != null) {
                trap.add(new VariableBinding(getOID(CsSnmpConstants.GENERATION_TIME), new OctetString(snmpTrapInfo.getGenerationTime().toString())));
            } else {
                trap.add(new VariableBinding(getOID(CsSnmpConstants.GENERATION_TIME)));
            }
        } else {
            throw new CloudRuntimeException(" Invalid alert Type ");
        }
View Full Code Here

  public DefaultCounterListener() {
  }

  public synchronized void incrementCounter(CounterEvent event) {
    OID id = event.getOid();
    VariableBinding counter = (VariableBinding) counters.get(id);
    if (counter == null) {
      counter = new VariableBinding(id, new Counter32(1));
      counters.put(id, counter);
    }
    else {
      ((Counter32)counter.getVariable()).increment();
    }
    // write back current value
    event.setCurrentValue((Variable)
                          ((VariableBinding)counter).getVariable().clone());
  }
View Full Code Here

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

      target.setTimeout(timeout);
      target.setVersion(SnmpConstants.version1);

    Variable var = providerCmd.getValue(itemName, command);
    OID oid = providerCmd.getOID(itemName, command);
      VariableBinding varBind = new VariableBinding(oid,var);

    // Create the PDU
    PDU pdu = new PDU();
      pdu.add(varBind);
      pdu.setType(PDU.SET);
View Full Code Here

            target.setTimeout(timeout);
            target.setVersion(SnmpConstants.version1);

          // Create the PDU
          PDU pdu = new PDU();
            pdu.add(new VariableBinding(provider.getOID(itemName)));
            pdu.setType(PDU.GET);

          logger.debug("SNMP: Send PDU {} {}", provider.getAddress(itemName), pdu);

          if (snmp == null) {
View Full Code Here

TOP

Related Classes of org.snmp4j.smi.VariableBinding

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.