mirror of
https://github.com/centreon/centreon-plugins.git
synced 2025-07-27 07:34:35 +02:00
(plugin) apps::monitoring::iplabel::newtest::restapi - mode scenarios… (#4545)
* (plugin) apps::monitoring::iplabel::newtest::restapi - mode scenarios add --timeframe option * applications-monitoring-iplabel-newtest-restapi - mode scenarios add --timeframe option * review * Update src/apps/monitoring/iplabel/newtest/restapi/mode/scenarios.pm --------- Co-authored-by: omercier <32134301+omercier@users.noreply.github.com>
This commit is contained in:
parent
c2701eceb1
commit
31fe71833e
@ -25,7 +25,6 @@ use base qw(centreon::plugins::templates::counter);
|
|||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use Digest::MD5 qw(md5_hex);
|
use Digest::MD5 qw(md5_hex);
|
||||||
use POSIX;
|
|
||||||
use DateTime;
|
use DateTime;
|
||||||
|
|
||||||
sub robot_long_output {
|
sub robot_long_output {
|
||||||
@ -115,7 +114,8 @@ sub new {
|
|||||||
|
|
||||||
$options{options}->add_options(arguments => {
|
$options{options}->add_options(arguments => {
|
||||||
'filter-robot-name:s' => { name => 'filter_robot_name' },
|
'filter-robot-name:s' => { name => 'filter_robot_name' },
|
||||||
'filter-scenario-name:s' => { name => 'filter_scenario_name' }
|
'filter-scenario-name:s' => { name => 'filter_scenario_name' },
|
||||||
|
'timeframe:s' => { name => 'timeframe' }
|
||||||
});
|
});
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
@ -129,11 +129,17 @@ sub manage_selection {
|
|||||||
(defined($self->{option_results}->{filter_robot_name}) ? md5_hex($self->{option_results}->{filter_robot_name}) : md5_hex('all')) . '_' .
|
(defined($self->{option_results}->{filter_robot_name}) ? md5_hex($self->{option_results}->{filter_robot_name}) : md5_hex('all')) . '_' .
|
||||||
(defined($self->{option_results}->{filter_scenario_name}) ? md5_hex($self->{option_results}->{filter_scenario_name}) : md5_hex('all'));
|
(defined($self->{option_results}->{filter_scenario_name}) ? md5_hex($self->{option_results}->{filter_scenario_name}) : md5_hex('all'));
|
||||||
my $last_timestamp = $self->read_statefile_key(key => 'last_timestamp');
|
my $last_timestamp = $self->read_statefile_key(key => 'last_timestamp');
|
||||||
my $timespan = 5;
|
|
||||||
if (defined($last_timestamp)) {
|
my $timespan = 300;
|
||||||
$timespan = POSIX::ceil((time() - $last_timestamp) / 60);
|
if (defined($self->{option_results}->{timeframe}) && $self->{option_results}->{timeframe} =~ /^(\d+)$/) {
|
||||||
|
$timespan = $1;
|
||||||
|
$last_timestamp = time() - $timespan;
|
||||||
} else {
|
} else {
|
||||||
$last_timestamp = time() - (60 * 5);
|
if (defined($last_timestamp)) {
|
||||||
|
$timespan = time() - $last_timestamp;
|
||||||
|
} else {
|
||||||
|
$last_timestamp = time() - $timespan;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
my $instances = $options{custom}->request_api(endpoint => '/api/instances');
|
my $instances = $options{custom}->request_api(endpoint => '/api/instances');
|
||||||
@ -299,6 +305,11 @@ Filter robots (can be a regexp).
|
|||||||
|
|
||||||
Filter scenarios (can be a regexp).
|
Filter scenarios (can be a regexp).
|
||||||
|
|
||||||
|
=item B<--timeframe>
|
||||||
|
|
||||||
|
Define timeframe (duration to go back in time) in seconds (default value: 300 ).
|
||||||
|
The first range is calculated with this value then it's calculated from the last execution (stored in the cache file).
|
||||||
|
|
||||||
=item B<--warning-*> B<--critical-*>
|
=item B<--warning-*> B<--critical-*>
|
||||||
|
|
||||||
Thresholds.
|
Thresholds.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user