From 0aae142c052c3d28359e518ad94745cdad13d7e0 Mon Sep 17 00:00:00 2001 From: Fredrik Eriksson Date: Sat, 13 Jul 2024 20:55:45 +0200 Subject: [PATCH] remove systemctl status output from email. I can't seem to find a way to allow systemctl status in combination with DynamicUser= for the sysalert service... --- sysalert/email.py | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/sysalert/email.py b/sysalert/email.py index 5d6fd80..ec22478 100644 --- a/sysalert/email.py +++ b/sysalert/email.py @@ -1,20 +1,9 @@ import email import smtplib import socket -import subprocess import systemd.journal -def _get_status(name): - cmd = ['/usr/bin/systemctl', 'status', name] - - proc = subprocess.Popen( - cmd, - stdout=subprocess.PIPE) - out, err = proc.communicate() - out = out.decode('utf-8') - return out - def _send_email(subject, message, config): mail = email.message.EmailMessage() hostname = socket.getfqdn() @@ -44,9 +33,6 @@ def success(name, failures, config): subject=f'{hostname} - {name}: recovery' message=f""" {name} has recovered after {nr_failures} failures. -Current status: - -{cur_status} """ _send_email(subject, message, config) @@ -72,11 +58,6 @@ def failure(name, failures, config): subject=f"{hostname} - {name}: failure" message=f""" New failure for {name}. -Current status: - -{cur_status} - - Latest journal log: {journal_txt} @@ -85,11 +66,6 @@ Latest journal log: subject=f"{hostname} - {name}: {nr_failures} failures" message=f""" {nr_failures} failures for {name} ({prev_failures} since last notification). -Current status: - -{cur_status} - - Latest journal log: {journal_txt}