mirror of
https://github.com/centreon/centreon-plugins.git
synced 2025-07-27 15:44:21 +02:00
+ Add option for scenario telnet
This commit is contained in:
parent
b48c94f29f
commit
745df38cd6
@ -39,6 +39,8 @@ 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' },
|
||||||
|
"hostname:s" => { name => 'hostname' },
|
||||||
|
"port:s" => { name => 'port', default => 23 },
|
||||||
});
|
});
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
@ -94,10 +96,18 @@ sub read_scenario {
|
|||||||
sub execute_scenario {
|
sub execute_scenario {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
my $timing0 = [gettimeofday];
|
||||||
my $session = new Net::Telnet();
|
my $session = new Net::Telnet();
|
||||||
$session->errmode('return');
|
$session->errmode('return');
|
||||||
|
|
||||||
my $timing0 = [gettimeofday];
|
if (defined($self->{option_results}->{hostname}) && $self->{option_results}->{hostname} ne '') {
|
||||||
|
if (!$session->open(Host => $self->{option_results}->{hostname}, Port => $self->{option_results}->{port}, Timeout => 30)) {
|
||||||
|
$self->{output}->output_add(severity => 'critical',
|
||||||
|
short_msg => sprintf("cannot open session: %s", $session->errmsg()));
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
my ($step_ok, $exit1) = (0, 'OK');
|
my ($step_ok, $exit1) = (0, 'OK');
|
||||||
my $step_total = scalar(@{$self->{json_scenario}});
|
my $step_total = scalar(@{$self->{json_scenario}});
|
||||||
foreach my $cmd (@{$self->{json_scenario}}) {
|
foreach my $cmd (@{$self->{json_scenario}}) {
|
||||||
@ -161,12 +171,22 @@ Check telnet scenario execution
|
|||||||
|
|
||||||
=item B<--scenario>
|
=item B<--scenario>
|
||||||
|
|
||||||
Scenario used
|
Scenario used (Required)
|
||||||
|
|
||||||
=item B<--timeout>
|
=item B<--timeout>
|
||||||
|
|
||||||
Set global execution timeout (Default: 50)
|
Set global execution timeout (Default: 50)
|
||||||
|
|
||||||
|
=item B<--hostname>
|
||||||
|
|
||||||
|
Set telnet hostname.
|
||||||
|
Could be used if you want to use the same scenario for X hosts.
|
||||||
|
|
||||||
|
=item B<--port>
|
||||||
|
|
||||||
|
Set telnet port.
|
||||||
|
Could be used if you want to use the same scenario for X hosts.
|
||||||
|
|
||||||
=item B<--warning>
|
=item B<--warning>
|
||||||
|
|
||||||
Threshold warning in seconds (Scenario execution time)
|
Threshold warning in seconds (Scenario execution time)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user