Cleanup the old function.
This commit is contained in:
parent
2a1c06116b
commit
b05af57b54
|
@ -40,44 +40,6 @@ async def run_checks():
|
||||||
await send_msg(client, "```\n{}\n```".format(trace), force_notify=False)
|
await send_msg(client, "```\n{}\n```".format(trace), force_notify=False)
|
||||||
|
|
||||||
|
|
||||||
# check_journal checks the journal
|
|
||||||
async def check_journal():
|
|
||||||
print("\nChecking journal...")
|
|
||||||
|
|
||||||
# Get the systemd service name as an argument, or use "siad" as default.
|
|
||||||
service_name = "siad"
|
|
||||||
if len(sys.argv) > 2:
|
|
||||||
service_name = sys.argv[2]
|
|
||||||
|
|
||||||
# Get the systemd service name as an argument, or use "siad" as default.
|
|
||||||
check_interval = timedelta(hours=DEFAULT_CHECK_INTERVAL)
|
|
||||||
if len(sys.argv) > 3:
|
|
||||||
check_interval = timedelta(hours=int(sys.argv[3]))
|
|
||||||
|
|
||||||
now = datetime.now()
|
|
||||||
time = now - check_interval
|
|
||||||
time_string = "{}-{}-{} {}:{}:{}".format(time.year, time.month, time.day, time.hour, time.minute, time.second)
|
|
||||||
|
|
||||||
# Open the journal.
|
|
||||||
proc = Popen(["journalctl", "--user-unit", service_name, "--since", time_string], stdin=PIPE, stdout=PIPE, stderr=PIPE, text=True)
|
|
||||||
std_out, std_err = proc.communicate()
|
|
||||||
|
|
||||||
if len(std_err) > 0:
|
|
||||||
await send_msg(client, "Error reading journalctl output: {}".format(std_err), force_notify=True)
|
|
||||||
return
|
|
||||||
|
|
||||||
# If there are any critical errors. upload the whole log file.
|
|
||||||
if "Critical" in std_out or "panic" in std_out:
|
|
||||||
upload_name = "{}-{}-{}-{}-{}:{}:{}.log".format(service_name, time.year, time.month, time.day, time.hour, time.minute, time.second)
|
|
||||||
await send_msg(client, "Critical error found in log!", file=discord.File(io.BytesIO(std_out.encode()), filename=upload_name), force_notify=True)
|
|
||||||
return
|
|
||||||
|
|
||||||
# No critical errors, return a heartbeat type message
|
|
||||||
pretty_before = time.strftime("%I:%M%p")
|
|
||||||
pretty_now = now.strftime("%I:%M%p")
|
|
||||||
await send_msg(client, "No critical warnings in log from `{}` to `{}`".format(pretty_before, pretty_now))
|
|
||||||
|
|
||||||
|
|
||||||
# check_docker_logs checks the docker logs by filtering on the docker image name
|
# check_docker_logs checks the docker logs by filtering on the docker image name
|
||||||
async def check_docker_logs():
|
async def check_docker_logs():
|
||||||
print("\nChecking docker logs...")
|
print("\nChecking docker logs...")
|
||||||
|
|
Reference in New Issue