Correction to last commit

This commit is contained in:
Thomas Williams 2024-07-02 20:46:36 +01:00
parent 1e57d30597
commit 6644051c7b
Signed by: thomas
GPG key ID: EB8F975CF60BCBFF

View file

@ -30,9 +30,12 @@ import log
import requests
import threading
import signal
import socket
from functools import partial
from concurrent.futures import ThreadPoolExecutor, as_completed
from bs4 import BeautifulSoup
from log import hostLogsManager
from datetime import datetime
stop_event = threading.Event()
@ -61,6 +64,7 @@ def monitorHost(stop_event):
loadavg = round((load1/os.cpu_count()) * 100, 2)
memory = psutil.virtual_memory().percent
logHostLog(socket.gethostname(), datetime.now(), loadavg, memory)
print("CPU %: " + str(loadavg))
print("Memory %: " + str(memory))
@ -104,6 +108,11 @@ def monitorUrls(stop_event):
time.sleep(config.urlMonitoringPeriod)
def logHostLog(hostname, logTime, cpu, memory):
manager = hostLogsManager(config.sqlServer, config.sqlDatabase, config.sqlUsername, config.sqlPassword)
manager.insert_host_log(hostname, logTime, cpu, memory)
def main():
signal.signal(signal.SIGTERM, signal_handler)