diff --git a/Netdisco/Changes b/Netdisco/Changes index 5e9377da..7d2ffff5 100644 --- a/Netdisco/Changes +++ b/Netdisco/Changes @@ -7,6 +7,7 @@ * [#164] Workers should restart periodically * [#168] Jobs requested via web UI are treated as high priority * [#162] Change from Net::MAC to NetAddr::MAC + * [#159] Macsuck archive behaviour same as ND1 (unseen nodes remain active) * Add "Run Expire Job" to the Admin Menu [BUG FIXES] diff --git a/Netdisco/lib/App/Netdisco/Core/Macsuck.pm b/Netdisco/lib/App/Netdisco/Core/Macsuck.pm index 042f28e9..1cde1cc4 100644 --- a/Netdisco/lib/App/Netdisco/Core/Macsuck.pm +++ b/Netdisco/lib/App/Netdisco/Core/Macsuck.pm @@ -112,10 +112,15 @@ sub do_macsuck { $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' }); + my $archived = 0; + + if (setting('node_freshness')) { + $archived = schema('netdisco')->resultset('Node')->search({ + switch => $ip, + time_last => \[ "< ($now - ?::interval)", + setting('node_freshness') .' minutes' ], + })->update({ active => \'false' }); + } debug sprintf ' [%s] macsuck - removed %d fwd table entries to archive', $ip, $archived; diff --git a/Netdisco/lib/App/Netdisco/Manual/Configuration.pod b/Netdisco/lib/App/Netdisco/Manual/Configuration.pod index ebee0c90..8122008f 100644 --- a/Netdisco/lib/App/Netdisco/Manual/Configuration.pod +++ b/Netdisco/lib/App/Netdisco/Manual/Configuration.pod @@ -741,6 +741,21 @@ Value: Number. Default: 1. Seconds nbtstat will wait for a response before time out. Accepts fractional seconds as well as integers. +=head3 C + +Value: Number of Minutes. Default: 0 + +Controls the behaviour of Netdisco when a node (workstation, printer, etc) has +disappeared from the network (device MAC address tables). + +If set to 0, the default, nodes will remain on the last-seen switch port until +"C" days have passed (when they'll be deleted if you run the +Expire job). This is the same behaviour as Netdisco 1. + +Set to a number of minutes to enforce some kind of ageing on this data. For +example you could set to 60 to match the default macsuck schedule, meaning +nodes are archived if they're not in the device tables at the time of polling. + =head3 C Value: Number of Days. Default: 60 diff --git a/Netdisco/share/config.yml b/Netdisco/share/config.yml index 7e14a201..fdbf2f5f 100644 --- a/Netdisco/share/config.yml +++ b/Netdisco/share/config.yml @@ -130,6 +130,7 @@ nbtstat_only: [] nbtstat_max_age: 7 nbtstat_interval: 0.02 nbtstat_timeout: 1 +node_freshness: 0 expire_devices: 60 expire_nodes: 90 expire_nodes_archive: 60