From df7b0034ed6aaab5435f53a2425a80bd5e525a27 Mon Sep 17 00:00:00 2001 From: Jared Vititoe Date: Fri, 13 Dec 2024 18:59:10 -0500 Subject: [PATCH] Adds Banner and increases the timer --- hwmon.timer | 5 ++--- hwmonDaemon.py | 14 ++++++++++---- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/hwmon.timer b/hwmon.timer index d4ac957..be07167 100644 --- a/hwmon.timer +++ b/hwmon.timer @@ -2,9 +2,8 @@ Description=Run System Health Monitoring Daemon Daily [Timer] -OnCalendar=daily -RandomizedDelaySec=1h -Persistent=true +OnCalendar=hourly +RandomizedDelaySec=300 [Install] WantedBy=timers.target \ No newline at end of file diff --git a/hwmonDaemon.py b/hwmonDaemon.py index 417b24a..fec9ed5 100644 --- a/hwmonDaemon.py +++ b/hwmonDaemon.py @@ -37,7 +37,6 @@ class SystemHealthMonitor: } CONFIG = { 'TICKET_API_URL': 'http://10.10.10.45/create_ticket_api.php', - 'STATE_FILE': '/tmp/last_health_check.json', 'THRESHOLDS': { 'DISK_CRITICAL': 90, 'DISK_WARNING': 80, @@ -65,7 +64,6 @@ class SystemHealthMonitor: def __init__(self, ticket_api_url: str = 'http://10.10.10.45/create_ticket_api.php', - state_file: str = '/tmp/last_health_check.json', dry_run: bool = False): """ Initialize the system health monitor. @@ -129,8 +127,17 @@ class SystemHealthMonitor: :param health_report: The comprehensive health report from the checks. :return: A detailed description for the issue. """ - description = issue + "\n\n" + banner = """ + ================================================================= + AUTOMATED TICKET - Generated by Hardware Monitoring Service (hwmonDaemon) + Host: {} + Generated: {} + ================================================================= + """.format(socket.gethostname(), datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")) + + description = banner + issue + "\n\n" + if "Disk" in issue: for partition in health_report.get('drives_health', {}).get('drives', []): if partition.get('mountpoint') in issue: @@ -599,7 +606,6 @@ def main(): # Parse command-line arguments or read from configuration file ticket_api_url = "http://10.10.10.45/create_ticket_api.php" - state_file = "/tmp/last_health_check.json" # Instantiate the SystemHealthMonitor class monitor = SystemHealthMonitor(