diff --git a/docs/collectors/MonitCollector.md b/docs/collectors/MonitCollector.md index 3c433980c..4748fc628 100644 --- a/docs/collectors/MonitCollector.md +++ b/docs/collectors/MonitCollector.md @@ -20,6 +20,8 @@ enabled | False | Enable collecting these metrics | bool measure_collector_time | False | Collect the collector run time in ms | bool metrics_blacklist | None | Regex to match metrics to block. Mutually exclusive with metrics_whitelist | NoneType metrics_whitelist | None | Regex to match metrics to transmit. Mutually exclusive with metrics_blacklist | NoneType +scheme | http | Select scheme http or https | str +selfsigned | False | Use self-signed certificate | bool send_totals | False | Send cpu and memory totals | bool #### Example Output @@ -46,4 +48,3 @@ servers.hostname.monit.rsyslogd.memory.kilobyte_usage 2664 servers.hostname.monit.sshd.cpu.percent 0.0 servers.hostname.monit.sshd.memory.kilobyte_usage 2588 ``` - diff --git a/src/collectors/monit/monit.py b/src/collectors/monit/monit.py index c3bbd5936..aa1457a60 100644 --- a/src/collectors/monit/monit.py +++ b/src/collectors/monit/monit.py @@ -11,6 +11,8 @@ import urllib2 import base64 +import sys +import ssl from xml.dom.minidom import parseString @@ -40,12 +42,24 @@ def get_default_config(self): 'path': 'monit', 'byte_unit': ['byte'], 'send_totals': False, + 'scheme': 'http', + 'selfsigned': False, }) return config def collect(self): - url = 'http://%s:%i/_status?format=xml' % (self.config['host'], - int(self.config['port'])) + url = '%s://%s:%i/_status?format=xml' % (self.config['scheme'], + self.config['host'], + int(self.config['port'])) + + if ( + self.config['selfsigned'] + # 0x020709f0 exactly equal python 2.7.9 final + and sys.hexversion >= 0x020709f0 + and hasattr(ssl, '_create_unverified_context') + ): + ssl._create_default_https_context = ssl._create_unverified_context + try: request = urllib2.Request(url)