it.jnrpe
Class ReturnValue

java.lang.Object
  extended by it.jnrpe.ReturnValue

public final class ReturnValue
extends Object

This class is just a container for the plugin result.

Author:
Massimiliano Ziccardi

Nested Class Summary
static class ReturnValue.UnitOfMeasure
          An enumeration defining all supported unit of measures.
 
Constructor Summary
ReturnValue()
          Initializes an empty return value.
ReturnValue(int returnCode, String message)
          Deprecated. Use ReturnValue(Status, String) instead
ReturnValue(Status status, String message)
          Initializes the return value object with the given state and the given message.
ReturnValue(String message)
          Initializes the return value object with the given message and with the Status.OK state.
 
Method Summary
 String getMessage()
          Returns the message.
 int getReturnCode()
          Deprecated. Use getStatus() instead.
 Status getStatus()
          Returns the status.
 ReturnValue withMessage(String message)
          Sets the message and returns 'this' so that the calls can be cascaded.
 ReturnValue withPerformanceData(String label, BigDecimal value, ReturnValue.UnitOfMeasure uom, String warningRange, String criticalRange, BigDecimal minimumValue, BigDecimal maximumValue)
          Adds performance data to the plugin result.
 ReturnValue withPerformanceData(String label, BigDecimal value, String unit, String warningRange, String criticalRange, BigDecimal minimumValue, BigDecimal maximumValue)
          Adds performance data to the plugin result.
 ReturnValue withPerformanceData(String label, Long value, ReturnValue.UnitOfMeasure uom, String warningRange, String criticalRange, Long minimumValue, Long maximumValue)
          Adds performance data to the plugin result.
 ReturnValue withReturnCode(int returnCode)
          Deprecated. Use withStatus(Status) instead.
 ReturnValue withStatus(Status status)
          Sets the return code and returns 'this' so that the calls can be cascaded.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReturnValue

public ReturnValue()
Initializes an empty return value.


ReturnValue

public ReturnValue(String message)
Initializes the return value object with the given message and with the Status.OK state.

Parameters:
message - The message

ReturnValue

@Deprecated
public ReturnValue(int returnCode,
                              String message)
Deprecated. Use ReturnValue(Status, String) instead

Initializes the return value object with the given state and the given message.

Parameters:
returnCode - The state
message - The message

ReturnValue

public ReturnValue(Status status,
                   String message)
Initializes the return value object with the given state and the given message.

Parameters:
status - The status to be returned
message - The message to be returned
Method Detail

withReturnCode

@Deprecated
public ReturnValue withReturnCode(int returnCode)
Deprecated. Use withStatus(Status) instead.

Sets the return code and returns 'this' so that the calls can be cascaded.

Parameters:
returnCode - The return code
Returns:
this

withStatus

public ReturnValue withStatus(Status status)
Sets the return code and returns 'this' so that the calls can be cascaded.

Parameters:
status - The status to be returned to Nagios
Returns:
this

withMessage

public ReturnValue withMessage(String message)
Sets the message and returns 'this' so that the calls can be cascaded.

Parameters:
message - The message to be returned
Returns:
this

getReturnCode

@Deprecated
public int getReturnCode()
Deprecated. Use getStatus() instead.

Returns the status.

Returns:
The state

getStatus

public Status getStatus()
Returns the status.

Returns:
The status

getMessage

public String getMessage()
Returns the message. If the performance data has been passed in, they are attached at the end of the message accordingly to the Nagios specifications

Returns:
The message and optionally the performance data

withPerformanceData

public ReturnValue withPerformanceData(String label,
                                       Long value,
                                       ReturnValue.UnitOfMeasure uom,
                                       String warningRange,
                                       String criticalRange,
                                       Long minimumValue,
                                       Long maximumValue)
Adds performance data to the plugin result. Thos data will be added to the output formatted as specified in Nagios specifications (http://nagiosplug.sourceforge.net/developer-guidelines.html#AEN201)

Parameters:
label - The label of the performance data we are adding
value - The performance data value
uom - The Unit Of Measure
warningRange - The warning threshold used to check this metric (can be null)
criticalRange - The critical threshold used to check this value (can be null)
minimumValue - The minimum value for this metric (can be null if not applicable)
maximumValue - The maximum value for this metric (can be null if not applicable)
Returns:
this

withPerformanceData

public ReturnValue withPerformanceData(String label,
                                       BigDecimal value,
                                       ReturnValue.UnitOfMeasure uom,
                                       String warningRange,
                                       String criticalRange,
                                       BigDecimal minimumValue,
                                       BigDecimal maximumValue)
Adds performance data to the plugin result. Thos data will be added to the output formatted as specified in Nagios specifications (http://nagiosplug.sourceforge.net/developer-guidelines.html#AEN201)

Parameters:
label - The label of the performance data we are adding
value - The performance data value
uom - The Unit Of Measure
warningRange - The warning threshold used to check this metric (can be null)
criticalRange - The critical threshold used to check this value (can be null)
minimumValue - The minimum value for this metric (can be null if not applicable)
maximumValue - The maximum value for this metric (can be null if not applicable)
Returns:
this

withPerformanceData

public ReturnValue withPerformanceData(String label,
                                       BigDecimal value,
                                       String unit,
                                       String warningRange,
                                       String criticalRange,
                                       BigDecimal minimumValue,
                                       BigDecimal maximumValue)
Adds performance data to the plugin result. Thos data will be added to the output formatted as specified in Nagios specifications (http://nagiosplug.sourceforge.net/developer-guidelines.html#AEN201)

Parameters:
label - The label of the performance data we are adding
value - The performance data value
unit - The Unit Of Measure
warningRange - The warning threshold used to check this metric (can be null)
criticalRange - The critical threshold used to check this value (can be null)
minimumValue - The minimum value for this metric (can be null if not applicable)
maximumValue - The maximum value for this metric (can be null if not applicable)
Returns:
this


Copyright © 2014. All Rights Reserved.