Exemplo n.º 1
0
  /**
   * Verifies that the result of the SNMP query meets the criteria specified by the operator and the
   * operand from the configuration file.
   *
   * @param result a {@link org.opennms.netmgt.snmp.SnmpValue} object.
   * @param operator a {@link java.lang.String} object.
   * @param operand a {@link java.lang.String} object.
   * @return a boolean.
   */
  protected boolean meetsCriteria(SnmpValue result, String operator, String operand) {

    Boolean retVal = null;

    retVal = isCriteriaNull(result, operator, operand);

    if (retVal == null) {
      String value = result.toString();
      retVal = checkStringCriteria(operator, operand, value);

      if (retVal == null) {
        BigInteger val = BigInteger.valueOf(result.toLong());

        BigInteger intOperand = new BigInteger(operand);
        if (LESS_THAN.equals(operator)) {
          return val.compareTo(intOperand) < 0;
        } else if (LESS_THAN_EQUALS.equals(operator)) {
          return val.compareTo(intOperand) <= 0;
        } else if (GREATER_THAN.equals(operator)) {
          return val.compareTo(intOperand) > 0;
        } else if (GREATER_THAN_EQUALS.equals(operator)) {
          return val.compareTo(intOperand) >= 0;
        } else {
          throw new IllegalArgumentException("operator " + operator + " is unknown");
        }
      }
    } else if (retVal.booleanValue()) {
      return true;
    }

    return retVal.booleanValue();
  }
 private Long getIfHighSpeed() {
   final SnmpValue value = getValue(IF_HIGH_SPEED);
   return value == null ? null : value.toLong();
 }
Exemplo n.º 3
0
 /**
  * getStorableValue
  *
  * @param snmpVal a {@link org.opennms.netmgt.snmp.SnmpValue} object.
  * @return a {@link java.lang.String} object.
  */
 public String getStorableValue(SnmpValue snmpVal) {
   return (snmpVal == null ? null : Long.toString(snmpVal.toLong()));
 }