mirror of
https://github.com/centreon/centreon-plugins.git
synced 2025-04-08 17:06:05 +02:00
fix(iplabel): don't show perfdata when the last execution don't have perfdata
Refs:CTOR-1394
This commit is contained in:
parent
8486e3592a
commit
1b7b8d7468
@ -43,7 +43,7 @@ sub prefix_scenario_output {
|
||||
sub prefix_steps_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return sprintf(" Step: %s, last exec: %s, ", $options{instance_value}->{display}, $options{instance_value}->{last_exec});
|
||||
return sprintf("Step: %s, last exec: %s, ", $options{instance_value}->{display}, $options{instance_value}->{last_exec});
|
||||
}
|
||||
|
||||
sub set_counters {
|
||||
@ -182,7 +182,7 @@ sub manage_selection {
|
||||
}
|
||||
};
|
||||
if (!defined $scenario_detail->{results} or scalar(@{$scenario_detail->{results}}) <= 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Scenario '" . $scenario->{scenarioName} . "' Don't have any performance data, please try to add a bigger timeframe");
|
||||
$self->{output}->add_option_msg(short_msg => "No execution, please try again with a bigger timeframe");
|
||||
next;
|
||||
}
|
||||
foreach my $kpi (@{$scenario_detail->{kpis}}) {
|
||||
@ -194,8 +194,17 @@ sub manage_selection {
|
||||
$self->{scenarios}->{ $scenario->{scenarioName} }->{steps_index}->{$steps->{index} - 1} = $steps->{name};
|
||||
}
|
||||
}
|
||||
|
||||
# api is expected to sort the output to get the most recent data at the end of the array.
|
||||
# we store the last execution date, and check it for every data point sent back by the api.
|
||||
# If a step fail, no data is sent by the api for this step, but the older execution are present.
|
||||
# this allow to get perfdata for the last execution with a successfull first step.
|
||||
# if the first step fail, the script will take older data.
|
||||
my $last_execution = @{$scenario_detail->{results}}[-1]->{planningTime};
|
||||
foreach my $step_metrics (@{$scenario_detail->{results}}) {
|
||||
if ($step_metrics->{planningTime} ne $last_execution){
|
||||
$self->{output}->add_option_msg(long_msg => "Execution $step_metrics->{planningTime} of step $step_metrics->{stepId} is older than $last_execution, not taking it into account.", debug => 1);
|
||||
next;
|
||||
}
|
||||
my $exec_time = str2time($step_metrics->{planningTime}, 'GMT');
|
||||
$self->{scenarios}->{ $scenario->{scenarioName} }->{steps}->{ $self->{scenarios}->{ $scenario->{scenarioName} }->{steps_index}->{ $step_metrics->{stepId} } }->{ $step_metrics->{metric} } = $step_metrics->{value};
|
||||
$self->{scenarios}->{ $scenario->{scenarioName} }->{steps}->{ $self->{scenarios}->{ $scenario->{scenarioName} }->{steps_index}->{ $step_metrics->{stepId} } }->{last_exec} = POSIX::strftime('%d-%m-%Y %H:%M:%S %Z', localtime($exec_time));
|
||||
|
File diff suppressed because one or more lines are too long
@ -33,10 +33,20 @@ scenario ${tc}
|
||||
Examples: tc extra_options expected_result --
|
||||
... 1 --filter-name='Centreon Demo Navigation|Centreon Demo ping NA' --output-ignore-perfdata CRITICAL: Scenario 'Centreon Demo Navigation': status: Failure (2) WARNING: Scenario 'Centreon Demo ping NA': status: Degraded (8)
|
||||
... 2 --filter-name='AKILA - Business App' OK: Scenario 'AKILA - Business App': status: Success (1), availability: 100%, time total all steps: 4280ms - All steps are ok | 'AKILA - Business App#scenario.availability.percentage'=100%;;;0;100 'AKILA - Business App#scenario.time.allsteps.total.milliseconds'=4280ms;;;0; 'AKILA - Business App~Dashboard 2#scenario.step.time.milliseconds'=898ms;;;0; 'AKILA - Business App~Dashboard 3#scenario.step.time.milliseconds'=848ms;;;0; 'AKILA - Business App~Run Chrome#scenario.step.time.milliseconds'=2534ms;;;0;
|
||||
... 3 --filter-name='wrong currentstatus.*' WARNING: Scenario 'wrong currentstatus, no perfdata': status: Unknown (14) - Scenario 'wrong currentstatus, no perfdata' Don't have any performance data, please try to add a bigger timeframe
|
||||
... 3 --filter-name='wrong currentstatus.*' UNKNOWN: Scenario 'wrong currentstatus, no perfdata': status: Unknown (14) - No execution, please try again with a bigger timeframe
|
||||
... 4 --filter-name='not a scenario name' UNKNOWN: No scenario found
|
||||
... 5 --filter-id='09fe2561.*' --warning-time-total-allsteps='30' --output-ignore-perfdata WARNING: Scenario 'AKILA - (Web) ': time total all steps: 5822ms
|
||||
... 5 --filter-id='127a149b.*' --warning-time-total='30' --output-ignore-perfdata WARNING: Scenario 'AKILA - (Browser Page Load)': Step: Default, last exec: 30-12-2024 10:30:00 UTC, time total: 1097 ms
|
||||
... 6 --filter-status='2' --output-ignore-perfdata CRITICAL: Scenario 'Centreon Demo Navigation': status: Failure (2)
|
||||
... 7 --filter-status='2' --filter-siteid='site' --filter-workspaceid='workspace' --output-ignore-perfdata CRITICAL: Scenario 'Centreon Demo Navigation': status: Failure (2)
|
||||
... 8 --filter-type='not a scenario type' UNKNOWN: No scenario found
|
||||
... 9 --api-password='Wrongpassword' --api-username='wrongUsername' UNKNOWN: Authentication endpoint returns error code 'Wrong email or password' (add --debug option for detailed message)
|
||||
# This scenario failed the second step. we show only the first step perfdata, and not the perfdata of the other step for another timestamp.
|
||||
... 10 --filter-name='AKILA - .Web.' CRITICAL: Scenario 'AKILA - (Web)': status: Failure (2) | 'AKILA - (Web)#scenario.availability.percentage'=45.76%;;;0;100 'AKILA - (Web)#scenario.time.allsteps.total.milliseconds'=4733ms;;;0; 'AKILA - (Web)~Home#scenario.step.time.milliseconds'=2851ms;;;0;
|
||||
# without any filter-name of filter-id, every scenario are taken into account of this type.
|
||||
... 11 --filter-type='WEB' --output-ignore-perfdata CRITICAL: Scenario 'AKILA - (Web)': status: Failure (2) - Scenario 'Centreon Demo Navigation': status: Failure (2)
|
||||
# Check the unknown default parameter. These scenario are not real and go to the same scenarioId, which is not possible in real life.
|
||||
... 12 --filter-name='unknown Status 0' --output-ignore-perfdata UNKNOWN: Scenario 'unknown Status 0': status: Unknown (0)
|
||||
... 13 --filter-name='unknown Status 3' --output-ignore-perfdata UNKNOWN: Scenario 'unknown Status 3': status: Aborted (3)
|
||||
... 14 --filter-name='unknown Status 4' --output-ignore-perfdata UNKNOWN: Scenario 'unknown Status 4': status: No execution (4)
|
||||
... 15 --filter-name='unknown Status 5' --output-ignore-perfdata UNKNOWN: Scenario 'unknown Status 5': status: No execution (5)
|
||||
... 16 --filter-name='unknown Status 6' --output-ignore-perfdata UNKNOWN: Scenario 'unknown Status 6': status: Stopped (6)
|
||||
|
Loading…
x
Reference in New Issue
Block a user