archive disappeared nodes from device - really important!
This commit is contained in:
@@ -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});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user