Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
  • While working with SNMPv3 with a specific SNMP agent, we encountered problems with SNMPv3 “Time synchronization”, some research determined that this error could be ignored, so modifying the Net::SNMP Perl library could workaround this problem.
  • If you encounter the 'Time synchronization failed during discovery' error using the perl Net::SNMP library there may be a fairly easy

...

  • work around.

...

  •  It may be as easy as editing the Net::SNMP module to not invoke this error.

...

  •  The following advice should be executed as root.
  • The following was done with the Net::SNMP Version 6.0.1 package.  If this library is upgraded, this patch may need to be reapplied.

Find Net::SNMP

In order to find where Net::SNMP is on the subject system issue the following command.

...

The @INC array is a list of directories that perl looks in to find modules.  This is a top down, first match find operation.  Based on this the version in /usr/local/share/perl5/Net will be utilized because it will be found first.

Edit Net::SNMP

Always make a backup of a module prior to editing it.  In order to prevent Net::SNMP from failing due to this error we edited it in the following fashion.

We were able to get the agent to work by doing the following:

  • Commenting out part of the if statement on line 2545. (The if statement will need to be re-written)
  • Commenting out lines 2562 through 2565.
Code Block
titleSNMP.pm v5.2.0
2544    if (($this->{_security}->discovered) &&
2545        ($this->{_error} =~ /usmStatsNotInTimeWindows/))
2546    {
2547       $this->_error_clear;
2548 
2549       DEBUG_INFO('discovery and synchronization complete');
2550 
2551       # Discovery is complete, send any pending messages
2552       while (my $q = shift(@{$this->{_discovery_queue}})) {
2553          $DISPATCHER->send_pdu(@{$q});
2554       }
2555 
2556       return TRUE;
2557    }
2558 
2559
Code Block
$ diff -bu SNMP.pm.original SNMP.pm.patched 
--- SNMP.pm.original    2018-01-26 08:36:28.833348881 +0900
+++ SNMP.pm.patched     2018-01-26 14:25:42.798070662 +0900
@@ -2617,8 +2617,9 @@
    # counter in the varBindList..."  If another error is returned, we 
    # assume that the synchronization has failed.
 
-   if (($this->{_security}->discovered()) &&
-       ($this->{_error} =~ /usmStatsNotInTimeWindows/))
+   if ($this->{_security}->discovered())
+   #if (($this->{_security}->discovered()) &&
+   #    ($this->{_error} =~ /usmStatsNotInTimeWindows/))
    {
       $this->_error_clear();
       DEBUG_INFO('discovery and synchronization complete');
@@ -2628,10 +2629,10 @@
    # If we received the usmStatsNotInTimeWindows report or no error, but 
2560    # we are still not synchronized, provide a generic error message.
2561 
-2562    if ((!$this->{_error}) || ($this->{_error} =~ /usmStatsNotInTimeWindows/)) {
-2563       $this->_error_clear();
-2564       $this->_error('Time synchronization failed during discovery');
-2565   }
+   #if ((!$this->{_error}) || ($this->{_error} =~ /usmStatsNotInTimeWindows/)) {
+   #   $this->_error_clear();
+   #   $this->_error('Time synchronization failed during discovery');
+   #}
 
    DEBUG_INFO('synchronization failed');

Complete files:

...