summaryrefslogtreecommitdiffstats
AgeCommit message (Collapse)AuthorFilesLines
2018-07-25release 0.40v0.40Sven Nierlein3-2/+3
2018-07-25update changelogSven Nierlein1-1/+7
Signed-off-by: Sven Nierlein <sven@nierlein.de>
2018-05-28Merge pull request #19 from tejr/config-read-errorSven Nierlein1-1/+3
Fail with config ->errstr() when undef read
2018-05-24Fail with config ->errstr() when undef readrefs/pull/19/headTom Ryder1-1/+3
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
2018-03-07Merge pull request #18 from tejr/masterSven Nierlein1-4/+1
Remove "experimental" tag on "Message Methods"
2018-03-04Remove "experimental" tag on "Message Methods"refs/pull/18/headTom Ryder1-4/+1
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.
2017-12-22Merge pull request #17 from tejr/arg-add-cleanupSven Nierlein1-16/+13
Clean up argument adding code a little bit
2017-12-16Remove "scalar" call entirelyrefs/pull/17/headTom Ryder1-1/+1
Context with the lhs of the == operator forces this into scalar context anyway, making this call redundant.
2017-12-16Pass params validation by ref not copyTom Ryder1-1/+1
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.
2017-12-16Remove unneeded params around "scalar" callTom Ryder1-1/+1
Operator precedence allows leaving these out.
2017-12-16Refactor positional arg parsing for Getopt::arg()Tom Ryder1-8/+2
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.
2017-12-16Change arg() param type detect to key exists checkTom Ryder1-1/+1
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.
2017-12-16Move Getopt param/reqd defs into dedicated hashTom Ryder1-7/+10
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.
2017-11-15Add missing `label` key to named Getopts argsTom Ryder1-1/+1
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.
2016-11-20Merge pull request #13 from mstock/feature/argument-negationSven Nierlein2-5/+25
Allow negation of command line arguments using '--no'-prefix
2016-11-19Allow negation of command line arguments using '--no'-prefixrefs/pull/13/headManfred Stock2-5/+25
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.
2016-06-22use case insensitive regexSven Nierlein1-1/+1
2016-06-22Merge pull request #12 from pdugas/masterSven Nierlein1-1/+1
Fix plugin-name processing in ALRM handler.
2016-06-03fix typo in perl pod (fixes rt #114873)Sven Nierlein1-4/+4
Signed-off-by: Sven Nierlein <sven@nierlein.de>
2016-04-20Update Getopt.pmrefs/pull/12/headPaul Dugas1-1/+1
Allow hypen or underscore in plugin name.
2016-04-20Update Getopt.pmPaul Dugas1-1/+1
Wrong case in ALRM regex.
2016-04-02make regular expression 5.8 compatibleSven Nierlein1-1/+1
\R was introduced in 5.10 too
2016-04-02make regular expression 5.8 compatibleSven Nierlein1-1/+1
2016-04-02add notifications for travis buildsSven Nierlein1-0/+12
2016-04-02update changelogSven Nierlein1-0/+1
2016-04-02update gitignoreSven Nierlein2-46/+19
2016-04-02add travis fileSven Nierlein1-0/+10
2016-04-02Merge pull request #11 from pdugas/masterSven Nierlein2-2/+15
Fixed regex in plugin_exit() that handles hyphen for LONGOUTPUT.
2016-04-02Fixed regex in plugin_exit() that handles hyphen for LONGOUTPUT.refs/pull/11/headPaul Dugas2-2/+15
Added tests.
2016-03-31Merge pull request #10 from pdugas/masterSven Nierlein1-1/+4
Support LONGTEXT output
2016-03-31Support LONGTEXT outputrefs/pull/10/headPaul Dugas1-1/+4
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).
2015-12-03update changelogSven Nierlein1-0/+3
2015-12-03Merge pull request #5 from daku3649/patch-1Sven Nierlein1-1/+8
output empty values as "U"
2015-12-03output empty values as "U"refs/pull/5/headdaku36491-1/+8
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
2015-10-02add description for getter / setter methods (#107370)Sven Nierlein1-0/+26
Signed-off-by: Sven Nierlein <sven@nierlein.de> Original-Author: Christoph Biedl <debian.axhn@manchmal.in-ulm.de>
2015-04-11released 0.39v0.39Sven Nierlein4-7/+5
Signed-off-by: Sven Nierlein <sven@nierlein.de>
2015-04-11fix "Redundant argument in sprintf" in perl 5.21 (RT #103214)Sven Nierlein2-7/+12
Signed-off-by: Sven Nierlein <sven@nierlein.de>
2015-03-30Revert "fix warning in function tests"Sven Nierlein1-1/+1
This reverts commit 5b2ab7f928b17b2013bdc914e36f7c2314f7b922.
2015-03-30fix warning in function testsSven Nierlein1-1/+1
fixes https://rt.cpan.org/Ticket/Display.html?id=103190 Signed-off-by: Sven Nierlein <sven@nierlein.de>
2014-12-28update changelogSven Nierlein1-0/+3
Signed-off-by: Sven Nierlein <sven@nierlein.de>
2014-12-28Merge pull request #2 from evgeni/getopt_colon_specSven Nierlein2-5/+43
GetOpt::Long optional arguments using a colon instead of an equal sign
2014-12-28release 0.38v0.38Sven Nierlein4-4/+4
Signed-off-by: Sven Nierlein <sven@nierlein.de>
2014-12-28update changelogSven Nierlein1-0/+3
Signed-off-by: Sven Nierlein <sven@nierlein.de>
2014-12-28fix test in windowsSven Nierlein1-1/+4
on windows backslashes are expected instead of forward slashes. fixes https://rt.cpan.org/Ticket/Display.html?id=100708 Signed-off-by: Sven Nierlein <sven@nierlein.de>
2014-12-08fix link to documentationSven Nierlein1-1/+1
Signed-off-by: Sven Nierlein <sven@nierlein.de>
2014-12-08correct getopt helpSven Nierlein1-2/+2
its not true that the options are available via the main Monitoring::Plugin object. Instead you have to fetch them from the opts object. Signed-off-by: Sven Nierlein <sven@nierlein.de>
2014-10-03format optional arguments in square braketsrefs/pull/2/headEvgeni Golov2-7/+17
2014-10-03GetOpt::Long optional arguments using a colon instead of an equal signEvgeni Golov2-3/+31
Instead of writing `foo|f=s` you can also write `foo|f:s` for a GetOpt::Long option spec [1], thus making the argument optional. The current implementation of `_spec_to_help` will wrongly render this as two long options: --dirport, --d:9030 directory port instead of a short and a long one: -d, --dirport=INTEGER directory port This commit fixes the the parsing of the spec, detection of the type and adds tests for a few common cases this could be used in. [1] http://perldoc.perl.org/Getopt/Long.html#Summary-of-Option-Specifications
2014-01-20keep the old name in copyright for more transparencyv0.37Sven Nierlein14-69/+98
Signed-off-by: Sven Nierlein <sven@nierlein.de>
2014-01-19renamed module into Monitoring::PluginSven Nierlein38-1062/+1104
since the complete monitoring team has been renamed, we also rename this module. Signed-off-by: Sven Nierlein <sven@nierlein.de>