Added support for auto purging deleted ports (#8861)

This commit is contained in:
Neil Lathwood
2018-07-03 14:27:20 +01:00
committed by Tony Murray
parent faba6d9d02
commit d9ceaf7830
3 changed files with 24 additions and 2 deletions

View File

@@ -112,6 +112,26 @@ if ($options['f'] === 'device_perf') {
exit($ret);
}
if ($options['f'] === 'ports_purge') {
try {
if (Config::get('distributed_poller')) {
MemcacheLock::lock('ports_purge', 0, 86000);
}
$ports_purge = Config::get('ports_purge');
if ($ports_purge) {
$interfaces = dbFetchRows('SELECT * from `ports` AS P, `devices` AS D WHERE `deleted` = 1 AND D.device_id = P.device_id');
foreach ($interfaces as $interface) {
delete_port($interface['port_id']);
}
echo "All deleted ports now purged\n";
}
} catch (LockException $e) {
echo $e->getMessage() . PHP_EOL;
exit(-1);
}
}
if ($options['f'] === 'handle_notifiable') {
if ($options['t'] === 'update') {
$title = 'Error: Daily update failed';