Created
February 5, 2022 07:43
-
-
Save core2duoe6420/3361c0ed7d9a654bd056f3c953d10767 to your computer and use it in GitHub Desktop.
A python script to follow Linksys Velop's log printed by sysinfo.cgi
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
import requests | |
import time | |
from datetime import datetime, timedelta | |
from requests.auth import HTTPBasicAuth | |
last_time = datetime.min | |
last_message = '' | |
while True: | |
basic = HTTPBasicAuth('admin', '${velop_password}') | |
r = requests.get('http:/${velop_address}/sysinfo.cgi', stream=True, auth=basic, headers={'Connection':'close'}) | |
start_log = False | |
for line in r.iter_lines(): | |
if not line: | |
continue | |
line = line.decode('utf-8') | |
if 'tail -200 /var/log/messages' in line: | |
start_log = True | |
continue | |
if line.startswith('====='): | |
break | |
if not start_log: | |
continue | |
dt = datetime.strptime(line[:15], '%b %d %H:%M:%S') | |
dt = dt.replace(year=2022) | |
if last_time != datetime.min and dt > last_time and (dt - last_time).seconds >= 360: | |
# Sometimes the timestamp is not UTC and is actually a few seconds ealier than last_time... | |
dt = last_time | |
message = line[15:].strip() | |
if dt < last_time or (dt == last_time and message == last_message): | |
continue | |
if 'EthUtil returns multiple MACs' not in line: | |
print(line) | |
last_time = dt | |
last_message = message | |
r.close() | |
time.sleep(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment