archive disappeared nodes from device - really important!

This commit is contained in:
Oliver Gorwits
2014-01-13 18:43:59 +00:00
parent c09dddb7d1
commit cf23636ddf

View File

@@ -57,8 +57,8 @@ sub do_macsuck {
my $ip = $device->ip; my $ip = $device->ip;
# would be possible just to use now() on updated records, but by using this # would be possible just to use now() on updated records, but by using this
# same value for them all, we _can_ if we want add a job at the end to # same value for them all, we can if we want add a job at the end to
# select and do something with the updated set (no reason to yet, though) # select and do something with the updated set (see set archive, below)
my $now = 'to_timestamp('. (join '.', gettimeofday) .')'; my $now = 'to_timestamp('. (join '.', gettimeofday) .')';
my $total_nodes = 0; my $total_nodes = 0;
@@ -115,8 +115,18 @@ sub do_macsuck {
} }
} }
debug sprintf ' [%s] macsuck - %s forwarding table entries', debug sprintf ' [%s] macsuck - %s updated forwarding table entries',
$ip, $total_nodes; $ip, $total_nodes;
# a use for $now ... need to archive dissapeared nodes
my $archived = schema('netdisco')->resultset('Node')->search({
switch => $ip,
time_last => { '<' => \$now },
})->update({ active => \'false' });
debug sprintf ' [%s] macsuck - removed %s fwd table entries to archive',
$ip, $archived;
$device->update({last_macsuck => \$now}); $device->update({last_macsuck => \$now});
} }