RabbitMQ changes. Closes issue #17
This commit is contained in:
parent
4e959749fc
commit
33ede80613
3 changed files with 35 additions and 2 deletions
27
config.py.sample
Normal file
27
config.py.sample
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
#!/usr/bin/python3
|
||||||
|
|
||||||
|
# See README before changing any of these options.
|
||||||
|
|
||||||
|
hostMonitoringPeriod = 1
|
||||||
|
urlMonitoringPeriod = 120
|
||||||
|
urls = ["https://one.one.one.one"]
|
||||||
|
urlTimeout = 10
|
||||||
|
maxWorkers = 4
|
||||||
|
forceNonPOSIXCPU = True
|
||||||
|
loggingMode = ''
|
||||||
|
sqlServer = ''
|
||||||
|
sqlDatabase = ''
|
||||||
|
sqlUsername = ''
|
||||||
|
sqlPassword = ''
|
||||||
|
rabbitmqHost = ''
|
||||||
|
rabbitmqPort = 5671
|
||||||
|
rabbitmqca = ''
|
||||||
|
rabbitmqcacert = ''
|
||||||
|
rabbitmqcakey = ''
|
||||||
|
rabbitmqRoutingKey = ''
|
||||||
|
logRetentionDays = 90
|
||||||
|
maximumSQLAttempts = 3
|
||||||
|
hostMonitorStartTime = "00:00:00"
|
||||||
|
hostMonitorEndTime = "23:59:59"
|
||||||
|
urlMonitorStartTime = "00:00:00"
|
||||||
|
urlMonitorEndTime = "23:59:59"
|
7
main.py
7
main.py
|
@ -40,7 +40,7 @@ from datetime import datetime
|
||||||
if config.loggingMode == 'rabbitmq':
|
if config.loggingMode == 'rabbitmq':
|
||||||
|
|
||||||
import rabbitmq
|
import rabbitmq
|
||||||
rabbitmq = rabbitmq.rabbitMQClient('sampleca.crt','sample.crt','sample.key','','5671','monutil')
|
rabbitmq = rabbitmq.rabbitMQClient(config.rabbitmqca,config.rabbitmqcacert,config.rabbitmqcakey,config.rabbitmqHost,config.rabbitmqPort,config.rabbitmqRoutingKey)
|
||||||
|
|
||||||
stop_event = threading.Event()
|
stop_event = threading.Event()
|
||||||
nonPOSIXCPULoads = []
|
nonPOSIXCPULoads = []
|
||||||
|
@ -93,7 +93,6 @@ def getNonPOSIXCPUAverage():
|
||||||
|
|
||||||
return avgLoad
|
return avgLoad
|
||||||
|
|
||||||
|
|
||||||
def monitorHost(stop_event):
|
def monitorHost(stop_event):
|
||||||
|
|
||||||
nonPOSIXCPUStarted = False
|
nonPOSIXCPUStarted = False
|
||||||
|
@ -194,6 +193,10 @@ def logURLLog(hostname, logTime, url, responseTime):
|
||||||
manager = logsManager(config.sqlServer, config.sqlDatabase, config.sqlUsername, config.sqlPassword)
|
manager = logsManager(config.sqlServer, config.sqlDatabase, config.sqlUsername, config.sqlPassword)
|
||||||
manager.insertURLLog(hostname, socket.gethostbyname(socket.gethostname()), logTime, url, responseTime)
|
manager.insertURLLog(hostname, socket.gethostbyname(socket.gethostname()), logTime, url, responseTime)
|
||||||
|
|
||||||
|
if config.loggingMode == 'rabbitmq':
|
||||||
|
|
||||||
|
rabbitmq.publish(hostname + '|' + str(logTime) + '|' + 'url' + '|' + url + '|' + str(responseTime))
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
||||||
signal.signal(signal.SIGTERM, signal_handler)
|
signal.signal(signal.SIGTERM, signal_handler)
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
|
|
||||||
import pika
|
import pika
|
||||||
import ssl
|
import ssl
|
||||||
|
import base64
|
||||||
|
|
||||||
class rabbitMQClient:
|
class rabbitMQClient:
|
||||||
|
|
||||||
|
@ -38,6 +39,8 @@ class rabbitMQClient:
|
||||||
|
|
||||||
def publish(self, message):
|
def publish(self, message):
|
||||||
|
|
||||||
|
message = base64.b64encode(message.encode('utf-8'))
|
||||||
|
|
||||||
context = ssl.create_default_context(
|
context = ssl.create_default_context(
|
||||||
cafile=self.ca)
|
cafile=self.ca)
|
||||||
context.verify_mode = ssl.CERT_REQUIRED
|
context.verify_mode = ssl.CERT_REQUIRED
|
||||||
|
|
Loading…
Reference in a new issue