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.plugins; 17 18 import java.math.BigDecimal; 19 20 /** 21 * This class represent a metric gathered from a plugin. 22 * 23 * @author Massimiliano Ziccardi 24 */ 25 public class Metric { 26 /** 27 * The name of the metric. 28 */ 29 private final String metricName; 30 31 /** 32 * The message associated with this metric. This is the message that will be 33 * returned to Nagios if the user requested for this metric. 34 */ 35 private final String metricMessage; 36 37 /** 38 * The value of this metric. 39 */ 40 private final BigDecimal metricValue; 41 42 /** 43 * The maximum value for this metric. 44 */ 45 private final BigDecimal minValue; 46 47 /** 48 * The minimum value for this metric. 49 */ 50 private final BigDecimal maxValue; 51 52 /** 53 * Builds and initializes a metric object. 54 * 55 * @param name 56 * The name of the metric 57 * @param message 58 * The message associated with this metric. For example: disk 59 * usage 50%. 60 * @param value 61 * The value of this metric (can't be null) 62 * @param min 63 * The minimum value for this metric (can be null) 64 * @param max 65 * The maximum value for this metric (can be null) 66 */ 67 public Metric(final String name, final String message, 68 final BigDecimal value, final BigDecimal min, final BigDecimal max) { 69 metricName = name; 70 metricValue = value; 71 minValue = min; 72 maxValue = max; 73 metricMessage = message; 74 } 75 76 /** 77 * @return The name of this metric. 78 */ 79 public final String getMetricName() { 80 return metricName; 81 } 82 83 /** 84 * @return The value of this metric. 85 */ 86 public final BigDecimal getMetricValue() { 87 return metricValue; 88 } 89 90 /** 91 * @return The minimum value for this metric. 92 */ 93 public final BigDecimal getMinValue() { 94 return minValue; 95 } 96 97 /** 98 * @return The maximum value for this metric. 99 */ 100 public final BigDecimal getMaxValue() { 101 return maxValue; 102 } 103 104 /** 105 * @return The message associated with this metric. 106 */ 107 public final String getMessage() { 108 return metricMessage; 109 } 110 }