1Nagios::Plugin::PerformUasnecre(C3o)ntributed Perl DocumNeangtiaotsi:o:nPlugin::Performance(3)
2
3
4

NAME

6       Nagios::Plugin::Performance - class for handling Nagios::Plugin
7       performance data.
8

SYNOPSIS

10         use Nagios::Plugin::Performance use_die => 1;
11
12         # Constructor (also accepts a 'threshold' obj instead of warning/critical)
13         $p = Nagios::Plugin::Performance->new(
14             label     => 'size',
15             value     => $value,
16             uom       => "kB",
17             warning   => $warning,
18             critical  => $critical,
19             min       => $min,
20             max       => $max,
21         );
22
23         # Parser
24         @perf = Nagios::Plugin::Performance->parse_perfstring(
25             "/=382MB;15264;15269;; /var=218MB;9443;9448"
26         )
27         or warn("Failed to parse perfstring");
28
29         # Accessors
30         for $p (@perf) {
31           printf "label:    %s\n",   $p->label;
32           printf "value:    %s\n",   $p->value;
33           printf "uom:      %s\n",   $p->uom;
34           printf "warning:  %s\n",   $p->warning;
35           printf "critical: %s\n",   $p->critical;
36           printf "min:      %s\n",   $p->min;
37           printf "max:      %s\n",   $p->max;
38           # Special accessor returning a threshold obj containing warning/critical
39           $threshold = $p->threshold;
40         }
41
42         # Perfdata output format i.e. label=value[uom];[warn];[crit];[min];[max]
43         print $p->perfoutput;
44

DESCRIPTION

46       Nagios::Plugin class for handling performance data. This is a public
47       interface because it could be used by performance graphing routines,
48       such as nagiostat (http://nagiostat.sourceforge.net), perfparse
49       (http://perfparse.sourceforge.net), nagiosgraph
50       (http://nagiosgraph.sourceforge.net) or NagiosGrapher
51       (http://www.nagiosexchange.org/NagiosGrapher.84.0.html).
52
53       Nagios::Plugin::Performance offers both a parsing interface (via
54       parse_perfstring), for turning nagios performance output strings into
55       their components, and a composition interface (via new), for turning
56       components into perfdata strings.
57

USE'ING THE MODULE

59       If you are using this module for the purposes of parsing perf data, you
60       will probably want to set use_die => 1 at use time. This forces
61       &Nagios::Plugin::Functions::nagios_exit to call die() - rather than
62       exit() - when an error occurs. This is then trappable by an eval. If
63       you don't set use_die, then an error in these modules will cause your
64       script to exit
65

CLASS METHODS

67       Nagios::Plugin::Performance->new(%attributes)
68           Instantiates a new Nagios::Plugin::Performance object with the
69           given attributes.
70
71       Nagios::Plugin::Performance->parse_perfstring($string)
72           Returns an array of Nagios::Plugin::Performance objects based on
73           the string entered. If there is an error parsing the string - which
74           may consists of several sets of data -  will return an array with
75           all the successfully parsed sets.
76
77           If values are input with commas instead of periods, due to
78           different locale settings, then it will still be parsed, but the
79           commas will be converted to periods.
80

OBJECT METHODS (ACCESSORS)

82       label, value, uom, warning, critical, min, max
83           These all return scalars. min and max are not well supported yet.
84
85       threshold
86           Returns a Nagios::Plugin::Threshold object holding the warning and
87           critical ranges for this performance data (if any).
88
89       rrdlabel
90           Returns a string based on 'label' that is suitable for use as
91           dataset name of an RRD i.e. munges label to be 1-19 characters long
92           with only characters [a-zA-Z0-9_].
93
94           This calls $self->clean_label and then truncates to 19 characters.
95
96           There is no guarantee that multiple N:P:Performance objects will
97           have unique rrdlabels.
98
99       clean_label
100           Returns a "clean" label for use as a dataset name in RRD, ie, it
101           converts characters that are not [a-zA-Z0-9_] to _.
102
103           It also converts "/" to "root" and "/{name}" to "{name}".
104
105       perfoutput
106           Outputs the data in Nagios::Plugin perfdata format i.e.
107           label=value[uom];[warn];[crit];[min];[max].
108

SEE ALSO

110       Nagios::Plugin, Nagios::Plugin::Threshold,
111       http://nagiosplug.sourceforge.net.
112

AUTHOR

114       This code is maintained by the Nagios Plugin Development Team: see
115       http://nagiosplug.sourceforge.net.
116
118       Copyright (C) 2006-2007 Nagios Plugin Development Team
119
120       This library is free software; you can redistribute it and/or modify it
121       under the same terms as Perl itself.
122
123
124
125perl v5.12.1                      2010-04-15    Nagios::Plugin::Performance(3)
Impressum