fix: Fixed arp-tables duplicate data (#8147)

Truncating the table here, because we could have a massive amount of duplicate rows which could cause php oom.
This commit is contained in:
Tony Murray
2018-01-24 14:51:00 -06:00
committed by Neil Lathwood
parent 0a6f113f5a
commit a98ab6363b
2 changed files with 12 additions and 4 deletions

View File

@ -42,10 +42,16 @@ foreach ($vrfs_lite_cisco as $vrf) {
$arp_data = snmpwalk_group($device, 'ipNetToMediaPhysAddress', 'IP-MIB', 1, $arp_data);
}
$existing_data = dbFetchRows(
"SELECT * from `ipv4_mac` WHERE `device_id`=? AND `context_name`=?",
array($device['device_id'], $context)
);
$sql = "SELECT * from `ipv4_mac` WHERE `device_id`=?";
$params = array($device['device_id']);
if (is_null($context)) {
$sql .= ' AND `context_name` IS NULL';
} else {
$sql .= ' AND `context_name`=?';
$params[] = $context;
}
$existing_data = dbFetchRows($sql, $params);
$ipv4_addresses = array_map(function ($data) {
return $data['ipv4_address'];
}, $existing_data);

2
sql-schema/232.sql Normal file
View File

@ -0,0 +1,2 @@
TRUNCATE `ipv4_mac`;