| Nagios-Plugin-OverHTTP documentation | view source | Contained in the Nagios-Plugin-OverHTTP distribution. |
Nagios::Plugin::OverHTTP::PerformanceData - Represents performance data of a Nagios plugin
This documentation refers to Nagios::Plugin::OverHTTP::PerformanceData version 0.14
use Nagios::Plugin::OverHTTP::PerformanceData;
# 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;
This module represents performance data from plugins.
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.
This will construct a new plugin object.
%attributes is a HASH where the keys are attributes (specified in the
ATTRIBUTES section).
$attributes is a HASHREF where the keys are attributes (specified in the
ATTRIBUTES section).
This will construct a new object directly from a performance string by parsing it.
# Set an attribute $object->attribute_name($new_value); # Get an attribute my $value = $object->attribute_name;
This is the threshold for when a critical status will be issued based on the performance.
Required. This is the label for the performance data.
This is the maximum value for the performance data.
This is the minimum value for the performance data.
This is a string representing the units of measurement that the values are in.
Required. This is the performance value.
This is the threshold for when a warning status will be issued based on the performance.
This will clear the value in critical_threshold.
This will clear the value in warning_threshold.
This will return a true value if critical_threshold is set.
This will return a true value if maximum_value is set.
This will return a true value if minimum_value is set.
This will return a true value if units is set.
This will return a true value if warning_threshold is set.
This will return a true value if the value falls in the range specified by critical_threshold.
This will return a true value if the value does not fall within the critical or warning ranges.
This will return a true value if the value falls in the range specified by warning_threshold.
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'
;
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);
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].
This module is dependent on the following modules:
Douglas Christopher Wilson, <doug at somethingdoug.com>
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.
Copyright 2010 Douglas Christopher Wilson, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the terms of either:
| Nagios-Plugin-OverHTTP documentation | view source | Contained in the Nagios-Plugin-OverHTTP distribution. |