Mon Jun 10 04:56:55 PM CEST 2024
This commit is contained in:
parent
3dc765ce26
commit
723ebeeedd
|
@ -8,11 +8,20 @@ let
|
|||
import sys
|
||||
import socket
|
||||
import subprocess
|
||||
import tempfile
|
||||
|
||||
|
||||
async def run():
|
||||
text = subprocess.check_output(
|
||||
["journalctl", "--user", "-u", sys.argv[1], "-b"]
|
||||
[
|
||||
"journalctl",
|
||||
"--user",
|
||||
"-u",
|
||||
sys.argv[1],
|
||||
"--since",
|
||||
"-1h",
|
||||
"--no-pager"
|
||||
]
|
||||
).decode("utf-8")
|
||||
|
||||
with open("/home/server/mail.log", "a") as f:
|
||||
|
@ -27,7 +36,10 @@ let
|
|||
f"{hostname} encountered an error in the service: {sys.argv[1]}"
|
||||
)
|
||||
|
||||
await bot.send_message(chat_id, text)
|
||||
with tempfile.NamedTemporaryFile(suffix=".txt") as tmp_file:
|
||||
tmp_file.write(text.encode("utf-8"))
|
||||
tmp_file.seek(0)
|
||||
await bot.send_document(chat_id, document=tmp_file)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
Loading…
Reference in New Issue