+ Add mode time in snmp for windows
This commit is contained in:
parent
109b2c5b12
commit
37f0b95e65
|
@ -56,6 +56,7 @@ sub new {
|
||||||
'service' => 'os::windows::snmp::mode::service',
|
'service' => 'os::windows::snmp::mode::service',
|
||||||
'storage' => 'snmp_standard::mode::storage',
|
'storage' => 'snmp_standard::mode::storage',
|
||||||
'swap' => 'os::windows::snmp::mode::swap',
|
'swap' => 'os::windows::snmp::mode::swap',
|
||||||
|
'time' => 'snmp_standard::mode::ntp',
|
||||||
'traffic' => 'snmp_standard::mode::traffic',
|
'traffic' => 'snmp_standard::mode::traffic',
|
||||||
'uptime' => 'snmp_standard::mode::uptime',
|
'uptime' => 'snmp_standard::mode::uptime',
|
||||||
);
|
);
|
||||||
|
|
|
@ -54,6 +54,7 @@ sub new {
|
||||||
"ntp-port:s" => { name => 'ntp_port', default => 123 },
|
"ntp-port:s" => { name => 'ntp_port', default => 123 },
|
||||||
"warning:s" => { name => 'warning' },
|
"warning:s" => { name => 'warning' },
|
||||||
"critical:s" => { name => 'critical' },
|
"critical:s" => { name => 'critical' },
|
||||||
|
"timezone:s" => { name => 'timezone' },
|
||||||
});
|
});
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
@ -109,6 +110,13 @@ sub run {
|
||||||
}
|
}
|
||||||
|
|
||||||
my @remote_date = unpack 'n C6 a C2', $result->{$oid_hrSystemDate};
|
my @remote_date = unpack 'n C6 a C2', $result->{$oid_hrSystemDate};
|
||||||
|
my $timezone = 'UTC';
|
||||||
|
if (defined($self->{option_results}->{timezone})) {
|
||||||
|
$timezone = $self->{option_results}->{timezone};
|
||||||
|
} elsif (defined($remote_date[9])) {
|
||||||
|
$timezone = sprintf("%s%02d%02d", $remote_date[7], $remote_date[8], $remote_date[9]); # format +0630
|
||||||
|
}
|
||||||
|
|
||||||
my $dt = DateTime->new(
|
my $dt = DateTime->new(
|
||||||
year => $remote_date[0],
|
year => $remote_date[0],
|
||||||
month => $remote_date[1],
|
month => $remote_date[1],
|
||||||
|
@ -116,7 +124,7 @@ sub run {
|
||||||
hour => $remote_date[3],
|
hour => $remote_date[3],
|
||||||
minute => $remote_date[4],
|
minute => $remote_date[4],
|
||||||
second => $remote_date[5],
|
second => $remote_date[5],
|
||||||
time_zone => sprintf("%s%02d%02d", $remote_date[7], $remote_date[8], $remote_date[9]) , # format +0630
|
time_zone => $timezone,
|
||||||
);
|
);
|
||||||
$distant_time = $dt->epoch;
|
$distant_time = $dt->epoch;
|
||||||
|
|
||||||
|
@ -165,6 +173,11 @@ Set the ntp hostname (if not set, localtime is used).
|
||||||
|
|
||||||
Set the ntp port (Default: 123).
|
Set the ntp port (Default: 123).
|
||||||
|
|
||||||
|
=item B<--timezone>
|
||||||
|
|
||||||
|
Set the timezone of distant server. For Windows, you need to set it.
|
||||||
|
Can use format: 'Europe/London' or '+0100'.
|
||||||
|
|
||||||
=back
|
=back
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
Loading…
Reference in New Issue