NAME
Nagios::Plugin::OverHTTP::PerformanceData - Represents performance data of a Nagios plugin
VERSION
This documentation refers to Nagios::Plugin::OverHTTP::PerformanceData version 0.16
SYNOPSIS
# New from many options
my
$data
= Nagios::Plugin::OverHTTP::PerformanceData->new(
label
=>
q{time}
,
value
=> 5,
units
=>
q{s}
,
# Seconds
);
# New from a performance string
my
$data
= Nagios::Plugin::OverHTTP::PerformanceData->new(
'time=5s'
);
# Set a new critical threshold
$data
->critical_threshold(
'@10:20'
);
# Check if matches the critical threshold
say
$data
->is_critical ?
'CRITICAL'
:
'NOT CRITICAL'
;
# Print out plugin information with performance data
printf
q{%s - %s | %s}
,
$status
,
$message
,
$data
->to_string;
DESCRIPTION
This module represents performance data from plugins.
CONSTRUCTOR
This is fully object-oriented, and as such before any method can be used, the constructor needs to be called to create an object to work with.
new
This will construct a new plugin object.
- new(%attributes)
-
%attributes
is a HASH where the keys are attributes (specified in the "ATTRIBUTES" section). - new($attributes)
-
$attributes
is a HASHREF where the keys are attributes (specified in the "ATTRIBUTES" section). - new($performance_string)
-
This will construct a new object directly from a performance string by parsing it.
ATTRIBUTES
# Set an attribute
$object
->attribute_name(
$new_value
);
# Get an attribute
my
$value
=
$object
->attribute_name;
critical_threshold
This is the threshold for when a critical status will be issued based on the performance.
label
Required. This is the label for the performance data.
maximum_value
This is the maximum value for the performance data.
minimum_value
This is the minimum value for the performance data.
units
This is a string representing the units of measurement that the values are in.
value
Required. This is the performance value.
warning_threshold
This is the threshold for when a warning status will be issued based on the performance.
METHODS
clear_critical_threshold
This will clear the value in "critical_threshold".
clear_warning_threshold
This will clear the value in "warning_threshold".
has_critical_threshold
This will return a true value if "critical_threshold" is set.
has_maximum_value
This will return a true value if "maximum_value" is set.
has_minimum_value
This will return a true value if "minimum_value" is set.
has_units
This will return a true value if "units" is set.
has_warning_threshold
This will return a true value if "warning_threshold" is set.
is_critical
This will return a true value if the value falls in the range specified by "critical_threshold".
is_ok
This will return a true value if the value does not fall within the critical or warning ranges.
is_warning
This will return a true value if the value falls in the range specified by "warning_threshold".
is_within_range
This will return a true value if the value falls within the range given as the first argument.
say
$data
->is_within_range(
'10:20'
) ?
'Outsite range of 10-20'
:
'Inside range of 10-20, inclusive'
;
split_performance_string
This will take a list of performance strings and split them at the white space while keeping intact quoted whitespace in the labels. Note that this is a static method and thus can be called as Nagios::Plugin::OverHTTP::PerformanceData->split_performance_string()
.
# Example use to get a long string of different data into objects
my
@data
=
map
{ Nagios::Plugin::OverHTTP::PerformanceData->new(
$_
) }
Nagios::Plugin::OverHTTP::PerformanceData->split_performance_string(
$string_of_many
);
to_string
This returns a string-representation of the object. The string representation of the performance data is as a preformance string in the format specified by the Nagios plugin documentation 'label'=value[UOM];[warn];[crit];[min];[max]
.
DEPENDENCIES
This module is dependent on the following modules:
Moose 0.74
Regexp::Common 2.119
namespace::clean 0.04
AUTHOR
Douglas Christopher Wilson, <doug at somethingdoug.com>
BUGS AND LIMITATIONS
Please report any bugs or feature requests to bug-nagios-plugin-overhttp at rt.cpan.org
, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Nagios-Plugin-OverHTTP. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
LICENSE AND COPYRIGHT
Copyright 2010-2012 Douglas Christopher Wilson, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the terms of either:
the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version, or
the Artistic License version 2.0.