Skip to content

Instantly share code, notes, and snippets.

@barbudor
Created May 27, 2022 06:36
Show Gist options
  • Save barbudor/2f860f53bcb7131f538ceeb3db4142dc to your computer and use it in GitHub Desktop.
Save barbudor/2f860f53bcb7131f538ceeb3db4142dc to your computer and use it in GitHub Desktop.
Dead simple syslog receiver and logger in Python
#! /usr/bin/env python
import socket
from datetime import datetime
UDP_IP = "0.0.0.0"
UDP_PORT = 5140
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.bind((UDP_IP, UDP_PORT))
while True:
data, addr = sock.recvfrom(1600)
t = datetime.now()
print( "%s: %s" % (t.strftime("%Y-%m-%d %H:%M:%S.%f"), data.decode()))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment