parent
10d2d1cb1f
commit
fb78123c07
|
@ -41,11 +41,12 @@ use base qw(centreon::plugins::mode);
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use Time::HiRes qw(gettimeofday tv_interval);
|
use Time::HiRes qw(gettimeofday tv_interval);
|
||||||
use centreon::plugins::httplib;
|
|
||||||
use XML::XPath;
|
use XML::XPath;
|
||||||
use XML::XPath::XMLParser;
|
use XML::XPath::XMLParser;
|
||||||
use WWW::Selenium;
|
use WWW::Selenium;
|
||||||
|
|
||||||
|
my %handlers = (ALRM => {} );
|
||||||
|
|
||||||
sub new {
|
sub new {
|
||||||
my ($class, %options) = @_;
|
my ($class, %options) = @_;
|
||||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||||
|
@ -61,10 +62,34 @@ sub new {
|
||||||
"scenario:s" => { name => 'scenario' },
|
"scenario:s" => { name => 'scenario' },
|
||||||
"warning:s" => { name => 'warning' },
|
"warning:s" => { name => 'warning' },
|
||||||
"critical:s" => { name => 'critical' },
|
"critical:s" => { name => 'critical' },
|
||||||
|
"timeout:s" => { name => 'timeout', default => 50 },
|
||||||
});
|
});
|
||||||
|
$self->set_signal_handlers;
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub set_signal_handlers {
|
||||||
|
my $self = shift;
|
||||||
|
|
||||||
|
$SIG{ALRM} = \&class_handle_ALRM;
|
||||||
|
$handlers{ALRM}->{$self} = sub { $self->handle_ALRM() };
|
||||||
|
}
|
||||||
|
|
||||||
|
sub class_handle_ALRM {
|
||||||
|
foreach (keys %{$handlers{ALRM}}) {
|
||||||
|
&{$handlers{ALRM}->{$_}}();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sub handle_ALRM {
|
||||||
|
my $self = shift;
|
||||||
|
|
||||||
|
$self->{output}->output_add(severity => 'UNKNOWN',
|
||||||
|
short_msg => sprintf("Cannot finished scenario execution (timeout received)"));
|
||||||
|
$self->{output}->display();
|
||||||
|
$self->{output}->exit();
|
||||||
|
}
|
||||||
|
|
||||||
sub check_options {
|
sub check_options {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
$self->SUPER::init(%options);
|
$self->SUPER::init(%options);
|
||||||
|
@ -77,6 +102,10 @@ sub check_options {
|
||||||
$self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'.");
|
$self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'.");
|
||||||
$self->{output}->option_exit();
|
$self->{output}->option_exit();
|
||||||
}
|
}
|
||||||
|
if (defined($self->{option_results}->{timeout}) && $self->{option_results}->{timeout} =~ /^\d+$/ &&
|
||||||
|
$self->{option_results}->{timeout} > 0) {
|
||||||
|
alarm($self->{option_results}->{timeout});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sub run {
|
sub run {
|
||||||
|
@ -191,6 +220,10 @@ Directory where scenarii are stored
|
||||||
|
|
||||||
Scenario used by Selenium server (without extension)
|
Scenario used by Selenium server (without extension)
|
||||||
|
|
||||||
|
=item B<--timeout>
|
||||||
|
|
||||||
|
Set global execution timeout (Default: 50)
|
||||||
|
|
||||||
=item B<--warning>
|
=item B<--warning>
|
||||||
|
|
||||||
Threshold warning in seconds (Scenario execution time)
|
Threshold warning in seconds (Scenario execution time)
|
||||||
|
|
Loading…
Reference in New Issue