Progress made but more testing needed with possible change to keep it alive after shutdown (but in a suspended state)
This commit is contained in:
parent
264c8ccbdc
commit
29546b6280
2 changed files with 15 additions and 4 deletions
|
@ -2,9 +2,9 @@
|
|||
|
||||
# See README before changing any of these options.
|
||||
|
||||
hostMonitoringPeriod = 15
|
||||
hostMonitoringPeriod = 1
|
||||
urlMonitoringPeriod = 60
|
||||
urls = ["https://1.1.1.1"]
|
||||
urls = ["https://one.one.one.one"]
|
||||
urlTimeout = 10
|
||||
maxWorkers = 4
|
||||
forceNonPOSIXCPU = True
|
||||
|
@ -15,3 +15,7 @@ sqlUsername = ''
|
|||
sqlPassword = ''
|
||||
logRetentionDays = 90
|
||||
maximumSQLAttempts = 3
|
||||
hostMonitorStartTime = "00:00:00"
|
||||
hostMonitorEndTime = "23:59:59"
|
||||
urlMonitorStartTime = "00:00:00"
|
||||
urlMonitorEndTime = "23:59:59"
|
||||
|
|
11
main.py
11
main.py
|
@ -90,9 +90,12 @@ def getNonPOSIXCPUAverage():
|
|||
|
||||
def monitorHost(stop_event):
|
||||
|
||||
while time.strftime("%H:%M:%S") <= config.hostMonitorStartTime:
|
||||
time.sleep(1) # This block is important to ensure the thread sleeps until the start time is reached. Else the thread wont start if the script is started before the start time
|
||||
|
||||
nonPOSIXCPUStarted = False
|
||||
|
||||
while not stop_event.is_set():
|
||||
while not (stop_event.is_set()) and (time.strftime("%H:%M:%S") >= config.hostMonitorStartTime and time.strftime("%H:%M:%S") <= config.hostMonitorEndTime):
|
||||
|
||||
if os.name != 'posix' or config.forceNonPOSIXCPU:
|
||||
|
||||
|
@ -120,7 +123,10 @@ def monitorHost(stop_event):
|
|||
|
||||
def monitorUrls(stop_event):
|
||||
|
||||
while not stop_event.is_set():
|
||||
while time.strftime("%H:%M:%S") <= config.urlMonitorStartTime:
|
||||
time.sleep(1) # This block is important to ensure the thread sleeps until the start time is reached. Else the thread wont start if the script is started before the start time
|
||||
|
||||
while not (stop_event.is_set()) and (time.strftime("%H:%M:%S") >= config.urlMonitorStartTime and time.strftime("%H:%M:%S") <= config.urlMonitorEndTime):
|
||||
|
||||
for url in config.urls:
|
||||
|
||||
|
@ -167,6 +173,7 @@ def logHostLog(hostname, logTime, cpu, memory):
|
|||
def logURLLog(hostname, logTime, url, responseTime):
|
||||
|
||||
if not config.loggingMode == 'none':
|
||||
|
||||
manager = logsManager(config.sqlServer, config.sqlDatabase, config.sqlUsername, config.sqlPassword)
|
||||
manager.insertURLLog(hostname, socket.gethostbyname(socket.gethostname()), logTime, url, responseTime)
|
||||
|
||||
|
|
Loading…
Reference in a new issue