Python – Tail & Ship Logs to HTTP

Below is a ready-to-use script. Review and adapt variables to your environment.

#!/usr/bin/env python3
import requests, time, sys
url = sys.argv[1]; path = sys.argv[2]
with open(path) as f:
    f.seek(0,2)
    while True:
        line = f.readline()
        if not line:
            time.sleep(0.5); continue
        requests.post(url, data={'line': line})
  

← Back to SQL