From 79b36b4d71afeb016a3b4764b6b484754323b011 Mon Sep 17 00:00:00 2001 From: Gavin Carr Date: Sat, 11 Nov 2006 05:18:46 +0000 Subject: Add get_shortname to NP::Functions export_ok list; update perldocs. git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/Nagios-Plugin/trunk@1537 f882894a-f735-0410-b71e-b25c423dba1c --- lib/Nagios/Plugin/Functions.pm | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'lib') 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); require Exporter; our @ISA = qw(Exporter); our @EXPORT = (@STATUS_CODES, qw(nagios_exit nagios_die check_messages)); -our @EXPORT_OK = qw(%ERRORS %STATUS_TEXT @STATUS_CODES); +our @EXPORT_OK = qw(%ERRORS %STATUS_TEXT @STATUS_CODES get_shortname); our %EXPORT_TAGS = ( all => [ @EXPORT, @EXPORT_OK ], codes => [ @STATUS_CODES ], @@ -224,6 +224,10 @@ Nagios plugins. critical => \@crit, warning => \@warn, ok => \@ok ); + # get_shortname - return the default short name for this plugin + # (as used by nagios_exit/die; not exported by default) + $shortname = get_shortname(); + =head1 DESCRIPTION @@ -250,10 +254,11 @@ as are the following functions: nagios_die check_messages -The following variables are exported only on request: +The following variables and functions are exported only on request: %ERRORS %STATUS_TEXT + get_shortname =head2 FUNCTIONS @@ -330,6 +335,18 @@ all messages are joined and returned. =back +=item get_shortname + +Return the default shortname used for this plugin i.e. the first +token reported by nagios_exit/nagios_die. The default is basically + + uc basename( $ENV{NAGIOS_PLUGIN} || $0 ) + +with any leading 'CHECK_' and trailing file suffixes removed. + +get_shortname is not exported by default, so must be explicitly +imported. + =back -- cgit v1.2.3-74-g34f1