Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/collectors/monit/monit.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

import urllib2
import base64
import sys
import ssl

from xml.dom.minidom import parseString

Expand Down Expand Up @@ -40,12 +42,19 @@ 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'],
url = '%s://%s:%i/_status?format=xml' % (self.config['scheme'],
self.config['host'],
int(self.config['port']))

if self.config['selfsigned'] and sys.hexversion >= 0x020709f0 and hasattr(ssl, '_create_unverified_context'):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a comment as to what version 0x020709f0 correlates to? or use sys.version_info instead?

ssl._create_default_https_context = ssl._create_unverified_context

try:
request = urllib2.Request(url)

Expand Down