Track how many times the device uptime wrapped (F. Schiavarelli)

This commit is contained in:
Oliver Gorwits
2014-07-01 20:46:34 +01:00
parent 30b234848d
commit d6f2d357cc
2 changed files with 14 additions and 2 deletions

View File

@@ -216,9 +216,20 @@ sub store_interfaces {
# clear the cached uptime and get a new one
my $dev_uptime = $snmp->load_uptime;
# used to track whether we've wrapped the device uptime
# used to track how many times the device uptime wrapped
my $dev_uptime_wrapped = 0;
# use SNMP-FRAMEWORK-MIB::snmpEngineTime if available to
# fix device uptime if wrapped
if (defined $snmp->snmpEngineTime) {
$dev_uptime_wrapped = int( $snmp->snmpEngineTime * 100 / 2**32 );
if ($dev_uptime_wrapped > 0) {
info sprintf ' [%s] interface - device uptime wrapped %d times - correcting',
$device->ip, $dev_uptime_wrapped;
$device->uptime( $dev_uptime + $dev_uptime_wrapped * 2**32 );
}
}
# build device interfaces suitable for DBIC
my %interfaces;
foreach my $entry (keys %$interfaces) {
@@ -264,7 +275,7 @@ sub store_interfaces {
debug sprintf
' [%s] interfaces - correcting LastChange for %s, assuming sysUptime wrap',
$device->ip, $port;
$lc += 2**32;
$lc += $dev_uptime_wrapped * 2**32;
}
}
}