diff options
Diffstat (limited to 'lib/Nagios/Plugin/Functions.pm')
-rw-r--r-- | lib/Nagios/Plugin/Functions.pm | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/lib/Nagios/Plugin/Functions.pm b/lib/Nagios/Plugin/Functions.pm index 41ec27a..9983456 100644 --- a/lib/Nagios/Plugin/Functions.pm +++ b/lib/Nagios/Plugin/Functions.pm | |||
@@ -18,7 +18,7 @@ our @STATUS_CODES = qw(OK WARNING CRITICAL UNKNOWN DEPENDENT); | |||
18 | require Exporter; | 18 | require Exporter; |
19 | our @ISA = qw(Exporter); | 19 | our @ISA = qw(Exporter); |
20 | our @EXPORT = (@STATUS_CODES, qw(nagios_exit nagios_die check_messages)); | 20 | our @EXPORT = (@STATUS_CODES, qw(nagios_exit nagios_die check_messages)); |
21 | our @EXPORT_OK = qw(%ERRORS %STATUS_TEXT @STATUS_CODES); | 21 | our @EXPORT_OK = qw(%ERRORS %STATUS_TEXT @STATUS_CODES get_shortname); |
22 | our %EXPORT_TAGS = ( | 22 | our %EXPORT_TAGS = ( |
23 | all => [ @EXPORT, @EXPORT_OK ], | 23 | all => [ @EXPORT, @EXPORT_OK ], |
24 | codes => [ @STATUS_CODES ], | 24 | codes => [ @STATUS_CODES ], |
@@ -224,6 +224,10 @@ Nagios plugins. | |||
224 | critical => \@crit, warning => \@warn, | 224 | critical => \@crit, warning => \@warn, |
225 | ok => \@ok ); | 225 | ok => \@ok ); |
226 | 226 | ||
227 | # get_shortname - return the default short name for this plugin | ||
228 | # (as used by nagios_exit/die; not exported by default) | ||
229 | $shortname = get_shortname(); | ||
230 | |||
227 | 231 | ||
228 | =head1 DESCRIPTION | 232 | =head1 DESCRIPTION |
229 | 233 | ||
@@ -250,10 +254,11 @@ as are the following functions: | |||
250 | nagios_die | 254 | nagios_die |
251 | check_messages | 255 | check_messages |
252 | 256 | ||
253 | The following variables are exported only on request: | 257 | The following variables and functions are exported only on request: |
254 | 258 | ||
255 | %ERRORS | 259 | %ERRORS |
256 | %STATUS_TEXT | 260 | %STATUS_TEXT |
261 | get_shortname | ||
257 | 262 | ||
258 | 263 | ||
259 | =head2 FUNCTIONS | 264 | =head2 FUNCTIONS |
@@ -330,6 +335,18 @@ all messages are joined and returned. | |||
330 | 335 | ||
331 | =back | 336 | =back |
332 | 337 | ||
338 | =item get_shortname | ||
339 | |||
340 | Return the default shortname used for this plugin i.e. the first | ||
341 | token reported by nagios_exit/nagios_die. The default is basically | ||
342 | |||
343 | uc basename( $ENV{NAGIOS_PLUGIN} || $0 ) | ||
344 | |||
345 | with any leading 'CHECK_' and trailing file suffixes removed. | ||
346 | |||
347 | get_shortname is not exported by default, so must be explicitly | ||
348 | imported. | ||
349 | |||
333 | =back | 350 | =back |
334 | 351 | ||
335 | 352 | ||