diff --git a/check_systemd_timer.py b/check_systemd_timer.py index 6d12903..07d897c 100755 --- a/check_systemd_timer.py +++ b/check_systemd_timer.py @@ -1,9 +1,12 @@ #!/usr/bin/env python3 - import argparse +import re +import subprocess import sys import traceback +from datetime import datetime +import humanfriendly from dateutil import tz from checker import nagios @@ -13,17 +16,11 @@ from checker.result import quit_check sys.path.insert(0, "/usr/lib/python3/dist-packages") import dbus -import re -import subprocess -from datetime import datetime - -import humanfriendly - SYSTEMCTL_TIMERS_RE = re.compile( r'^(([A-Za-z]*\s[0-9]{4}-[0-9]{2}-[0-9]{2}\s*[0-9]{2}:[0-9]{2}:[0-9]{2}\s[A-Z]*)|n\/a)\s*((([0-9]*[a-z]*\s)*left)|n\/a)\s*(([A-Za-z]*\s[0-9]{4}-[0-9]{2}-[0-9]{2}\s[0-9]{2}:[0-9]{2}:[0-9]{2}\s[A-Z]*)|n\/a)\s*(([0-9A-Za-z\s]*\sago)|n\/a)\s*([A-Za-z\-_]*.timer)\s*(([A-Za-z\-_]*.service)|\s*)') -def get_next_elapse(timer_name): +def get_next_elapse(timer_name) -> tuple[None, Exception] | tuple[dict, None]: try: output = subprocess.check_output(["systemctl", "list-timers", "--all"], universal_newlines=True) lines = output.split('\n')