Monitoring::Plugin::Functions(3pm) | User Contributed Perl Documentation | Monitoring::Plugin::Functions(3pm) |
Monitoring::Plugin::Functions - functions to simplify the creation of Nagios plugins
# Constants OK, WARNING, CRITICAL, and UNKNOWN exported by default use Monitoring::Plugin::Functions; # plugin_exit( CODE, $message ) - exit with error code CODE, # and message "PLUGIN CODE - $message" plugin_exit( CRITICAL, $critical_error ) if $critical_error; plugin_exit( WARNING, $warning_error ) if $warning_error; plugin_exit( OK, $result ); # plugin_die( $message, [$CODE] ) - just like plugin_exit(), # but CODE is optional, defaulting to UNKNOWN do_something() or plugin_die("do_something() failed horribly"); do_something_critical() or plugin_die("do_something_critical() failed", CRITICAL); # check_messages - check a set of message arrays, returning a # CODE and/or a result message $code = check_messages(critical => \@crit, warning => \@warn); ($code, $message) = check_messages( critical => \@crit, warning => \@warn, ok => \@ok ); # get_shortname - return the default short name for this plugin # (as used by plugin_exit/die; not exported by default) $shortname = get_shortname();
This module is part of the Monitoring::Plugin family, a set of modules for simplifying the creation of Nagios plugins. This module exports convenience functions for the class methods provided by Monitoring::Plugin. It is intended for those who prefer a simpler functional interface, and who do not need the additional functionality of Monitoring::Plugin.
Nagios status code constants are exported by default:
OK WARNING CRITICAL UNKNOWN DEPENDENT
as are the following functions:
plugin_exit plugin_die check_messages
The following variables and functions are exported only on request:
%ERRORS %STATUS_TEXT get_shortname max_state max_state_alt
The following functions are supported:
# Scalar context $code = check_messages(critical => \@crit, warning => \@warn); # List context ($code, $msg) = check_messages(critical => \@crit, warning => \@warn);
check_messages() accepts the following named arguments:
join( $join, @crit )
as the result message. Optional; default: ' ' (space).
If join_all is supplied, however, it will be used as a string to join the resultant critical, warning, and ok messages together i.e. all messages are joined and returned.
uc basename( $ENV{PLUGIN_NAME} || $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.
The typical usage of max_state is to initialise the state as UNKNOWN and use it on the result of various test. If no test were performed successfully the state will still be UNKNOWN.
This is a true definition of a max state (OK last) and should be used if the internal tests performed can return UNKNOWN.
Monitoring::Plugin; the nagios plugin developer guidelines at https://www.monitoring-plugins.org/doc/guidelines.html.
This code is maintained by the Monitoring Plugin Development Team: see https://monitoring-plugins.org
Copyright (C) 2014 by Monitoring Plugin Team Copyright (C) 2006-2014 by Nagios Plugin Development Team
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
2018-07-26 | perl v5.26.2 |