Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion suzieq/poller/worker/services/arpnd.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def _clean_panos_data(self, processed_data, _):
# ARP entries are shown with status as merely a letter while
# ND entries are shown with the status as a self-respecting word.
# sigh
state = entry.get("state", "").lower()
state = (entry.get("state") or "").lower()
if state in ["s", "static"]:
entry["state"] = "permanent"
elif state in ["c", "e", "stale", "reachable"]:
Expand Down
27 changes: 23 additions & 4 deletions suzieq/poller/worker/services/interfaces.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import re
from datetime import datetime
from collections import defaultdict
from json import loads
from json import loads, JSONDecodeError
from typing import Dict
import numpy as np

Expand Down Expand Up @@ -993,13 +993,32 @@ def _clean_panos_data(self, processed_data, _):

# mtu values are collected separatly
if _mtu_data:
try:
_, json_blob = _mtu_data.split(": ", 1)
except ValueError:
self.logger.warning(
"Unexpected panos MTU data format: %s", _mtu_data)
continue

# fix json so that it can be parsed
d = _mtu_data.split(": ", 1)[1].replace("'", "\"")
d = json_blob.replace("'", "\"")
d = re.sub(
r"([a-fA-F0-9]{2}(:[a-fA-F0-9]{2}){5})", r'"\1"', d)
d = re.sub(r"(\"[\w0-9\.\/]+\": \{\s\},\s)", r"", d)
d = re.sub(r"(,\s\})", r" }", d)
j = loads(d)
d = re.sub(r"(,\s\})", r" }", d).strip()

if not d:
self.logger.warning(
"Empty panos MTU data after cleanup: %s", _mtu_data)
continue

try:
j = loads(d)
except JSONDecodeError: # pragma: no cover - defensive
self.logger.warning(
"Unable to parse panos MTU data: %s", d)
continue

for ifname, value in j.items():
mtu_data[ifname] = value["mtu"]
continue
Expand Down