Files
monitor/addEvent.py
2025-03-24 21:33:34 +00:00

27 lines
626 B
Python

'''
send a text to the local event-log
usage as library or from the CLI:
python3 addEvent.py "ERROR,key,timeout,count, text"
'''
import sys
import socket
def send_event(text):
'''
text must be a str
'''
host = "localhost"
port = 1234 # The same port as used by the server
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((host, port))
s.sendall(bytes(text, 'utf-8'))
# data = s.recv(1024) # nothing should be returned....
s.close()
if __name__ == "__main__":
if len(sys.argv) > 1:
send_event(sys.argv[1].encode('utf-8'))