mirror of
https://github.com/centreon/centreon-plugins.git
synced 2025-07-29 00:24:46 +02:00
fix(storage::emc::datadomain::snmp): fixed cleaning mode by adding timezone option CTOR-1415 (#5453)
Co-authored-by: omercier <omercier@centreon.com>
This commit is contained in:
parent
129256e737
commit
4d055649a3
@ -82,7 +82,8 @@ sub new {
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments => {
|
||||
'unit:s' => { name => 'unit', default => 'd' }
|
||||
'unit:s' => { name => 'unit', default => 'd' },
|
||||
'timezone:s' => { name => 'timezone'}
|
||||
});
|
||||
|
||||
return $self;
|
||||
@ -95,6 +96,10 @@ sub check_options {
|
||||
if ($self->{option_results}->{unit} eq '' || !defined($unitdiv->{$self->{option_results}->{unit}})) {
|
||||
$self->{option_results}->{unit} = 'd';
|
||||
}
|
||||
if (defined($self->{option_results}->{timezone}) && $self->{option_results}->{timezone} ne '' && $self->{option_results}->{timezone} !~ /^[A-Za-z_\/0-9-]+$/) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong timezone format '" . $self->{option_results}->{timezone} . "'. (Example format: 'America/Los_Angeles')");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
@ -112,6 +117,16 @@ sub manage_selection {
|
||||
foreach my $oid (keys %$snmp_result) {
|
||||
if ($snmp_result->{$oid} =~ /\s+(\d+)\/(\d+)\/(\d+)\s+(\d+):(\d+):(\d+)/) {
|
||||
my $dt = DateTime->new(year => $1, month => $2, day => $3, hour => $4, minute => $5, second => $6);
|
||||
# if the equipment check is on another timezone than the system where the plugin is executed.
|
||||
if (defined($self->{option_results}->{timezone})){
|
||||
eval {
|
||||
$dt = $dt->set_time_zone($self->{option_results}->{timezone});
|
||||
};
|
||||
if ($@) {
|
||||
$self->{output}->add_option_msg(short_msg => "Invalid timezone provided: '" . $self->{option_results}->{timezone} . "'. Check in /usr/share/zoneinfo for valid time zones.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
}
|
||||
my $lastExecSeconds = $ctime - $dt->epoch();
|
||||
if ($self->{global}->{lastExecSeconds} == -1 || $self->{global}->{lastExecSeconds} > $lastExecSeconds) {
|
||||
$self->{global}->{lastExecSeconds} = $lastExecSeconds;
|
||||
@ -144,6 +159,11 @@ Check last time filesystems had been cleaned.
|
||||
|
||||
Select the time unit for thresholds. May be 's' for seconds, 'm' for minutes, 'h' for hours, 'd' for days, 'w' for weeks (default: 'd').
|
||||
|
||||
=item B<--timezone>
|
||||
|
||||
Set equipment timezone if different from Europe/London. Valid time zones can be found in C</usr/share/zoneinfo>.
|
||||
Format example : Europe/Paris and America/Los_Angeles
|
||||
|
||||
=item B<--warning-*> B<--critical-*>
|
||||
|
||||
Thresholds.
|
||||
|
@ -31,8 +31,11 @@ cleaning ${tc}
|
||||
|
||||
|
||||
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;
|
||||
... 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;
|
||||
... 6 --timezone='Europe/Paris' storage/emc/datadomain/snmp/slim-datadomain-cleaning-ok OK: cleaning last execution: .* \\\\| 'filesystems.cleaning.execution.last.days'=\\\\d+d;;;0;
|
||||
... 7 --timezone='America/Los_Angeles' storage/emc/datadomain/snmp/slim-datadomain-cleaning-ok OK: cleaning last execution: .* \\\\| 'filesystems.cleaning.execution.last.days'=\\\\d+d;;;0;
|
||||
... 8 --timezone='bad/timezone' storage/emc/datadomain/snmp/slim-datadomain-cleaning-ok UNKNOWN: Invalid timezone provided: 'bad/timezone'. Check in /usr/share/zoneinfo for valid time zones.
|
||||
|
@ -0,0 +1 @@
|
||||
.1.3.6.1.4.1.19746.1.3.5.1.1.2.0 = STRING: Cleaning finished at 2025/02/17 09:55:44.
|
Loading…
x
Reference in New Issue
Block a user