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


Java OID.startsWith方法代码示例

本文整理汇总了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;
}
 
开发者ID:soulwing,项目名称:tnm4j,代码行数:19,代码来源:AbstractAsyncWalker.java

示例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();
}
 
开发者ID:genman,项目名称:rhq-plugins,代码行数:19,代码来源:MibIndex.java

示例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;
}
 
开发者ID:genman,项目名称:rhq-plugins,代码行数:39,代码来源:Rule.java

示例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;
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:14,代码来源:MockAgent.java

示例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);
}
 
开发者ID:boundary,项目名称:boundary-event-sdk,代码行数:64,代码来源:SnmpToEventProcessor.java

示例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);
}
 
开发者ID:1and1,项目名称:snmpman,代码行数:17,代码来源:WildcardOID.java


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