From a4ec5a6951430479c627cd2f5550cb6966612c7b Mon Sep 17 00:00:00 2001 From: pyr0ball Date: Wed, 13 May 2026 04:58:51 -0700 Subject: [PATCH] feat: add UDP syslog receiver for network device log collection MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit scripts/syslog_receiver.py: asyncio UDP server listening on port 5140, appends raw syslog lines to network-syslog.txt for the Turnstone live watcher to tail. Requires no root — port 5140 is non-privileged. scripts/turnstone-syslog-receiver.service: systemd unit for auto-start. app/ingest/syslog.py: strip optional RFC 3164 prefix before parsing so network-forwarded syslog (OpenWRT logd, Arista EOS, etc.) is handled correctly without the PRI value breaking the regex. --- app/ingest/syslog.py | 7 +- scripts/syslog_receiver.py | 96 +++++++++++++++++++++++ scripts/turnstone-syslog-receiver.service | 19 +++++ 3 files changed, 120 insertions(+), 2 deletions(-) create mode 100644 scripts/syslog_receiver.py create mode 100644 scripts/turnstone-syslog-receiver.service diff --git a/app/ingest/syslog.py b/app/ingest/syslog.py index f82cf06..1bc9cd5 100644 --- a/app/ingest/syslog.py +++ b/app/ingest/syslog.py @@ -26,6 +26,8 @@ _MONTHS = { # May 11 14:23:01 hostname ident[pid]: message # May 1 04:00:00 hostname ident: message (no pid, day may be space-padded) +# <134>May 11 14:23:01 ... (optional RFC 3164 PRI prefix from network syslog) +_PRI_RE = re.compile(r"^<\d{1,3}>") _LINE_RE = re.compile( r"^(?PJan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)" r"\s+(?P\d{1,2})\s+(?P