- Deleted old configuration file (config.yaml) containing device and monitoring settings. - Removed outdated Docker Compose file (docker-compose.yml) for container setup. - Eliminated entrypoint script (entrypoint.sh) that handled container initialization and command processing. - Cleared example output JSON file (example_output.json) used for testing. - Removed test suite script (test_suite.sh) that validated the project structure and functionality. - Deleted Zabbix integration script (zabbix_integration.sh) for external script execution. - Removed Zabbix template examples (zabbix_template_examples.md) for monitoring setup. - Updated permissions for run.sh and test_new_format.py scripts.
43 lines
1.3 KiB
Python
Executable File
43 lines
1.3 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""
|
|
Test script para verificar el nuevo formato JSON
|
|
"""
|
|
|
|
import sys
|
|
import os
|
|
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
|
|
|
|
from cisco_mac_monitor import MacEntry, ZabbixLLDFormatter
|
|
import json
|
|
|
|
# Crear datos de prueba
|
|
test_mac_entries = [
|
|
MacEntry(vlan="600", mac_address="f0:8e:db:2e:4d:86", type="DYNAMIC", port="Gi1/0/1"),
|
|
MacEntry(vlan="601", mac_address="f0:8e:db:2e:4d:86", type="DYNAMIC", port="Gi1/0/1"),
|
|
MacEntry(vlan="151", mac_address="00:50:56:a6:91:69", type="DYNAMIC", port="Gi1/0/10"),
|
|
]
|
|
|
|
# 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"])
|
|
|
|
# Mostrar resultado
|
|
print(json.dumps(result, indent=2, ensure_ascii=False))
|
|
|
|
# Verificar estructura esperada
|
|
print("\n" + "="*50)
|
|
print("VERIFICACIÓN DE ESTRUCTURA:")
|
|
print("="*50)
|
|
|
|
data = result["data"]
|
|
print(f"✓ Total de puertos: {len(data)}")
|
|
|
|
for item in data:
|
|
port = item["port"]
|
|
port_data = item["data"]
|
|
print(f"✓ Puerto {port}:")
|
|
print(f" - Count: {port_data['count']}")
|
|
print(f" - VLANs: '{port_data['vlans']}'")
|
|
print(f" - Addresses: '{port_data['addresses']}'")
|
|
print(f" - Timestamp: {port_data['timestamp']}")
|
|
print() |