diff options
author | Sven Nierlein <Sven.Nierlein@consol.de> | 2014-06-12 11:56:48 (GMT) |
---|---|---|
committer | Sven Nierlein <Sven.Nierlein@consol.de> | 2014-06-12 11:56:48 (GMT) |
commit | c5a6c5136a2a7e629907b04a63dff059603bdb09 (patch) | |
tree | e6c9d47b240904752f2bf056bdc9dd92f7a83562 /NPTest.pm | |
parent | 3529d7465d31234ec634939ed1a6bdc915b73ccd (diff) | |
download | monitoring-plugins-c5a6c5136a2a7e629907b04a63dff059603bdb09.tar.gz |
tests: testCmd has own timeout which overwrites local one
so add configurable/optional timeout to testCmd.
Signed-off-by: Sven Nierlein <Sven.Nierlein@consol.de>
Diffstat (limited to 'NPTest.pm')
-rw-r--r-- | NPTest.pm | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -627,12 +627,13 @@ sub only_output { | |||
627 | } | 627 | } |
628 | 628 | ||
629 | sub testCmd { | 629 | sub testCmd { |
630 | my $class = shift; | 630 | my $class = shift; |
631 | my $command = shift or die "No command passed to testCmd"; | 631 | my $command = shift or die "No command passed to testCmd"; |
632 | my $timeout = shift || 120; | ||
632 | my $object = $class->new; | 633 | my $object = $class->new; |
633 | 634 | ||
634 | local $SIG{'ALRM'} = sub { die("timeout in command: $command"); }; | 635 | local $SIG{'ALRM'} = sub { die("timeout in command: $command"); }; |
635 | alarm(120); # no test should take longer than 120 seconds | 636 | alarm($timeout); # no test should take longer than 120 seconds |
636 | 637 | ||
637 | my $output = `$command`; | 638 | my $output = `$command`; |
638 | $object->return_code($? >> 8); | 639 | $object->return_code($? >> 8); |