Skip Menu |
 

This queue is for tickets about the Monitoring-Plugin CPAN distribution.

Report information
The Basics
Id: 123328
Status: resolved
Priority: 0/
Queue: Monitoring-Plugin

People
Owner: Nobody in particular
Requestors: debian.axhn [...] manchmal.in-ulm.de
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



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;
Download signature.asc
application/pgp-signature 819b

Message body not shown because it is not plain text.

Subject: Re: [rt.cpan.org #123328] Cannot override default 'timeout' value
Date: Sat, 9 Dec 2017 15:55:02 -0500
To: bug-Monitoring-Plugin [...] rt.cpan.org
From: Thomas Guyot-Sionnest <dermoth [...] aei.ca>
Subject: Re: [rt.cpan.org #123328] Cannot override default 'timeout' value
To: bug-Monitoring-Plugin [...] rt.cpan.org
From: Thomas Guyot-Sionnest <dermoth [...] aei.ca>
Download (untitled) / with headers
text/plain 2.2k
Hi, I think you should just remove the "$mp->add_arg('spec' => 'timeout|t=i'...)" - the issue is that you're overriding an internal N::P parameter so --timeout no longer set N::P's timeout but only your variable. You can get --timeout's value from $mp->opts->timeout, and you can override the default timeout value by passing "timeout => N" to N::P->new() If for some reason you really need to override --timeout (ex custom format) I think you could pass back the parsed timeout to $mp->opts->timeout, but I'm not absolutely sure this is supported and it doesn't sound like something you'd need. Regards, -- Thomas On 19/10/17 01:35 PM, Christoph Biedl via RT wrote: Show quoted text
> Thu Oct 19 13:35:55 2017: Request 123328 was acted upon. > Transaction: Ticket created by debian.axhn@manchmal.in-ulm.de > Queue: Monitoring-Plugin > Subject: Cannot override default 'timeout' value > Broken in: (no value) > Severity: (no value) > Owner: Nobody > Requestors: debian.axhn@manchmal.in-ulm.de > Status: new > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=123328 > > > > 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; >
Download signature.asc
application/pgp-signature 195b

Message body not shown because it is not plain text.



This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.