it.jnrpe.utils.thresholds
Class ReturnValueBuilder

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

public final class ReturnValueBuilder
extends Object

This object takes the responsability to build and configure the return value object and the performance data. The plugin has only the responsability to gain the metrics and pass them to the builder: both status and performance data will be generated.

Author:
Massimiliano Ziccardi

Method Summary
 ReturnValue create()
          Builds the configured ReturnValue object.
static ReturnValueBuilder forPlugin(String name)
          Constructs the object with an empty threshold evaluator.
static ReturnValueBuilder forPlugin(String name, ThresholdsEvaluator thr)
          Constructs the object with the given threshold evaluator.
 ReturnValueBuilder withForcedMessage(String message)
          Force the message to return to Nagios.
 ReturnValueBuilder withStatus(Status forceStatus)
          Use this method if you want to force the status to be returned.
 ReturnValueBuilder withValue(Metric pluginMetric)
          Configure the ReturnValue we are building with the specified value.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

forPlugin

public static ReturnValueBuilder forPlugin(String name)
Constructs the object with an empty threshold evaluator.

Parameters:
name - The name of the plugin that is creating this result
Returns:
the newly created instance.

forPlugin

public static ReturnValueBuilder forPlugin(String name,
                                           ThresholdsEvaluator thr)
Constructs the object with the given threshold evaluator.

Parameters:
name - The name of the plugin that is creating this result
thr - The threshold evaluator.
Returns:
the newly created instance.

withValue

public ReturnValueBuilder withValue(Metric pluginMetric)
Configure the ReturnValue we are building with the specified value.

Parameters:
pluginMetric - The metric for wich we want to compute the result Status.
Returns:
this

withForcedMessage

public ReturnValueBuilder withForcedMessage(String message)
Force the message to return to Nagios. Instead of computing the message using the Metric object received in the withValue(Metric) methods, this value will be returned.

Parameters:
message - The message to return.
Returns:
this

withStatus

public ReturnValueBuilder withStatus(Status forceStatus)
Use this method if you want to force the status to be returned. This can be useful if, for example, your check got an error and has no metric to be evaluated to automatically compute the status.

Parameters:
forceStatus - The status to be forced
Returns:
this

create

public ReturnValue create()
Builds the configured ReturnValue object.

Returns:
The ReturnValue object


Copyright © 2014. All Rights Reserved.