Debian Codegraph @

src/network/dell/nseries/snmp/mode/time.pm

raw
1 #
2 # Copyright 2024 Centreon (http://www.centreon.com/)
3 #
4 # Centreon is a full-fledged industry-strength solution that meets
5 # the needs in IT infrastructure and application monitoring for
6 # service performance.
7 #
8 # Licensed under the Apache License, Version 2.0 (the "License");
9 # you may not use this file except in compliance with the License.
10 # You may obtain a copy of the License at
11 #
12 # http://www.apache.org/licenses/LICENSE-2.0
13 #
14 # Unless required by applicable law or agreed to in writing, software
15 # distributed under the License is distributed on an "AS IS" BASIS,
16 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 # See the License for the specific language governing permissions and
18 # limitations under the License.
19 #
20
21 package network::dell::nseries::snmp::mode::time;
22
23 use base qw(snmp_standard::mode::ntp);
24
25 use strict;
26 use warnings;
27 use Date::Parse;
28
29 sub get_target_time {
30 my ($self, %options) = @_;
31
32 my $oid_agentSystemTime = '.1.3.6.1.4.1.674.10895.5000.2.6132.1.1.42.1.1.0';
33 my $oid_agentSystemDate = '.1.3.6.1.4.1.674.10895.5000.2.6132.1.1.42.1.2.0';
34 my $snmp_result = $options{snmp}->get_leef(oids => [ $oid_agentSystemTime, $oid_agentSystemDate ], nothing_quit => 1);
35
36 my $epoch = Date::Parse::str2time($snmp_result->{$oid_agentSystemDate} . ' ' . $snmp_result->{$oid_agentSystemTime});
37 return $self->get_from_epoch(date => $epoch);
38 }
39
40 1;
41
42 __END__
43
44 =head1 MODE
45
46 Check time offset of server with ntp server. Use local time if ntp-host option is not set.
47 SNMP gives a date with second precision (no milliseconds). Time precision is not very accurate.
48 Use threshold with (+-) 2 seconds offset (minimum).
49
50 =over 8
51
52 =item B<--warning-offset>
53
54 Time offset warning threshold (in seconds).
55
56 =item B<--critical-offset>
57
58 Time offset critical Threshold (in seconds).
59
60 =item B<--ntp-hostname>
61
62 Set the ntp hostname (if not set, localtime is used).
63
64 =item B<--ntp-port>
65
66 Set the ntp port (default: 123).
67
68 =item B<--timezone>
69
70 Set the timezone of distant server. For Windows, you need to set it.
71 Can use format: 'Europe/London' or '+0100'.
72
73 =back
74
75 =cut