Adds Banner and increases the timer
This commit is contained in:
@ -2,9 +2,8 @@
|
|||||||
Description=Run System Health Monitoring Daemon Daily
|
Description=Run System Health Monitoring Daemon Daily
|
||||||
|
|
||||||
[Timer]
|
[Timer]
|
||||||
OnCalendar=daily
|
OnCalendar=hourly
|
||||||
RandomizedDelaySec=1h
|
RandomizedDelaySec=300
|
||||||
Persistent=true
|
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=timers.target
|
WantedBy=timers.target
|
||||||
@ -37,7 +37,6 @@ class SystemHealthMonitor:
|
|||||||
}
|
}
|
||||||
CONFIG = {
|
CONFIG = {
|
||||||
'TICKET_API_URL': 'http://10.10.10.45/create_ticket_api.php',
|
'TICKET_API_URL': 'http://10.10.10.45/create_ticket_api.php',
|
||||||
'STATE_FILE': '/tmp/last_health_check.json',
|
|
||||||
'THRESHOLDS': {
|
'THRESHOLDS': {
|
||||||
'DISK_CRITICAL': 90,
|
'DISK_CRITICAL': 90,
|
||||||
'DISK_WARNING': 80,
|
'DISK_WARNING': 80,
|
||||||
@ -65,7 +64,6 @@ class SystemHealthMonitor:
|
|||||||
|
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
ticket_api_url: str = 'http://10.10.10.45/create_ticket_api.php',
|
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):
|
dry_run: bool = False):
|
||||||
"""
|
"""
|
||||||
Initialize the system health monitor.
|
Initialize the system health monitor.
|
||||||
@ -129,8 +127,17 @@ class SystemHealthMonitor:
|
|||||||
:param health_report: The comprehensive health report from the checks.
|
:param health_report: The comprehensive health report from the checks.
|
||||||
:return: A detailed description for the issue.
|
: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:
|
if "Disk" in issue:
|
||||||
for partition in health_report.get('drives_health', {}).get('drives', []):
|
for partition in health_report.get('drives_health', {}).get('drives', []):
|
||||||
if partition.get('mountpoint') in issue:
|
if partition.get('mountpoint') in issue:
|
||||||
@ -599,7 +606,6 @@ def main():
|
|||||||
|
|
||||||
# Parse command-line arguments or read from configuration file
|
# Parse command-line arguments or read from configuration file
|
||||||
ticket_api_url = "http://10.10.10.45/create_ticket_api.php"
|
ticket_api_url = "http://10.10.10.45/create_ticket_api.php"
|
||||||
state_file = "/tmp/last_health_check.json"
|
|
||||||
|
|
||||||
# Instantiate the SystemHealthMonitor class
|
# Instantiate the SystemHealthMonitor class
|
||||||
monitor = SystemHealthMonitor(
|
monitor = SystemHealthMonitor(
|
||||||
|
|||||||
Reference in New Issue
Block a user