mirror of
https://github.com/centreon/centreon-plugins.git
synced 2025-07-30 17:15:11 +02:00
enh(counters/iplabe-ekara): allow to sort instances on attribute instead of instance key (#5501)
Refs: CTOR-1388
This commit is contained in:
parent
eeac58c17f
commit
6027943d65
@ -53,7 +53,16 @@ sub set_counters {
|
||||
{ name => 'scenarios', type => 3, cb_prefix_output => 'prefix_scenario_output', cb_long_output => 'prefix_scenario_output', indent_long_output => ' ', message_multiple => 'All scenarios are ok',
|
||||
group => [
|
||||
{ name => 'global', type => 0, skipped_code => { -10 => 1 } },
|
||||
{ name => 'steps', display_long => 1, cb_prefix_output => 'prefix_steps_output', message_multiple => 'All steps are ok', type => 1, skipped_code => { -10 => 1 } }
|
||||
{
|
||||
name => 'steps',
|
||||
type => 1,
|
||||
cb_prefix_output => 'prefix_steps_output',
|
||||
display_long => 1,
|
||||
message_multiple => 'All steps are ok',
|
||||
skipped_code => { -10 => 1 },
|
||||
sort_method => 'num',
|
||||
sort_attribute => 'index'
|
||||
}
|
||||
]
|
||||
}
|
||||
];
|
||||
@ -98,7 +107,7 @@ sub set_counters {
|
||||
];
|
||||
$self->{maps_counters}->{steps} = [
|
||||
{ label => 'time-step', nlabel => 'scenario.step.time.milliseconds', set => {
|
||||
key_values => [ { name => 'time_step' }, { name => 'display' }, { name => 'last_exec' } ],
|
||||
key_values => [ { name => 'time_step' }, { name => 'display' }, { name => 'last_exec' }, { name => 'index' } ],
|
||||
output_template => 'time step: %s ms',
|
||||
perfdatas => [
|
||||
{ template => '%s', unit => 'ms', min => 0, label_extra_instance => 1 }
|
||||
@ -106,7 +115,7 @@ sub set_counters {
|
||||
}
|
||||
},
|
||||
{ label => 'time-total', nlabel => 'scenario.steps.time.total.milliseconds', set => {
|
||||
key_values => [ { name => 'time_total' }, { name => 'display' }, { name => 'last_exec' } ],
|
||||
key_values => [ { name => 'time_total' }, { name => 'display' }, { name => 'last_exec' }, { name => 'index' } ],
|
||||
output_template => 'time total: %s ms',
|
||||
perfdatas => [
|
||||
{ template => '%s', unit => 'ms', min => 0, label_extra_instance => 1 }
|
||||
@ -209,6 +218,7 @@ sub manage_selection {
|
||||
$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));
|
||||
$self->{scenarios}->{ $scenario->{scenarioName} }->{steps}->{ $self->{scenarios}->{ $scenario->{scenarioName} }->{steps_index}->{ $step_metrics->{stepId} } }->{display} = $self->{scenarios}->{ $scenario->{scenarioName} }->{steps_index}->{ $step_metrics->{stepId} };
|
||||
$self->{scenarios}->{ $scenario->{scenarioName} }->{steps}->{ $self->{scenarios}->{ $scenario->{scenarioName} }->{steps_index}->{ $step_metrics->{stepId} } }->{index} = $step_metrics->{stepId};
|
||||
}
|
||||
}
|
||||
|
||||
@ -254,14 +264,53 @@ Syntax: C<--warning-scenario-status='%{status} =~ "xxx"'>
|
||||
Critical threshold for scenario status (default: '%{status} =~ "Failure"').
|
||||
Syntax: --critical-scenario-status='%{status} =~ "xxx"'
|
||||
|
||||
=item B<--warning-*> B<--critical-*>
|
||||
=item B<--warning-availability>
|
||||
|
||||
Thresholds.
|
||||
Common: 'availability' (%),
|
||||
For WEB scenarios: 'time-total-allsteps' (ms), 'time-step' (ms),
|
||||
For HTTPR scenarios: 'time-total' (ms),
|
||||
FOR BPL scenarios: 'time-interaction' (ms), 'time-total' (ms).
|
||||
Thresholds in %.
|
||||
|
||||
=item B<--critical-availability>
|
||||
|
||||
Thresholds in %.
|
||||
|
||||
=item B<--warning-time-total-allsteps>
|
||||
|
||||
Thresholds in ms for WEB scenarios.
|
||||
|
||||
=item B<--critical-time-total-allsteps>
|
||||
|
||||
Thresholds in ms for WEB scenarios.
|
||||
|
||||
=item B<--warning-time-step>
|
||||
|
||||
Thresholds in ms for WEB scenarios.
|
||||
|
||||
=item B<--critical-time-step>
|
||||
|
||||
Thresholds in ms for WEB scenarios.
|
||||
|
||||
=item B<--warning-time-total>
|
||||
|
||||
Thresholds in ms for HTTPR scenarios.
|
||||
|
||||
=item B<--critical-time-total>
|
||||
|
||||
Thresholds in ms for HTTPR scenarios.
|
||||
|
||||
=item B<--warning-time-interaction>
|
||||
|
||||
Thresholds in ms for BPL scenarios.
|
||||
|
||||
=item B<--critical-time-interaction>
|
||||
|
||||
Thresholds in ms for BPL scenarios.
|
||||
|
||||
=item B<--warning-time-total>
|
||||
|
||||
Thresholds in ms for BPL scenarios.
|
||||
|
||||
=item B<--critical-time-total>
|
||||
|
||||
Thresholds in ms for BPL scenarios.
|
||||
|
||||
=back
|
||||
|
||||
|
@ -365,10 +365,27 @@ sub run_instances {
|
||||
my $message_separator = defined($options{config}->{message_separator}) ?
|
||||
$options{config}->{message_separator}: ', ';
|
||||
|
||||
# The default sort method is cmp (string comparison)
|
||||
my $sort_method = 'cmp';
|
||||
# If configured otherwise, we take it from the counter (only other method is 'num' for '<=>')
|
||||
$sort_method = $options{config}->{sort_method}
|
||||
if (defined($options{config}->{sort_method}));
|
||||
foreach my $id (sort { $sort_subs->{$sort_method}->() } keys %{$self->{$options{config}->{name}}}) {
|
||||
|
||||
# In the absence of sort_attribute the sort method is set now
|
||||
my $sort_sub = $sort_subs->{$sort_method};
|
||||
|
||||
# If sort_attribute is set, then we'll redefine how things are sorted depending on the specified sort_method
|
||||
if (defined($options{config}->{sort_attribute})) {
|
||||
my $sort_attribute = $options{config}->{sort_attribute};
|
||||
if ($sort_method eq 'cmp') {
|
||||
$sort_sub = sub { $self->{$options{config}->{name}}->{$a}->{$sort_attribute} cmp $self->{$options{config}->{name}}->{$b}->{$sort_attribute}};
|
||||
} else {
|
||||
$sort_sub = sub { $self->{$options{config}->{name}}->{$a}->{$sort_attribute} <=> $self->{$options{config}->{name}}->{$b}->{$sort_attribute}};
|
||||
}
|
||||
}
|
||||
|
||||
# Now the loop begins with the desired sorting method
|
||||
foreach my $id (sort { $sort_sub->() } keys %{$self->{$options{config}->{name}}}) {
|
||||
my ($short_msg, $short_msg_append, $long_msg, $long_msg_append) = ('', '', '', '');
|
||||
my @exits = ();
|
||||
foreach (@{$self->{maps_counters}->{$options{config}->{name}}}) {
|
||||
@ -547,10 +564,28 @@ sub run_multiple_instances {
|
||||
|
||||
my $message_separator = defined($options{config}->{message_separator}) ?
|
||||
$options{config}->{message_separator} : ', ';
|
||||
|
||||
# The default sort method is cmp (string comparison)
|
||||
my $sort_method = 'cmp';
|
||||
# If configured otherwise, we take it from the counter (only other method is 'num' for '<=>')
|
||||
$sort_method = $options{config}->{sort_method}
|
||||
if (defined($options{config}->{sort_method}));
|
||||
foreach my $id (sort { $sort_subs->{$sort_method}->() } keys %{$self->{$options{config}->{name}}}) {
|
||||
|
||||
# In the absence of sort_attribute the sort method is set now
|
||||
my $sort_sub = $sort_subs->{$sort_method};
|
||||
|
||||
# If sort_attribute is set, then we'll redefine how things are sorted depending on the specified sort_method
|
||||
if (defined($options{config}->{sort_attribute})) {
|
||||
my $sort_attribute = $options{config}->{sort_attribute};
|
||||
if ($sort_method eq 'cmp') {
|
||||
$sort_sub = sub { $self->{$options{config}->{name}}->{$a}->{$sort_attribute} cmp $self->{$options{config}->{name}}->{$b}->{$sort_attribute}};
|
||||
} else {
|
||||
$sort_sub = sub { $self->{$options{config}->{name}}->{$a}->{$sort_attribute} <=> $self->{$options{config}->{name}}->{$b}->{$sort_attribute}};
|
||||
}
|
||||
}
|
||||
|
||||
# Now the loop begins with the desired sorting method
|
||||
foreach my $id (sort { $sort_sub->() } keys %{$self->{$options{config}->{name}}}) {
|
||||
my ($short_msg, $short_msg_append, $long_msg, $long_msg_append) = ('', '', '', '');
|
||||
my @exits = ();
|
||||
foreach (@{$self->{maps_counters}->{$options{config}->{name}}}) {
|
||||
|
@ -15,7 +15,7 @@ ${CMD} ${CENTREON_PLUGINS} --plugin=cloud::aws::cloudtr
|
||||
|
||||
|
||||
*** Test Cases ***
|
||||
AWS CloudTrail check trail status
|
||||
AWS CloudTrail check trail status ${tc}
|
||||
[Documentation] Check AWS CloudTrail trail status
|
||||
[Tags] cloud aws cloudtrail
|
||||
|
||||
|
@ -15,7 +15,7 @@ ${CMD} ${CENTREON_PLUGINS} --plugin=cloud::aws::cloudtr
|
||||
|
||||
|
||||
*** Test Cases ***
|
||||
AWS CloudTrail count events
|
||||
AWS CloudTrail count events ${tc}
|
||||
[Documentation] Check AWS CloudTrail count events
|
||||
[Tags] cloud aws cloudtrail
|
||||
|
||||
|
File diff suppressed because one or more lines are too long
@ -30,9 +30,9 @@ scenario ${tc}
|
||||
|
||||
Ctn Run Command And Check Result As Strings ${command} ${expected_result}
|
||||
|
||||
Examples: tc extra_options expected_result --
|
||||
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;
|
||||
... 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~Run Chrome#scenario.step.time.milliseconds'=2534ms;;;0; 'AKILA - Business App~Dashboard 2#scenario.step.time.milliseconds'=898ms;;;0; 'AKILA - Business App~Dashboard 3#scenario.step.time.milliseconds'=848ms;;;0;
|
||||
... 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='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
|
||||
@ -50,3 +50,5 @@ scenario ${tc}
|
||||
... 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)
|
||||
... 17 --filter-name='AKILA - .Web.' --curl-opt='CURLOPT_HTTPHEADER => [test: 2]' --curl-opt='CURLOPT_HTTPHEADER => [ Authorization: Bearer VeryLongTokenToAuthenticate]' CRITICAL: Scenario 'AKILA - (Web)': status: Failure (2) | 'AKILA - (Web)#scenario.availability.percentage'=64.48%;;;0;100 'AKILA - (Web)#scenario.time.allsteps.total.milliseconds'=4031ms;;;0; 'AKILA - (Web)~Home#scenario.step.time.milliseconds'=3862ms;;;0; 'AKILA - (Web)~Dashboard v2#scenario.step.time.milliseconds'=215ms;;;0; 'AKILA - (Web)~Dashboard v3#scenario.step.time.milliseconds'=68ms;;;0;
|
||||
|
||||
|
@ -52,6 +52,7 @@ Ctn Cleanup Cache
|
||||
|
||||
Ctn Generic Suite Setup
|
||||
Ctn Cleanup Cache
|
||||
Set Environment Variable TZ UTC
|
||||
|
||||
Ctn Run Command And Check Result As Regexp
|
||||
[Arguments] ${command} ${expected_result}
|
||||
|
Loading…
x
Reference in New Issue
Block a user