it.jnrpe.utils.thresholds
Class LegacyThreshold

java.lang.Object
  extended by it.jnrpe.utils.thresholds.LegacyThreshold

public class LegacyThreshold
extends Object

This class represent a parser/evaluator for the old threshold syntax.

Author:
Massimiliano Ziccardi

Constructor Summary
LegacyThreshold(String metric, LegacyRange ok, LegacyRange warn, LegacyRange crit)
          Builds and initializes the threshold object.
 
Method Summary
 Status evaluate(BigDecimal value)
          Evaluates the value agains the specified ranges.
 String getMetric()
          The metric referred by this threshold.
 String getRangesAsString(Status status)
          With the new threshold format, inside one threshold you can specify ranges for OK, WARNING and CRITICAL status.
 String getUnitString()
          Returns the unit of measure as a string.
 boolean isAboutMetric(String metric)
          Returns true if this threshold references the passed in metric.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LegacyThreshold

public LegacyThreshold(String metric,
                       LegacyRange ok,
                       LegacyRange warn,
                       LegacyRange crit)
Builds and initializes the threshold object.

Parameters:
metric - The metric associated with this threshold.
ok - The ok range.
warn - The warning range.
crit - The critical range.
Method Detail

evaluate

public final Status evaluate(BigDecimal value)
Evaluates the value agains the specified ranges. The followed flow is:
  1. If a critical range is defined and the value falls inside the specified range, a Status.CRITICAL is returned.
  2. If a warning range is defined and the value falls inside the specified range, a Status.WARNING is returned.
  3. If a OK range is defined and the value falls inside the specified range, a Status.OK is returned.
  4. If the OK range is not specified, a Status.CRITICAL is returned
  5. Status.OK is returned

Parameters:
value - The value to be evaluated.
Returns:
the evaluated status.

isAboutMetric

public final boolean isAboutMetric(String metric)
Returns true if this threshold references the passed in metric.

Parameters:
metric - The metric we want to evaluate.
Returns:
wether this threshold is about the passed in metric.

getMetric

public final String getMetric()
The metric referred by this threshold.

Returns:
the metric name.

getRangesAsString

public final String getRangesAsString(Status status)
With the new threshold format, inside one threshold you can specify ranges for OK, WARNING and CRITICAL status. This method returns the unparsed range string for the specified status.

Parameters:
status - the range we are interested in.
Returns:
the requested unparsed range string.

getUnitString

public final String getUnitString()
Returns the unit of measure as a string.

Returns:
the unit of measure as string.


Copyright © 2014. All Rights Reserved.