better defaults for freebox parsing issue #927

This commit is contained in:
jokob-sk
2025-01-03 22:27:56 +11:00
parent 4aa18691f4
commit 93886cec8a

View File

@@ -152,16 +152,17 @@ def main():
if "l3connectivities" in host and isinstance(host["l3connectivities"], list): if "l3connectivities" in host and isinstance(host["l3connectivities"], list):
for ip in [ip for ip in host["l3connectivities"] if ip.get("reachable")]: for ip in [ip for ip in host["l3connectivities"] if ip.get("reachable")]:
mac: str = host.get("l2ident", {}).get("id", "(unknown)") mac: str = host.get("l2ident", {}).get("id", "(unknown)")
plugin_objects.add_object( if mac != '(unknown)':
primaryId=mac, plugin_objects.add_object(
secondaryId=ip.get("addr", "(unknown)"), primaryId=mac,
watched1=host.get("primary_name", "(unknown)"), secondaryId=ip.get("addr", "0.0.0.0"),
watched2=host.get("vendor_name", "(unknown)"), watched1=host.get("primary_name", "(unknown)"),
watched3=map_device_type(host.get("host_type", "unknown")), watched2=host.get("vendor_name", "(unknown)"),
watched4=datetime.fromtimestamp(ip.get("last_time_reachable", 0)), watched3=map_device_type(host.get("host_type", "")),
extra="", watched4=datetime.fromtimestamp(ip.get("last_time_reachable", 0)),
foreignKey=mac, extra="",
) foreignKey=mac,
)
else: else:
# Optional: Log or handle hosts without 'l3connectivities' # Optional: Log or handle hosts without 'l3connectivities'
mylog("verbose", [f"[{pluginName}] Host missing 'l3connectivities': {host}"]) mylog("verbose", [f"[{pluginName}] Host missing 'l3connectivities': {host}"])