Subject: | Cannot override default 'timeout' value |
Date: | Thu, 19 Oct 2017 19:35:40 +0200 |
To: | bug-Monitoring-Plugin [...] rt.cpan.org |
From: | Christoph Biedl <debian.axhn [...] manchmal.in-ulm.de> |
Hello,
a plugin I created using Monitoring::Plugin needs a bit more time than
usual. So I provided an option with a greater default value. Big
surprise: It's not possible to change the timeout value, it's always the
internal default of 15 (seconds).
Can you please check? At least this is fairly confusing and took me a
while to figure. The magic is in GetOpt:213, perhaps apply the default
values *after*wards in case the plugin did not provide one?
A little reproducer below.
Christoph
-----------------------------------------------------------
#!/usr/bin/perl
use 5.010;
use strict;
use warnings;
use Test::More;
use Monitoring::Plugin;
my $mp = Monitoring::Plugin->new (
'usage' => '%s -H <host> -C <config_file> [-w <warning time>] [-c <critical time>] ...',
'license' => 'License: GPL-2.0',
'version' => 42,
);
$mp->add_arg (
'spec' => 'timeout|t=i',
'help' => 'Time threshold for timeout (default: 60s)',
'default' => 60,
);
$mp->getopts;
my $opts = $mp->opts;
my $ttime = $opts->{'timeout'};
is ($ttime, 60, 'timeout value');
done_testing;
Message body not shown because it is not plain text.