Last active
December 24, 2015 02:29
-
-
Save IlyaSemenov/6730474 to your computer and use it in GitHub Desktop.
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 | |
import subprocess | |
SYSLOG_HOST = "graylog2.local" | |
SYSLOG_PORT = 514 | |
LOG_FILE = "/var/log/nginx/access.log" | |
pipe = subprocess.Popen(["tail", "-n0", "-F", "-q", LOG_FILE], stdout=subprocess.PIPE).stdout | |
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) | |
while True: | |
line = pipe.readline() | |
if not line: | |
break | |
line = line.rstrip() | |
message = "<181>nginx: "+line # 181 is local6 (reverse engineered) | |
sock.sendto(message, (SYSLOG_HOST, SYSLOG_PORT)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment