@@ -218,6 +218,14 @@ private function getPeers( int $vlan, int $protocol = 6, bool $restrictActivePee
218218 return $ apeers ;
219219 }
220220
221+ // the number of days back we look is not a perfect science. generally, the bigger the interface / more
222+ // traffic, the less likely we'll find bgp sessions recently via sflow sampling.
223+ // 28 days seems good in practice but his can be changed in config/ixp.php
224+ $ lookback_days = (int )config ( 'ixp.peering-matrix.lookback_days ' );
225+ if ( !is_int ( $ lookback_days ) || $ lookback_days < 1 ) {
226+ $ lookback_days = 30 ;
227+ }
228+
221229 // we've added "bs.timestamp >= NOW() - INTERVAL 7 DAY" below as we don't
222230 // dump old date (yet) and the time to run the query is O(n) on number
223231 // of rows...
@@ -237,7 +245,7 @@ private function getPeers( int $vlan, int $protocol = 6, bool $restrictActivePee
237245 ->leftJoin ( 'cust AS cs ' , 'cs.id ' , 'vis.custid ' )
238246 ->leftJoin ( 'cust AS cd ' , 'cd.id ' , 'vid.custid ' )
239247 ->leftJoin ( 'vlan ' , 'vlan.id ' , 'srcip.vlanid ' )
240- ->whereRaw ( 'bs.last_seen >= NOW() - INTERVAL 7 DAY ' )
248+ ->whereRaw ( 'bs.last_seen >= NOW() - INTERVAL ' . $ lookback_days . ' DAY ' )
241249 ->where ( 'bs.protocol ' , $ protocol )
242250 ->where ( 'bs.packetcount ' , '>= ' , 1 )
243251 ->where ( 'vlan.id ' , $ vlan )
0 commit comments