fix(snmp): ARP表缺少发现时间字段,在get_arp_table返回值中添加last_seen和discovered_at
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -221,18 +221,20 @@ class SNMPService:
|
||||
arp_data[ip_address]['if_index'] = if_index
|
||||
|
||||
# 转换为列表
|
||||
now = datetime.utcnow()
|
||||
for ip, data in arp_data.items():
|
||||
if 'mac_address' in data:
|
||||
entry = {
|
||||
'ip_address': ip,
|
||||
'mac_address': data.get('mac_address'),
|
||||
'interface': str(data.get('if_index', '')),
|
||||
'device_id': device.id
|
||||
'device_id': device.id,
|
||||
'last_seen': now.isoformat(),
|
||||
'discovered_at': now.isoformat()
|
||||
}
|
||||
arp_entries.append(entry)
|
||||
|
||||
# 保存到数据库
|
||||
now = datetime.utcnow()
|
||||
for entry_data in arp_entries:
|
||||
# 查找是否已存在
|
||||
existing = db.query(ARPEntry).filter(
|
||||
|
||||
Reference in New Issue
Block a user