mirror of
https://github.com/centreon/centreon-plugins.git
synced 2025-07-28 16:14:21 +02:00
+ Fix ntp time snmp mode
This commit is contained in:
parent
1b6e876639
commit
2794c628de
@ -61,6 +61,7 @@ sub new {
|
|||||||
'processcount' => 'snmp_standard::mode::processcount',
|
'processcount' => 'snmp_standard::mode::processcount',
|
||||||
'storage' => 'snmp_standard::mode::storage',
|
'storage' => 'snmp_standard::mode::storage',
|
||||||
'swap' => 'snmp_standard::mode::swap',
|
'swap' => 'snmp_standard::mode::swap',
|
||||||
|
'time' => 'snmp_standard::mode::ntp',
|
||||||
'tcpcon' => 'snmp_standard::mode::tcpcon',
|
'tcpcon' => 'snmp_standard::mode::tcpcon',
|
||||||
'traffic' => 'snmp_standard::mode::traffic',
|
'traffic' => 'snmp_standard::mode::traffic',
|
||||||
'uptime' => 'snmp_standard::mode::uptime',
|
'uptime' => 'snmp_standard::mode::uptime',
|
||||||
|
@ -81,7 +81,7 @@ sub run {
|
|||||||
# $options{snmp} = snmp object
|
# $options{snmp} = snmp object
|
||||||
$self->{snmp} = $options{snmp};
|
$self->{snmp} = $options{snmp};
|
||||||
|
|
||||||
my $ref_time, $distant_time;
|
my ($ref_time, $distant_time);
|
||||||
my $oid_hrSystemDate = '.1.3.6.1.2.1.25.1.2.0';
|
my $oid_hrSystemDate = '.1.3.6.1.2.1.25.1.2.0';
|
||||||
my $result = $self->{snmp}->get_leef(oids => [ $oid_hrSystemDate ]);
|
my $result = $self->{snmp}->get_leef(oids => [ $oid_hrSystemDate ]);
|
||||||
if (scalar(keys %$result) == 0) {
|
if (scalar(keys %$result) == 0) {
|
||||||
@ -94,7 +94,7 @@ sub run {
|
|||||||
my %ntp;
|
my %ntp;
|
||||||
|
|
||||||
eval {
|
eval {
|
||||||
%ntp = Net::NTP::get_ntp_resonse($self->{option_results}->{ntp_hostname}, $self->{option_results}->{ntp_port});
|
%ntp = Net::NTP::get_ntp_response($self->{option_results}->{ntp_hostname}, $self->{option_results}->{ntp_port});
|
||||||
};
|
};
|
||||||
if ($@) {
|
if ($@) {
|
||||||
$self->{output}->output_add(severity => 'UNKNOWN',
|
$self->{output}->output_add(severity => 'UNKNOWN',
|
||||||
@ -125,7 +125,7 @@ sub run {
|
|||||||
my $exit = $self->{perfdata}->threshold_check(value => $diff,
|
my $exit = $self->{perfdata}->threshold_check(value => $diff,
|
||||||
threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
|
threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
|
||||||
$self->{output}->output_add(severity => $exit,
|
$self->{output}->output_add(severity => $exit,
|
||||||
short_msg => sprintf("Time offset %d", $diff));
|
short_msg => sprintf("Time offset %d second(s)", $diff));
|
||||||
|
|
||||||
$self->{output}->perfdata_add(label => 'offset', unit => 's',
|
$self->{output}->perfdata_add(label => 'offset', unit => 's',
|
||||||
value => sprintf("%d", $diff),
|
value => sprintf("%d", $diff),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user