Age | Commit message (Collapse) | Author | Files | Lines |
|
Create implicit threshold object if either warning or critical is set
|
|
|
|
Implicitly creating a threshold object in getopts rather than check_threshold
|
|
when warning and critical is passed in, so that order of execution between $mp->check_threshold and $mp->add_perfdata doesn't matter
|
|
|
|
Added missing ABSTRACT as reported by CPANTS.
|
|
|
|
|
|
Signed-off-by: Sven Nierlein <sven@nierlein.de>
|
|
Fail with config ->errstr() when undef read
|
|
The Config::Tiny parent class for Monitoring::Plugin::Config does not
necessarily raise an exception in $@/$EVAL_ERROR on a failed call to its
->read() method. Indeed, it does not in most cases, at least in the most
recent Config::Tiny.
If a file does not exist or for whatever other reason cannot actually be
read--such as permissions problems--Monitoring::Plugin ends up reporting
a "Missing config section" to the caller, which is misleading.
This information is available from the ->errstr() method of the base
class, however, and an inspection of the code for the ->read() method in
the parent class suggests the correct approach is to look for a return
of `undef` from the ->read() method, and use the return value of
->errstr() as the reported error for ->_die(). This commit adds such a
check.
To reproduce, given the following plugin `mptest`:
use strict;
use warnings;
use Monitoring::Plugin qw(%ERRORS);
my $mp = Monitoring::Plugin->new(
usage => '',
);
$mp->getopts;
$mp->plugin_exit($ERRORS{OK}, 'Done!');
Running it without options of course works, like so:
$ perl mptest
MPTEST OK - Done!
However, prior to this patch, if we specify --extra-opts with a
nonexistent filename, we get a misleading error:
$ perl mptest --extra-opts=@/nonexistent
Invalid section 'mptest' in config file '/nonexistent'
With this patch included, the error is more accurate and helpful:
$ perl mptest --extra-opts=@/nonexistent
Failed to open file '/nonexistent' for reading: No such file or directory
|
|
Remove "experimental" tag on "Message Methods"
|
|
From a maintainer, Sven Nierlein:
> I'd say we can remove the "experimental" tag there. It had been there
> for years now and i see no reason why we would change them.
Partly resolves #14.
|
|
Clean up argument adding code a little bit
|
|
Context with the lhs of the == operator forces this into scalar context
anyway, making this call redundant.
|
|
Since Params::Validate::validate() doesn't seem to actually mess with
this specification, may as well pass a reference rather than bother
copying the whole thing.
|
|
Operator precedence allows leaving these out.
|
|
Define the expected order of parameters by key in an array, and then
apply hash slices to validate and assign the arguments including their
required flags in one swoop, again hinging on the parameter definitions
established in c1046ba.
|
|
Use the parameter label definitions from commit c1046ba to simplify the
block of code that checks whether the first argument passed to arg() is
one of the known param keys, rather than using a regular expression with
alternating expression.
This is more compact, may be marginally faster, and will make adding new
parameters to this method more straightforward in future, avoiding the
situation corrected in commit 4aa2aee.
|
|
This shift and its comment makes what the values of the hashref passed
to the validate() methods mean clearer, and also allows the use of the
keys as a means of determining whether arg() was passed its definition
in the array or hash format in a separate commit.
|
|
If the `label` key is given as a named argument for argument
specification, if it turns out to be the first element returned in the
argument list subject to hash randomization, then this test for named
arguments fails due to the omission of the label from this alternating
group in the pattern.
When this happens, the code for an unnamed list of items was run
instead, leading to a very confusing area happening randomly:
8 parameters were passed to Monitoring::Plugin::Getopt::arg but 2 - 5 were expected
at PERL/lib/perl5/Monitoring/Plugin/Getopt.pm line 397.
Monitoring::Plugin::Getopt::arg(undef, "label", "HOSTNAME", "required", 1, "help", "Hostname of device to check", "spec", ...) called at PERL/lib/perl5/Monitoring/Plugin.pm line 161
Monitoring::Plugin::add_arg(Monitoring::Plugin=HASH(0x1f90fd8), "label", "HOSTNAME", "required", 1, "help", "Hostname of device to check", "spec", ...) called at libexec/check_example line 144
If you specified all five keys for your argument, then this happens
(roughly) one-fifth of the time.
|
|
Allow negation of command line arguments using '--no'-prefix
|
|
Getopt::Long supports negatable boolean options by appending an '!' to the
option specification, so this allows to use this functionality with
Monitoring::Plugin::Getopt as well.
|
|
|
|
Fix plugin-name processing in ALRM handler.
|
|
Signed-off-by: Sven Nierlein <sven@nierlein.de>
|
|
Allow hypen or underscore in plugin name.
|
|
Wrong case in ALRM regex.
|
|
\R was introduced in 5.10 too
|
|
|
|
|
|
|
|
|
|
|
|
Fixed regex in plugin_exit() that handles hyphen for LONGOUTPUT.
|
|
Added tests.
|
|
Support LONGTEXT output
|
|
Pass `TEXT OUTPUT\nLONGTEXT1\nLONGTEXT2` to as the second parameter to `plugin_exit()` to add LONGOUTPUT lines. If the parameter is has a leading newline (i.e. `\nLONGTEXT1\nLONGTEXT2`), skip emitting the hyphen (dash).
|
|
|
|
output empty values as "U"
|
|
output empty performance data value as value "U" to "indicate that the actual value couldn't be determined" (defined in https://nagios-plugins.org/doc/guidelines.html#AEN200) and do valid output
|
|
Signed-off-by: Sven Nierlein <sven@nierlein.de>
Original-Author: Christoph Biedl <debian.axhn@manchmal.in-ulm.de>
|
|
Signed-off-by: Sven Nierlein <sven@nierlein.de>
|
|
Signed-off-by: Sven Nierlein <sven@nierlein.de>
|
|
This reverts commit 5b2ab7f928b17b2013bdc914e36f7c2314f7b922.
|
|
fixes https://rt.cpan.org/Ticket/Display.html?id=103190
Signed-off-by: Sven Nierlein <sven@nierlein.de>
|
|
Signed-off-by: Sven Nierlein <sven@nierlein.de>
|
|
GetOpt::Long optional arguments using a colon instead of an equal sign
|
|
Signed-off-by: Sven Nierlein <sven@nierlein.de>
|
|
Signed-off-by: Sven Nierlein <sven@nierlein.de>
|