From 00049482a762998ef9e107e66000cc0743eb97ae Mon Sep 17 00:00:00 2001 From: Lucie Dubrunfaut Date: Thu, 12 Dec 2024 11:23:16 +0100 Subject: [PATCH 1/6] fix(datadomain-cleaning):fixed issue when cleaning is running --- src/storage/emc/datadomain/snmp/mode/cleaning.pm | 6 +++++- .../snmp/slim-datadomain-cleaning-running.snmpwalk | 1 + tests/storage/emc/datadomain/snmp/slim-datadomain.snmpwalk | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 tests/storage/emc/datadomain/snmp/slim-datadomain-cleaning-running.snmpwalk diff --git a/src/storage/emc/datadomain/snmp/mode/cleaning.pm b/src/storage/emc/datadomain/snmp/mode/cleaning.pm index 191f656826..87e6c606cd 100644 --- a/src/storage/emc/datadomain/snmp/mode/cleaning.pm +++ b/src/storage/emc/datadomain/snmp/mode/cleaning.pm @@ -116,10 +116,14 @@ sub manage_selection { if ($self->{global}->{lastExecSeconds} == -1 || $self->{global}->{lastExecSeconds} > $lastExecSeconds) { $self->{global}->{lastExecSeconds} = $lastExecSeconds; } + }elsif($snmp_result->{$oid} =~ /Cleaning: phase (\d+) of (\d+) \(copy\)/){ + $self->{global}->{lastExecHuman} = "running (phase $1 of $2 (copy))"; + $self->{global}->{lastExecSeconds} = 0; } } - if ($self->{global}->{lastExecSeconds} != -1) { + # If there is a lastExecSeconds set (if above in the looop) and this is not a cleaning running (elsif above) + if ($self->{global}->{lastExecSeconds} != -1 && ($self->{global}->{lastExecSeconds} == 0 && $self->{global}->{lastExecHuman} eq "never")) { $self->{global}->{lastExecHuman} = centreon::plugins::misc::change_seconds( value => $self->{global}->{lastExecSeconds} ); diff --git a/tests/storage/emc/datadomain/snmp/slim-datadomain-cleaning-running.snmpwalk b/tests/storage/emc/datadomain/snmp/slim-datadomain-cleaning-running.snmpwalk new file mode 100644 index 0000000000..3f0e126c9f --- /dev/null +++ b/tests/storage/emc/datadomain/snmp/slim-datadomain-cleaning-running.snmpwalk @@ -0,0 +1 @@ +.1.3.6.1.4.1.19746.1.3.5.1.1.2.0 = STRING: Cleaning: phase 5 of 6 (copy) \ No newline at end of file diff --git a/tests/storage/emc/datadomain/snmp/slim-datadomain.snmpwalk b/tests/storage/emc/datadomain/snmp/slim-datadomain.snmpwalk index 2f5417c84e..43df86852f 100644 --- a/tests/storage/emc/datadomain/snmp/slim-datadomain.snmpwalk +++ b/tests/storage/emc/datadomain/snmp/slim-datadomain.snmpwalk @@ -14972,7 +14972,7 @@ .1.3.6.1.4.1.19746.1.3.2.1.1.9.3 = STRING: Anonymized 098 .1.3.6.1.4.1.19746.1.3.2.1.1.9.4 = STRING: Anonymized 136 .1.3.6.1.4.1.19746.1.3.2.1.1.9.5 = STRING: Anonymized 207 -.1.3.6.1.4.1.19746.1.3.5.1.1.2.0 = STRING: Anonymized 176 +.1.3.6.1.4.1.19746.1.3.5.1.1.2.0 = STRING: "Cleaning finished at 2024/08/27 13:58:59." .1.3.6.1.4.1.19746.1.4.1.1.1.2.1 = STRING: Anonymized 018 .1.3.6.1.4.1.19746.1.4.1.1.1.2.2 = STRING: Anonymized 005 .1.3.6.1.4.1.19746.1.4.1.1.1.2.3 = STRING: Anonymized 122 From f26508589d769f5ee58f6e50c8fefe2a4cc9c904 Mon Sep 17 00:00:00 2001 From: Lucie Dubrunfaut Date: Thu, 12 Dec 2024 11:44:15 +0100 Subject: [PATCH 2/6] Fix if condition --- src/storage/emc/datadomain/snmp/mode/cleaning.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/storage/emc/datadomain/snmp/mode/cleaning.pm b/src/storage/emc/datadomain/snmp/mode/cleaning.pm index 87e6c606cd..69085b9f8d 100644 --- a/src/storage/emc/datadomain/snmp/mode/cleaning.pm +++ b/src/storage/emc/datadomain/snmp/mode/cleaning.pm @@ -123,7 +123,7 @@ sub manage_selection { } # If there is a lastExecSeconds set (if above in the looop) and this is not a cleaning running (elsif above) - if ($self->{global}->{lastExecSeconds} != -1 && ($self->{global}->{lastExecSeconds} == 0 && $self->{global}->{lastExecHuman} eq "never")) { + if ($self->{global}->{lastExecSeconds} > 0 || ($self->{global}->{lastExecSeconds} = 0 && $self->{global}->{lastExecHuman} eq "never")) { $self->{global}->{lastExecHuman} = centreon::plugins::misc::change_seconds( value => $self->{global}->{lastExecSeconds} ); From 966abe2ccdfe170816c32631129402d8ec89474f Mon Sep 17 00:00:00 2001 From: Lucie Dubrunfaut Date: Thu, 12 Dec 2024 16:04:16 +0100 Subject: [PATCH 3/6] Enhance running handling --- src/storage/emc/datadomain/snmp/mode/cleaning.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/storage/emc/datadomain/snmp/mode/cleaning.pm b/src/storage/emc/datadomain/snmp/mode/cleaning.pm index 69085b9f8d..3eb73e7633 100644 --- a/src/storage/emc/datadomain/snmp/mode/cleaning.pm +++ b/src/storage/emc/datadomain/snmp/mode/cleaning.pm @@ -116,8 +116,8 @@ sub manage_selection { if ($self->{global}->{lastExecSeconds} == -1 || $self->{global}->{lastExecSeconds} > $lastExecSeconds) { $self->{global}->{lastExecSeconds} = $lastExecSeconds; } - }elsif($snmp_result->{$oid} =~ /Cleaning: phase (\d+) of (\d+) \(copy\)/){ - $self->{global}->{lastExecHuman} = "running (phase $1 of $2 (copy))"; + }elsif($snmp_result->{$oid} =~ /Cleaning: phase (\d+) of (\d+) \(([^)]+)\)/) { + $self->{global}->{lastExecHuman} = "running (phase $1 of $2 : $3)"; $self->{global}->{lastExecSeconds} = 0; } } From 5321a7604c93cab465f6e1a0521dc204bf0ba4c3 Mon Sep 17 00:00:00 2001 From: sfarouq-ext <116093375+sfarouq-ext@users.noreply.github.com> Date: Wed, 18 Dec 2024 15:37:53 +0100 Subject: [PATCH 4/6] adding exemple for cleaning --- .../emc/datadomain/snmp/cleaning.robot | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/tests/storage/emc/datadomain/snmp/cleaning.robot b/tests/storage/emc/datadomain/snmp/cleaning.robot index ed7b68d42d..86b427bfc2 100644 --- a/tests/storage/emc/datadomain/snmp/cleaning.robot +++ b/tests/storage/emc/datadomain/snmp/cleaning.robot @@ -20,15 +20,18 @@ cleaning ${tc} ... --hostname=${HOSTNAME} ... --snmp-version=${SNMPVERSION} ... --snmp-port=${SNMPPORT} - ... --snmp-community=storage/emc/datadomain/snmp/slim-datadomain - ... --snmp-timeout=1 + ... --snmp-community=${SNMPCOMMUNITY} + ... --snmp-timeout=5 ... ${extra_options} - - Ctn Run Command And Check Result As Strings ${command} ${expected_result} + + # first run to build cache + Run ${command} + # second run to control the output + Ctn Run Command And Check Result As Regexp ${command} ${expected_result} + - Examples: tc extra_options expected_result -- - ... 1 --verbose OK: cleaning last execution: never | 'filesystems.cleaning.execution.last.days'=-1d;;;0; - ... 2 --unit='h' OK: cleaning last execution: never | 'filesystems.cleaning.execution.last.hours'=-1h;;;0; - ... 3 --unit='s' OK: cleaning last execution: never | 'filesystems.cleaning.execution.last.seconds'=-1s;;;0; - ... 4 --unit='w' OK: cleaning last execution: never | 'filesystems.cleaning.execution.last.weeks'=-1w;;;0; - ... 5 --warning-last-cleaning-execution='' --critical-last-cleaning-execution='' OK: cleaning last execution: never | 'filesystems.cleaning.execution.last.days'=-1d;;;0; + Examples: tc extra_options SNMPCOMMUNITY expected_result -- + ... 1 ${EMPTY} storage/emc/datadomain/snmp/slim-datadomain OK: cleaning last execution: \\\\d+M \\\\d+w \\\\d+h \\\\d+m \\\\d+s \\\\| 'filesystems.cleaning.execution.last.days'=\\\\d+d;;;0;$ + ... 2 --unit='w' storage/emc/datadomain/snmp/slim-datadomain OK: cleaning last execution: 3M 3w 17h 9m 7s | 'filesystems.cleaning.execution.last.weeks'=16w;;;0; + ... 3 --warning-last-cleaning-execution='115' --critical-last-cleaning-execution='0' storage/emc/datadomain/snmp/slim-datadomain CRITICAL: cleaning last execution: 3M 3w 16h 52m 15s | 'filesystems.cleaning.execution.last.days'=113d;0:115;0:0;0; + ... 4 ${EMPTY} storage/emc/datadomain/snmp/slim-datadomain-cleaning-running OK: cleaning last execution: running (phase 5 of 6 : copy) | 'filesystems.cleaning.execution.last.days'=0d;;;0; \ No newline at end of file From 1b0514c461196076bd20c032592c4c9aa1c0684c Mon Sep 17 00:00:00 2001 From: Lucie Dubrunfaut <123162035+lucie-dubrunfaut@users.noreply.github.com> Date: Mon, 23 Dec 2024 10:26:15 +0100 Subject: [PATCH 5/6] Apply suggestions from code review Co-authored-by: omercier <32134301+omercier@users.noreply.github.com> --- src/storage/emc/datadomain/snmp/mode/cleaning.pm | 4 ++-- tests/storage/emc/datadomain/snmp/cleaning.robot | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/storage/emc/datadomain/snmp/mode/cleaning.pm b/src/storage/emc/datadomain/snmp/mode/cleaning.pm index 3eb73e7633..762925ce47 100644 --- a/src/storage/emc/datadomain/snmp/mode/cleaning.pm +++ b/src/storage/emc/datadomain/snmp/mode/cleaning.pm @@ -116,14 +116,14 @@ sub manage_selection { if ($self->{global}->{lastExecSeconds} == -1 || $self->{global}->{lastExecSeconds} > $lastExecSeconds) { $self->{global}->{lastExecSeconds} = $lastExecSeconds; } - }elsif($snmp_result->{$oid} =~ /Cleaning: phase (\d+) of (\d+) \(([^)]+)\)/) { + } elsif ($snmp_result->{$oid} =~ /Cleaning: phase (\d+) of (\d+) \(([^)]+)\)/) { $self->{global}->{lastExecHuman} = "running (phase $1 of $2 : $3)"; $self->{global}->{lastExecSeconds} = 0; } } # If there is a lastExecSeconds set (if above in the looop) and this is not a cleaning running (elsif above) - if ($self->{global}->{lastExecSeconds} > 0 || ($self->{global}->{lastExecSeconds} = 0 && $self->{global}->{lastExecHuman} eq "never")) { + if ($self->{global}->{lastExecSeconds} > 0 || ($self->{global}->{lastExecSeconds} == 0 && $self->{global}->{lastExecHuman} eq "never")) { $self->{global}->{lastExecHuman} = centreon::plugins::misc::change_seconds( value => $self->{global}->{lastExecSeconds} ); diff --git a/tests/storage/emc/datadomain/snmp/cleaning.robot b/tests/storage/emc/datadomain/snmp/cleaning.robot index 86b427bfc2..abf2fc2e83 100644 --- a/tests/storage/emc/datadomain/snmp/cleaning.robot +++ b/tests/storage/emc/datadomain/snmp/cleaning.robot @@ -20,7 +20,7 @@ cleaning ${tc} ... --hostname=${HOSTNAME} ... --snmp-version=${SNMPVERSION} ... --snmp-port=${SNMPPORT} - ... --snmp-community=${SNMPCOMMUNITY} + ... --snmp-community=${snmp_community} ... --snmp-timeout=5 ... ${extra_options} @@ -30,7 +30,7 @@ cleaning ${tc} Ctn Run Command And Check Result As Regexp ${command} ${expected_result} - Examples: tc extra_options SNMPCOMMUNITY expected_result -- + Examples: tc extra_options snmp_community expected_result -- ... 1 ${EMPTY} storage/emc/datadomain/snmp/slim-datadomain OK: cleaning last execution: \\\\d+M \\\\d+w \\\\d+h \\\\d+m \\\\d+s \\\\| 'filesystems.cleaning.execution.last.days'=\\\\d+d;;;0;$ ... 2 --unit='w' storage/emc/datadomain/snmp/slim-datadomain OK: cleaning last execution: 3M 3w 17h 9m 7s | 'filesystems.cleaning.execution.last.weeks'=16w;;;0; ... 3 --warning-last-cleaning-execution='115' --critical-last-cleaning-execution='0' storage/emc/datadomain/snmp/slim-datadomain CRITICAL: cleaning last execution: 3M 3w 16h 52m 15s | 'filesystems.cleaning.execution.last.days'=113d;0:115;0:0;0; From c2cff37db026dec49264ee5824efad373d59c546 Mon Sep 17 00:00:00 2001 From: omercier <32134301+omercier@users.noreply.github.com> Date: Mon, 23 Dec 2024 11:23:36 +0100 Subject: [PATCH 6/6] Update tests/storage/emc/datadomain/snmp/cleaning.robot --- tests/storage/emc/datadomain/snmp/cleaning.robot | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tests/storage/emc/datadomain/snmp/cleaning.robot b/tests/storage/emc/datadomain/snmp/cleaning.robot index abf2fc2e83..161db0b71d 100644 --- a/tests/storage/emc/datadomain/snmp/cleaning.robot +++ b/tests/storage/emc/datadomain/snmp/cleaning.robot @@ -30,8 +30,9 @@ cleaning ${tc} Ctn Run Command And Check Result As Regexp ${command} ${expected_result} - Examples: tc extra_options snmp_community expected_result -- - ... 1 ${EMPTY} storage/emc/datadomain/snmp/slim-datadomain OK: cleaning last execution: \\\\d+M \\\\d+w \\\\d+h \\\\d+m \\\\d+s \\\\| 'filesystems.cleaning.execution.last.days'=\\\\d+d;;;0;$ - ... 2 --unit='w' storage/emc/datadomain/snmp/slim-datadomain OK: cleaning last execution: 3M 3w 17h 9m 7s | 'filesystems.cleaning.execution.last.weeks'=16w;;;0; - ... 3 --warning-last-cleaning-execution='115' --critical-last-cleaning-execution='0' storage/emc/datadomain/snmp/slim-datadomain CRITICAL: cleaning last execution: 3M 3w 16h 52m 15s | 'filesystems.cleaning.execution.last.days'=113d;0:115;0:0;0; - ... 4 ${EMPTY} storage/emc/datadomain/snmp/slim-datadomain-cleaning-running OK: cleaning last execution: running (phase 5 of 6 : copy) | 'filesystems.cleaning.execution.last.days'=0d;;;0; \ No newline at end of file + Examples: tc extra_options snmp_community expected_result -- + ... 1 ${EMPTY} storage/emc/datadomain/snmp/slim-datadomain OK: cleaning last execution: (\\\\d+[yY]] )?(\\\\d+M )?(\\\\d+w )?(\\\\d+d )?(\\\\d+h )?(\\\\d+m )?(\\\\d+s )?\\\\| 'filesystems.cleaning.execution.last.days'=\\\\d+d;;;0;$ + ... 2 --unit='w' storage/emc/datadomain/snmp/slim-datadomain OK: cleaning last execution: (\\\\d+[yY]] )?(\\\\d+M )?(\\\\d+w )?(\\\\d+d )?(\\\\d+h )?(\\\\d+m )?(\\\\d+s )?\\\\| 'filesystems.cleaning.execution.last.weeks'=\\\\d+w;;;0;$ + ... 3 --warning-last-cleaning-execution='115' storage/emc/datadomain/snmp/slim-datadomain WARNING: cleaning last execution: (\\\\d+[yY]] )?(\\\\d+M )?(\\\\d+w )?(\\\\d+d )?(\\\\d+h )?(\\\\d+m )?(\\\\d+s )?\\\\| 'filesystems.cleaning.execution.last.days'=\\\\d+d;0:115;;0; + ... 4 --critical-last-cleaning-execution='0' storage/emc/datadomain/snmp/slim-datadomain CRITICAL: cleaning last execution: (\\\\d+[yY]] )?(\\\\d+M )?(\\\\d+w )?(\\\\d+d )?(\\\\d+h )?(\\\\d+m )?(\\\\d+s )?\\\\| 'filesystems.cleaning.execution.last.days'=\\\\d+d;;0:0;0; + ... 5 ${EMPTY} storage/emc/datadomain/snmp/slim-datadomain-cleaning-running OK: cleaning last execution: running \\\\(phase 5 of 6 : copy\\\\) \\\\| 'filesystems.cleaning.execution.last.days'=0d;;;0;