Created
May 27, 2022 06:36
-
-
Save barbudor/2f860f53bcb7131f538ceeb3db4142dc to your computer and use it in GitHub Desktop.
Dead simple syslog receiver and logger in Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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