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...
This commit is contained in:
parent
aa1c2d0781
commit
0aae142c05
@ -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}
|
||||
|
Loading…
Reference in New Issue
Block a user