Add interface information handling and update Zabbix formatting

- Introduced InterfaceInfo class to encapsulate interface details.
- Modified CiscoMacTableParser to gather and store interface information.
- Updated ZabbixLLDFormatter to include interface status and descriptions in the output.
- Adjusted test_new_format.py to validate new interface information integration.
- Enhanced run.sh for improved container management.
This commit is contained in:
Xavier Rodriguez
2026-03-09 15:21:48 +01:00
parent f12e236e82
commit 6782aa47d1
5 changed files with 160 additions and 50 deletions
+11 -2
View File
@@ -7,7 +7,7 @@ import sys
import os
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
from cisco_mac_monitor import MacEntry, ZabbixLLDFormatter
from cisco_mac_monitor import MacEntry, InterfaceInfo, ZabbixLLDFormatter
import json
# Crear datos de prueba
@@ -17,9 +17,16 @@ test_mac_entries = [
MacEntry(vlan="151", mac_address="00:50:56:a6:91:69", type="DYNAMIC", port="Gi1/0/10"),
]
# Crear información de interfaces de prueba (incluye estado y descripción)
test_interface_info = {
"Gi1/0/1": InterfaceInfo(name="Gi1/0/1", status="up", description="User Port - Office"),
"Gi1/0/10": InterfaceInfo(name="Gi1/0/10", status="up", description="Server Link"),
"Gi1/0/11": InterfaceInfo(name="Gi1/0/11", status="down", description="Unused Port"),
}
# Crear formatter y formatear datos
formatter = ZabbixLLDFormatter("10.150.250.2")
result = formatter.format_for_zabbix(test_mac_entries, ["Gi1/0/1", "Gi1/0/10", "Gi1/0/11"])
result = formatter.format_for_zabbix(test_mac_entries, test_interface_info)
# Mostrar resultado
print(json.dumps(result, indent=2, ensure_ascii=False))
@@ -39,5 +46,7 @@ for item in data:
print(f" - Count: {port_data['count']}")
print(f" - VLANs: '{port_data['vlans']}'")
print(f" - Addresses: '{port_data['addresses']}'")
print(f" - Status: '{port_data['status']}'")
print(f" - Description: '{port_data['description']}'")
print(f" - Timestamp: {port_data['timestamp']}")
print()