From 28732f1d7f6944738e921c1c87d625b01a88daa3 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Thu, 16 Jun 2011 14:55:30 +0200 Subject: Add timeout switch (-t / --timeout) --- bin/ekgping | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/bin/ekgping b/bin/ekgping index e7c5764..4ca1765 100755 --- a/bin/ekgping +++ b/bin/ekgping @@ -25,11 +25,13 @@ my $column_max = Term::Size::chars; my $beep_file; my $quiet = 0; +my $timeout = 3; GetOptions( 'f|beep-file=s' => \$beep_file, 'q|quiet' => \$quiet, + 't|timeout=f' => \$timeout, 'V|version' => sub { say "ekgping version ${VERSION}"; exit 0 }, ) or usage(); @@ -126,7 +128,7 @@ while ( usleep(100_000) ) { else { $beep = 0; $dead_count++; - if ( $dead_count > 30 ) { + if ( $dead_count > ($timeout * 10) ) { $beep = 1; } @@ -155,7 +157,7 @@ B - Electrocardiograph-like visual and audible ping =head1 SYNOPSIS -B [B<-q>] [B<-f> I] I [B<--> I] +B [B<-q>] [B<-t> I] [B<-f> I] I [B<--> I] =head1 VERSION @@ -191,6 +193,14 @@ Play I instead of the default beeps. May be any sound / music file Do not play beeps, visual output only +=item B<-t>, B<--timeout> I + +Set ping timeout. If no pong was received in this time, B will emit a +continuous beep. Accepts a floating point value, defaults to B<3.0>. + +Note that setting this lower than the ping interval (which defaults to 1 +second) does not make much sense, unless you want longer beeps per pong. + =item B<-V>, B<--version> Show version information and exit -- cgit v1.2.3