Adds Banner and increases the timer

This commit is contained in:
2024-12-13 18:59:10 -05:00
parent 42b7bab201
commit df7b0034ed
2 changed files with 12 additions and 7 deletions

View File

@ -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

View File

@ -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,7 +127,16 @@ 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', []):
@ -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(