当前位置: 首页>>代码示例>>Java>>正文


Java VariableBinding.getOid方法代码示例

本文整理汇总了Java中org.snmp4j.smi.VariableBinding.getOid方法的典型用法代码示例。如果您正苦于以下问题:Java VariableBinding.getOid方法的具体用法?Java VariableBinding.getOid怎么用?Java VariableBinding.getOid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.snmp4j.smi.VariableBinding的用法示例。


在下文中一共展示了VariableBinding.getOid方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: checkWalkFinished

import org.snmp4j.smi.VariableBinding; //导入方法依赖的package包/类
private static boolean checkWalkFinished(OID targetOID, PDU pdu, VariableBinding vb) {
    boolean finished = false;
    if (pdu.getErrorStatus() != 0) {
        finished = true;
    } else if (vb.getOid() == null) {
        finished = true;
    } else if (vb.getOid().size() < targetOID.size()) {
        finished = true;
    } else if (targetOID.leftMostCompare(targetOID.size(), vb.getOid()) != 0) {
        finished = true;
    } else if (Null.isExceptionSyntax(vb.getVariable().getSyntax())) {
        finished = true;
    } else if (vb.getOid().compareTo(targetOID) <= 0) {
        finished = true;
    }
    return finished;

}
 
开发者ID:DevopsJK,项目名称:SuitAgent,代码行数:19,代码来源:SNMPHelper.java

示例2: resolveVarbinds

import org.snmp4j.smi.VariableBinding; //导入方法依赖的package包/类
private VariableBinding[] resolveVarbinds(VarbindCollection varbinds) {
  VariableBinding[] resolvedVarbinds = new VariableBinding[varbinds.size()];
  for (int i = 0; i < varbinds.size(); i++) {
    Varbind varbind = varbinds.get(i);
    if (varbind instanceof Snmp4jVarbind) {
      VariableBinding vb = ((Snmp4jVarbind) varbind).getDelegate();
      resolvedVarbinds[i] = new VariableBinding(vb.getOid());
      resolvedVarbinds[i].setVariable(vb.getVariable());
    }
    else {
      resolvedVarbinds[i] = resolveVarbind(varbind);
    }
  }
  return resolvedVarbinds;
}
 
开发者ID:soulwing,项目名称:tnm4j,代码行数:16,代码来源:Snmp4jContext.java

示例3: checkWalkFinished

import org.snmp4j.smi.VariableBinding; //导入方法依赖的package包/类
private static boolean checkWalkFinished(OID targetOID, PDU pdu,
    VariableBinding vb) {
  boolean finished = false;
  if (pdu.getErrorStatus() != 0) {
    System.out.println("[true] responsePDU.getErrorStatus() != 0 ");
    System.out.println(pdu.getErrorStatusText());
    finished = true;
  } else if (vb.getOid() == null) {
    System.out.println("[true] vb.getOid() == null");
    finished = true;
  } else if (vb.getOid().size() < targetOID.size()) {
    System.out.println("[true] vb.getOid().size() < targetOID.size()");
    finished = true;
  } else if (targetOID.leftMostCompare(targetOID.size(), vb.getOid()) != 0) {
    System.out.println("[true] targetOID.leftMostCompare() != 0");
    finished = true;
  } else if (Null.isExceptionSyntax(vb.getVariable().getSyntax())) {
    System.out
        .println("[true] Null.isExceptionSyntax(vb.getVariable().getSyntax())");
    finished = true;
  } else if (vb.getOid().compareTo(targetOID) <= 0) {
    System.out.println("[true] Variable received is not "
        + "lexicographic successor of requested " + "one:");
    System.out.println(vb.toString() + " <= " + targetOID);
    finished = true;
  }
  return finished;
 
}
 
开发者ID:waylau,项目名称:snmp4j-demos,代码行数:30,代码来源:SnmpData.java

示例4: checkWalkFinished

import org.snmp4j.smi.VariableBinding; //导入方法依赖的package包/类
private static boolean checkWalkFinished(OID walkOID, PDU pdu,
		VariableBinding vb) {
	boolean finished = false;
	if (pdu.getErrorStatus() != 0) {
		System.out.println("[true] pdu.getErrorStatus() != 0 ");
		System.out.println(pdu.getErrorStatusText());
		finished = true;
	} else if (vb.getOid() == null) {
		System.out.println("[true] vb.getOid() == null");
		finished = true;
	} else if (vb.getOid().size() < walkOID.size()) {
		System.out.println("[true] vb.getOid().size() < targetOID.size()");
		finished = true;
	} else if (walkOID.leftMostCompare(walkOID.size(), vb.getOid()) != 0) {
		System.out.println("[true] targetOID.leftMostCompare() != 0");
		finished = true;
	} else if (Null.isExceptionSyntax(vb.getVariable().getSyntax())) {
		System.out
				.println("[true] Null.isExceptionSyntax(vb.getVariable().getSyntax())");
		finished = true;
	} else if (vb.getOid().compareTo(walkOID) <= 0) {
		System.out.println("[true] vb.getOid().compareTo(walkOID) <= 0 ");
		finished = true;
	}
	return finished;

}
 
开发者ID:micmiu,项目名称:snmp-tutorial,代码行数:28,代码来源:SnmpWalkMuliTAsyn.java

示例5: checkWalkFinished

import org.snmp4j.smi.VariableBinding; //导入方法依赖的package包/类
/**
 * 1)responsePDU == null<br>
 * 2)responsePDU.getErrorStatus() != 0<br>
 * 3)responsePDU.get(0).getOid() == null<br>
 * 4)responsePDU.get(0).getOid().size() < targetOID.size()<br>
 * 5)targetOID.leftMostCompare(targetOID.size(),responsePDU.get(0).getOid())
 * !=0<br>
 * 6)Null.isExceptionSyntax(responsePDU.get(0).getVariable().getSyntax())<br>
 * 7)responsePDU.get(0).getOid().compareTo(targetOID) <= 0<br>
 *
 * @param targetOID
 * @param pdu
 * @param vb
 * @return
 */
private static boolean checkWalkFinished(OID targetOID, PDU pdu,
		VariableBinding vb) {
	boolean finished = false;
	if (pdu.getErrorStatus() != 0) {
		System.out.println("[true] responsePDU.getErrorStatus() != 0 ");
		System.out.println(pdu.getErrorStatusText());
		finished = true;
	} else if (vb.getOid() == null) {
		System.out.println("[true] vb.getOid() == null");
		finished = true;
	} else if (vb.getOid().size() < targetOID.size()) {
		System.out.println("[true] vb.getOid().size() < targetOID.size()");
		finished = true;
	} else if (targetOID.leftMostCompare(targetOID.size(), vb.getOid()) != 0) {
		System.out.println("[true] targetOID.leftMostCompare() != 0");
		finished = true;
	} else if (Null.isExceptionSyntax(vb.getVariable().getSyntax())) {
		System.out
				.println("[true] Null.isExceptionSyntax(vb.getVariable().getSyntax())");
		finished = true;
	} else if (vb.getOid().compareTo(targetOID) <= 0) {
		System.out.println("[true] Variable received is not "
				+ "lexicographic successor of requested " + "one:");
		System.out.println(vb.toString() + " <= " + targetOID);
		finished = true;
	}
	return finished;

}
 
开发者ID:micmiu,项目名称:snmp-tutorial,代码行数:45,代码来源:SnmpWalk.java

示例6: setTrapName

import org.snmp4j.smi.VariableBinding; //导入方法依赖的package包/类
private void setTrapName(SnmpTrap snmpTrap,Vector<? extends VariableBinding> varBinds) {
	SmiManager smiManager = this.getSmiManager();
	
	for(VariableBinding vb : varBinds) {
		OID oid = vb.getOid();
		SmiObject object = smiManager.findSmiObject(oid);
		if (object != null && object.getType() == SmiType.NOTIFICATION_TYPE) {
			String objectName = object.getObjectName();
			snmpTrap.setTrapName(objectName);
			LOG.info("Setting trap type to: {}",objectName);
		}
	}
	
}
 
开发者ID:boundary,项目名称:boundary-event-sdk,代码行数:15,代码来源:SnmpMessageToTrap.java

示例7: splitBody

import org.snmp4j.smi.VariableBinding; //导入方法依赖的package包/类
/**
   * The split body method returns something that is iteratable such as a java.util.List.
   *
   * @param body the payload of the incoming message
   * @return a list containing each part splitted
   */
  public List<VariableBinding> splitBody(Vector<? extends VariableBinding> body) {

      List<VariableBinding> answer = new ArrayList<VariableBinding>();
for (VariableBinding var : body) {
	OID oid = var.getOid();
	Variable variable = var.getVariable();
	LOG.debug("oid: {}, value: {}, syntax: {}",oid,variable.toLong(),variable.getSyntaxString());
	answer.add(var);
}
      return answer;
  }
 
开发者ID:boundary,项目名称:boundary-event-sdk,代码行数:18,代码来源:SplitVarBinds.java

示例8: splitMessage

import org.snmp4j.smi.VariableBinding; //导入方法依赖的package包/类
/**
   * The split message method returns something that is iteratable such as a java.util.List.
   *
   * @param body the payload of the incoming message
   * @return a list containing each part splitted
   */
  public List<VariableBinding> splitMessage(@Body Vector<? extends VariableBinding> body) {

      List<VariableBinding> answer = new ArrayList<VariableBinding>();
for (VariableBinding var : body) {
	OID oid = var.getOid();
	Variable variable = var.getVariable();
	LOG.debug("oid: {}, value: {}, syntax: {}",oid,variable.toLong(),variable.getSyntaxString());
	answer.add(var);
}
      return answer;
  }
 
开发者ID:boundary,项目名称:boundary-event-sdk,代码行数:18,代码来源:SplitVarBinds.java

示例9: get

import org.snmp4j.smi.VariableBinding; //导入方法依赖的package包/类
public Map<OID, Variable> get(Collection<OID> oids) throws IOException {
    Map<OID, Variable> map = new LinkedHashMap<OID, Variable>();
    PDU request = createPDU();
    request.setType(PDU.GET);
    request.setVariableBindings(wrap(oids));
    boolean debug = log.isDebugEnabled();
    if (debug)
        log.debug("request " + request);
    ResponseEvent re = snmp.send(request, this.target);
    PDU response = re.getResponse();
    if (debug)
        log.debug("response " + response);
    if (response == null) {
        throw new NoResponseException("no response querying " + oids);
    }
    if (re.getError() != null)
        throw new IOException(re.getError());
    Vector<? extends VariableBinding> vbs = response.getVariableBindings();
    if (vbs.size() == 1) {
        String error = Errors.get(vbs.get(0).getOid());
        if (error != null)
            throw new IOException("got SNMP error " + error);
    }
    for (VariableBinding vb : vbs) {
        OID oid = vb.getOid();
        map.put(oid, vb.getVariable());
    }
    return map;
}
 
开发者ID:genman,项目名称:rhq-plugins,代码行数:30,代码来源:SnmpComponent.java

示例10: BEROIDConversion

import org.snmp4j.smi.VariableBinding; //导入方法依赖的package包/类
/**
 * 
 * @param bBER
 */
public BEROIDConversion (byte[] bBER) {
	
	if (debug) {
		
		HexString hs = new HexString(bBER);
		
		logger.debug("BEROIDConversion() " + hs.toString());
	}
	
	//Save copy of BER
	this.bBER = bBER;

	//Convert to ByteBuffer
	bbBER = ByteBuffer.allocate(this.bBER.length);

	//Add byte Array
	bbBER.put(this.bBER).rewind();
	
	//Convert to BERInputStream
	bisBER = new BERInputStream(bbBER);
	
	//Create a VarBind
	vbBER = new VariableBinding();
	
	try {
		vbBER.decodeBER(bisBER);
	} catch (IOException e) {
		if (debug) {
			e.printStackTrace();	
		}
		
	}

	oOID = vbBER.getOid();
	
	if (debug) {
		logger.debug("BEROIDConversion() " + oOID.toString());
		logger.debug("BEROIDConversion() " + vbBER.toString());
		logger.debug("BEROIDConversion() " + vbBER.getSyntax());
	}
	
}
 
开发者ID:Comcast,项目名称:Oscar,代码行数:47,代码来源:BEROIDConversion.java

示例11: walk

import org.snmp4j.smi.VariableBinding; //导入方法依赖的package包/类
public static List<VariableBinding> walk(Target target, OID oid) {
    List<VariableBinding> ret = new ArrayList<VariableBinding>();

    PDU requestPDU = new PDU();
    requestPDU.add(new VariableBinding(oid));
    requestPDU.setType(PDU.GETNEXT);
    boolean finished = false;
    try{
        while (!finished) {
            VariableBinding vb = null;

            ResponseEvent respEvt = snmp.send(requestPDU, target);
            PDU responsePDU = respEvt.getResponse();
            if (responsePDU != null) {
                vb = responsePDU.get(0);
            }

            if (responsePDU == null) {
                finished = true;
            } else if (responsePDU.getErrorStatus() != 0) {
                finished = true;
            } else if (vb.getOid() == null) {
                finished = true;
            } else if (vb.getOid().size() < oid.size()) {
                finished = true;
            } else if (oid.leftMostCompare(oid.size(), vb.getOid()) != 0) {
                finished = true;
            } else if (Null.isExceptionSyntax(vb.getVariable().getSyntax())) {
                finished = true;
            } else if (vb.getOid().compareTo(oid) <= 0) {
                finished = true;
            } else {
                ret.add(vb);

                // Set up the variable binding for the next entry.
                requestPDU.setRequestID(new Integer32(0));
                requestPDU.set(0, vb);
            }
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
    return ret;
}
 
开发者ID:PRTG,项目名称:JMXMiniProbe,代码行数:45,代码来源:SNMPUtil.java

示例12: processV2Trap

import org.snmp4j.smi.VariableBinding; //导入方法依赖的package包/类
/**
 * Converts an {@link SnmpMessage}/{@link PDU} into a {@link RawEvent}
 * 
 * @param message - Contains a {@link SnmpMessage}
 * @param pdu - Contains a {@link PDU} with the actual trap contents
 * @param event - {@link RawEvent} to be populated.
 */
public void processV2Trap(SnmpMessage message, PDU pdu, RawEvent event) {
	String specificTrap = "";
	String hostname = getPeerAddress(message);
	
	// CREATED_AT
	event.setCreatedAt(new Date());

	// FINGERPRINT_FIELDS
	event.addFingerprintField(HOSTNAME_PROPERTY_NAME);
	
	// ORGANIZATION_ID - TBD: Override based on content of the PDU?
	
	// PROPERTIES
	event.addProperty(HOSTNAME_PROPERTY_NAME, hostname);
	event.addProperty("error_status", pdu.getErrorStatusText());
	
	
	// Get the variable bindings from the trap and create properties in the event
	Vector<? extends VariableBinding> varBinds = pdu.getVariableBindings();
	for (VariableBinding var : varBinds) {
		OID oid = var.getOid();

		if (oid.startsWith(SnmpConstants.snmpTraps) ||
			oid.startsWith(SnmpConstants.snmpTrapOID)) {
			specificTrap = var.toValueString();
			event.addProperty("trap",specificTrap);
			// MESSAGE
			event.setMessage(var.toValueString());
		}
		else {
			event.addProperty(var.getOid().toString(),var.toValueString());
			event.addFingerprintField(var.getOid().toString());
		}
		mapVarbindToEvent(event,var);
	}
	
	// RECEIVED_AT - Default to value set by Boundary
	
	// SENDER
	event.getSender().setRef(SENDER_REF).setType(SENDER_TYPE);

	// SEVERITY - TBD: set the severity based on content of the trap
	event.setSeverity(Severity.WARN);

	// SOURCE
	event.getSource().setRef(hostname).setType("host");
	
	//STATUS - TBD: Set status based on severity??
	event.setStatus(Status.OPEN);

	// TAGS
	event.addTag(hostname);
	
	// TITLE
	event.setTitle(specificTrap + " trap received from " + hostname);
}
 
开发者ID:boundary,项目名称:boundary-event-sdk,代码行数:64,代码来源:SnmpToEventProcessor.java


注:本文中的org.snmp4j.smi.VariableBinding.getOid方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。