Last active
August 11, 2022 17:29
-
-
Save froop/045a77b81f2c6d07c80147ef8bbdb6da to your computer and use it in GitHub Desktop.
[Python] syslog minimum client
This file contains hidden or 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 python3 | |
import socket | |
import datetime | |
now = datetime.datetime.now().strftime('%b %d %H:%M:%S') | |
msg = '<34>%s testhost TestTCP: aaa111' % now | |
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
sock.connect(('127.0.0.1', 514)) | |
sock.sendall(msg.encode('utf-8')) | |
sock.close() |
This file contains hidden or 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 python3 | |
import socket | |
import datetime | |
now = datetime.datetime.now().strftime('%b %d %H:%M:%S') | |
msg = '<34>%s testhost TestUDP: aaa111' % now | |
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) | |
sock.sendto(msg.encode('utf-8'), ('127.0.0.1', 514)) | |
sock.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment