本文整理汇总了Java中org.snmp4j.smi.OID.startsWith方法的典型用法代码示例。如果您正苦于以下问题:Java OID.startsWith方法的具体用法?Java OID.startsWith怎么用?Java OID.startsWith使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.snmp4j.smi.OID
的用法示例。
在下文中一共展示了OID.startsWith方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: endOfTable
import org.snmp4j.smi.OID; //导入方法依赖的package包/类
private boolean endOfTable(int offset) {
if (response == null) {
throw new WouldBlockException();
}
int i = 0;
while (offset + i < response.size() && i < repeaters) {
OID oid = response.get(offset + i).getOid();
if (!oid.startsWith(requestedVarbinds[nonRepeaters + i].getOid())) {
return true;
}
i++;
}
if (i < repeaters) {
setNextOids(offset - repeaters);
throw new WouldBlockException();
}
return false;
}
示例2: toName
import org.snmp4j.smi.OID; //导入方法依赖的package包/类
/**
* Inverse operation of {@link #toOid(String)}.
* Returns the exact matching name part suffixed with the remainder OID.
*/
public String toName(OID oid) {
if (oid == null)
throw new NullPointerException("value");
String name = this.oids.get(oid);
if (name != null)
return name;
Entry<OID, String> lowerEntry = this.oids.lowerEntry(oid);
if (lowerEntry != null && oid.startsWith(lowerEntry.getKey())) {
OID parent = lowerEntry.getKey();
OID suffix = new OID(oid.getValue(), parent.size(), oid.size() - parent.size());
return lowerEntry.getValue() + "." + suffix;
}
return oid.toString();
}
示例3: match
import org.snmp4j.smi.OID; //导入方法依赖的package包/类
/**
* Returns the matching severity for this PDU, or null if no match.
*/
public EventSeverity match(PDU pdu) {
if (pdu instanceof PDUv1) {
PDUv1 pdu1 = (PDUv1) pdu;
if (genericTrap != UNSET && genericTrap != pdu1.getGenericTrap()) {
log.trace("no match generic trap");
return null;
}
if (specificTrap != UNSET && specificTrap != pdu1.getSpecificTrap()) {
log.trace("no match specific trap");
return null;
}
if (!pdu1.getEnterprise().startsWith(enterprise)) {
log.trace("no match enterprise");
return null;
}
} else {
OID oid = (OID) pdu.getVariable(SnmpConstants.snmpTrapOID);
if (oid != null && oid.startsWith(trapOid)) {
log.trace("no match enterprise");
return null;
}
}
if (varbind.size() != 0) {
Variable v = pdu.getVariable(varbind);
if (v == null) {
log.trace("no required variable found");
return null;
}
if (!value.matcher(v.toString()).find()) {
log.trace("no match variable");
return null;
}
}
return severity;
}
示例4: get
import org.snmp4j.smi.OID; //导入方法依赖的package包/类
/**
* @param oid
* @return
*/
public VariableBinding get(OID oid) {
for (OID agentKey : m_subAgents.keySet()) {
if (oid.startsWith(agentKey)) {
SubAgent subAgent = m_subAgents.get(agentKey);
return subAgent.get(oid);
}
}
return null;
}
示例5: processV2Trap
import org.snmp4j.smi.OID; //导入方法依赖的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);
}
示例6: matches
import org.snmp4j.smi.OID; //导入方法依赖的package包/类
/**
* Returns {@code true} if this wildcard {@code OID} matches with the specified {@code OID}.
* <p/>
* Here some examples for matching {@code OID}s:
* <ul>
* <li>{@code .1.3.3.*.7} and {@code .1.3.3.7}</li>
* <li>{@code .1.3.3.*.7} and {@code .1.3.3.3.7}</li>
* <li>{@code .1.3.3.*.7} and {@code .1.3.3.1.2.3.4.5.7}</li>
* </ul>
*
* @param oid the {@code OID} to test
* @return {@code true} if the {@code OID}s are matching, otherwise {@code false}
*/
public boolean matches(final OID oid) {
return oid.startsWith(startsWith) && (endsWith == null || oid.size() >= endsWith.size() && oid.rightMostCompare(endsWith.size(), endsWith) == 0);
}