Examples of VariableBinding


Examples of org.snmp4j.smi.VariableBinding

    protected PDU createPDU(String mibName, int type) throws MIBLookupException {
        PDU pdu = new DefaultPDUFactory().createPDU(this.target);
        pdu.setType(type);
        OID oid = SNMPClient.getMibOID(mibName);
        pdu.add(new VariableBinding(oid));
        return pdu;
    }
View Full Code Here

Examples of org.snmp4j.smi.VariableBinding

                  "' contains "+l.size()+" objects.");
      OctetString ctx = new OctetString();
      SortedMap roots = new TreeMap();
      OID last = null;
      for (Iterator it = l.iterator(); it.hasNext(); ) {
        VariableBinding vb = (VariableBinding) it.next();
        if (last != null) {
          int min = Math.min(vb.getOid().size(), last.size());
          while (min > 0) {
            if (vb.getOid().leftMostCompare(min, last) == 0) {
              OID root = new OID(last.getValue(), 0, min);
              roots.put(root, root);
              break;
            }
            min--;
          }
        }
        last = vb.getOid();
      }
      logger.info("Identified the following sub-tree candidates: "+roots);
      SortedMap rootsCopy = new TreeMap();
      for (Iterator it = roots.keySet().iterator(); it.hasNext();) {
        OID k = (OID) it.next();
        if (k.size() > 1) {
          OID sk = new OID(k.getValue(), 0, k.size()-1);
          while ((sk.size() > 0) &&  (roots.get(sk) == null)) {
            sk.trim(1);
          }
          if (sk.size() == 0) {
            rootsCopy.put(k,k);
          }
        }
      }
      logger.info("Identified the following sub-trees "+rootsCopy);
      for (Iterator it = rootsCopy.keySet().iterator(); it.hasNext();) {
        OID root = (OID) it.next();
        ArrayList subtree = new ArrayList();
        for (Iterator vit = l.iterator(); vit.hasNext(); ) {
          VariableBinding vb = (VariableBinding) vit.next();
          if (vb.getOid().size() >= root.size()) {
            if (vb.getOid().leftMostCompare(root.size(), root) == 0) {
              subtree.add(vb);
            }
          }
        }
        StaticMOGroup group =
View Full Code Here

Examples of org.snmp4j.smi.VariableBinding

        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

Examples of org.snmp4j.smi.VariableBinding

  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

Examples of org.snmp4j.smi.VariableBinding

        }
      }
      else if ((type == PDU.TRAP) || (type == PDU.INFORM)) {
        Number tu = (Number) ArgumentParser.getValue(settings, oTrapSysUpTime, 0);
        if (tu != null) {
          pdu.add(new VariableBinding(SnmpConstants.sysUpTime,
                                      new TimeTicks(tu.longValue())));
        }
        String to = (String) ArgumentParser.getValue(settings, oTrapOID, 0);
        if (to != null) {
          pdu.add(new VariableBinding(SnmpConstants.snmpTrapOID, new OID(to)));
        }
      }
      else if (type == PDU.V1TRAP) {
        PDUv1 pduV1 = (PDUv1)pdu;
        String aa =
View Full Code Here

Examples of org.snmp4j.smi.VariableBinding

        // prepare the header
        sb.append(SNMP_TAG_OPEN);
               
        // now loop all variables of the response
        for (Object o : pdu.getVariableBindings()) {
            VariableBinding b = (VariableBinding)o;

            sb.append(ENTRY_TAG_OPEN);
            sb.append(OID_TAG_OPEN);
            sb.append(b.getOid().toString());
            sb.append(OID_TAG_CLOSE);
            sb.append(VALUE_TAG_OPEN);
            sb.append(getXmlSafeString(b.getVariable().toString()));
            sb.append(VALUE_TAG_CLOSE);
            sb.append(ENTRY_TAG_CLOSE);
        }
       
        // prepare the footer
View Full Code Here

Examples of org.snmp4j.smi.VariableBinding

        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

Examples of org.snmp4j.smi.VariableBinding

        // prepare the header
        sb.append(SNMP_TAG_OPEN);
               
        // now loop all variables of the response
        for (Object o : pdu.getVariableBindings()) {
            VariableBinding b = (VariableBinding)o;

            sb.append(ENTRY_TAG_OPEN);
            sb.append(OID_TAG_OPEN);
            sb.append(b.getOid().toString());
            sb.append(OID_TAG_CLOSE);
            sb.append(VALUE_TAG_OPEN);
            sb.append(b.getVariable().toString());
            sb.append(VALUE_TAG_CLOSE);
            sb.append(ENTRY_TAG_CLOSE);
        }
       
        // prepare the footer
View Full Code Here

Examples of org.snmp4j.smi.VariableBinding

            entryAppend(sb, "time-stamp", Long.toString(v1pdu.getTimestamp()));
        }

        // now loop all variables of the response
        for (Object o : pdu.getVariableBindings()) {
            VariableBinding b = (VariableBinding)o;

            sb.append(ENTRY_TAG_OPEN);
            sb.append(OID_TAG_OPEN);
            sb.append(b.getOid().toString());
            sb.append(OID_TAG_CLOSE);
            sb.append(VALUE_TAG_OPEN);
            sb.append(getXmlSafeString(b.getVariable().toString()));
            sb.append(VALUE_TAG_CLOSE);
            sb.append(ENTRY_TAG_CLOSE);
        }

        // prepare the footer
View Full Code Here

Examples of org.snmp4j.smi.VariableBinding

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