View Javadoc

1   /*******************************************************************************
2    * Copyright (c) 2007, 2014 Massimiliano Ziccardi
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   *******************************************************************************/
16  package it.jnrpe.utils.thresholds;
17  
18  import it.jnrpe.Status;
19  
20  import java.math.BigDecimal;
21  
22  /**
23   * This is the interface that all the threshold objects must implement.
24   * It is internally used to evaluate legacy or new threshold format.
25   *
26   * @author Massimiliano Ziccardi
27   *
28   */
29  interface IThreshold {
30  
31      /**
32       * Returns <code>true</code> if this threshold references the passed in
33       * metric.
34       *
35       * @param metric The metric name.
36       * @return <code>true</code> if this threshold references the passed in
37       * metric.
38       */
39      boolean isAboutMetric(final String metric);
40  
41      /**
42       * Evaluates the passed in value.
43       *
44       * @param value The value to be evaluated
45       * @return <code>true</code> if the passed in value falls inside this
46       * thresholds.
47       */
48      Status evaluate(final BigDecimal value);
49  
50      /**
51       * @return The name of the metric referred by this threshold.
52       */
53      String getMetric();
54  
55      /**
56       * With the new threshold format, inside one threshold you can specify
57       * ranges for OK, WARNING and CRITICAL status. This method returns the
58       * unparsed range string for the specified status.
59       *
60       * @param status The status for wich we want the range string
61       * @return The requested range string.
62       */
63      String getRangesAsString(final Status status);
64  
65      /**
66       * Returns the unit of measure as a string.
67       * @return The unit of measure.
68       */
69      String getUnitString();
70  }