Fix #1885
This commit is contained in:
parent
234ac31d1f
commit
991f13de06
|
@ -117,6 +117,7 @@ sub new {
|
||||||
$options{options}->add_options(arguments => {
|
$options{options}->add_options(arguments => {
|
||||||
'warning-status:s' => { name => 'warning_status', default => '' },
|
'warning-status:s' => { name => 'warning_status', default => '' },
|
||||||
'critical-status:s' => { name => 'critical_status', default => '%{oper_mode} !~ /normal/i' },
|
'critical-status:s' => { name => 'critical_status', default => '%{oper_mode} !~ /normal/i' },
|
||||||
|
'timezone:s' => { name => 'timezone' }
|
||||||
});
|
});
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
|
@ -127,6 +128,7 @@ sub check_options {
|
||||||
$self->SUPER::check_options(%options);
|
$self->SUPER::check_options(%options);
|
||||||
|
|
||||||
$self->change_macros(macros => ['warning_status', 'critical_status']);
|
$self->change_macros(macros => ['warning_status', 'critical_status']);
|
||||||
|
$self->{option_results}->{timezone} = 'GMT' if (!defined($self->{option_results}->{timezone}) || $self->{option_results}->{timezone} eq '');
|
||||||
}
|
}
|
||||||
|
|
||||||
sub get_diff_time {
|
sub get_diff_time {
|
||||||
|
@ -135,10 +137,7 @@ sub get_diff_time {
|
||||||
# '2019/10/15 12:03:58 BST'
|
# '2019/10/15 12:03:58 BST'
|
||||||
return if ($options{time} !~ /^\s*(\d{4})\/(\d{2})\/(\d{2})\s+(\d+):(\d+):(\d+)\s+(\S+)/);
|
return if ($options{time} !~ /^\s*(\d{4})\/(\d{2})\/(\d{2})\s+(\d+):(\d+):(\d+)\s+(\S+)/);
|
||||||
|
|
||||||
my $tz = $7;
|
my $tz = centreon::plugins::misc::set_timezone(name => $self->{option_results}->{timezone});
|
||||||
$tz = 'GMT' if ($tz eq 'BST');
|
|
||||||
$tz = 'Europe/Paris' if ($tz eq 'CEST');
|
|
||||||
$tz = 'America/New_York' if ($tz eq 'EST');
|
|
||||||
my $dt = DateTime->new(
|
my $dt = DateTime->new(
|
||||||
year => $1,
|
year => $1,
|
||||||
month => $2,
|
month => $2,
|
||||||
|
@ -146,7 +145,7 @@ sub get_diff_time {
|
||||||
hour => $4,
|
hour => $4,
|
||||||
minute => $5,
|
minute => $5,
|
||||||
second => $6,
|
second => $6,
|
||||||
time_zone => $tz
|
%$tz
|
||||||
);
|
);
|
||||||
return (time() - $dt->epoch);
|
return (time() - $dt->epoch);
|
||||||
}
|
}
|
||||||
|
@ -198,6 +197,10 @@ Check system.
|
||||||
Only display some counters (regexp can be used).
|
Only display some counters (regexp can be used).
|
||||||
Example: --filter-counters='^status$'
|
Example: --filter-counters='^status$'
|
||||||
|
|
||||||
|
=item B<--timezone>
|
||||||
|
|
||||||
|
Timezone options. Default is 'GMT'.
|
||||||
|
|
||||||
=item B<--warning-status>
|
=item B<--warning-status>
|
||||||
|
|
||||||
Set warning threshold for status (Default: '').
|
Set warning threshold for status (Default: '').
|
||||||
|
|
Loading…
Reference in New Issue