Correction to last commit
This commit is contained in:
parent
1e57d30597
commit
6644051c7b
1 changed files with 9 additions and 0 deletions
9
main.py
9
main.py
|
@ -30,9 +30,12 @@ import log
|
||||||
import requests
|
import requests
|
||||||
import threading
|
import threading
|
||||||
import signal
|
import signal
|
||||||
|
import socket
|
||||||
from functools import partial
|
from functools import partial
|
||||||
from concurrent.futures import ThreadPoolExecutor, as_completed
|
from concurrent.futures import ThreadPoolExecutor, as_completed
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
|
from log import hostLogsManager
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
stop_event = threading.Event()
|
stop_event = threading.Event()
|
||||||
|
|
||||||
|
@ -61,6 +64,7 @@ def monitorHost(stop_event):
|
||||||
loadavg = round((load1/os.cpu_count()) * 100, 2)
|
loadavg = round((load1/os.cpu_count()) * 100, 2)
|
||||||
|
|
||||||
memory = psutil.virtual_memory().percent
|
memory = psutil.virtual_memory().percent
|
||||||
|
logHostLog(socket.gethostname(), datetime.now(), loadavg, memory)
|
||||||
|
|
||||||
print("CPU %: " + str(loadavg))
|
print("CPU %: " + str(loadavg))
|
||||||
print("Memory %: " + str(memory))
|
print("Memory %: " + str(memory))
|
||||||
|
@ -104,6 +108,11 @@ def monitorUrls(stop_event):
|
||||||
|
|
||||||
time.sleep(config.urlMonitoringPeriod)
|
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():
|
def main():
|
||||||
|
|
||||||
signal.signal(signal.SIGTERM, signal_handler)
|
signal.signal(signal.SIGTERM, signal_handler)
|
||||||
|
|
Loading…
Reference in a new issue