Skip to content

Commit

Permalink
Merge pull request python-diamond#463 from MichaelDoyle/update_joloki…
Browse files Browse the repository at this point in the history
…a_legacy_options

Add maxCollectionSize to support legacy versions of Jolokia
  • Loading branch information
bmhatfield committed Apr 28, 2016
2 parents c0544c0 + 5ea5f76 commit b2fd65a
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/collectors/jolokia/jolokia.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,13 +201,19 @@ def _list_request(self):
"""Returns a dictionary with JMX domain names as keys"""
try:
# https://jolokia.org/reference/html/protocol.html
#
# A maxDepth of 1 restricts the return value to a map with the JMX
# domains as keys. The values of the maps don't have any meaning
# and are dummy values.
url = "http://%s:%s/%s%s?maxDepth=1" % (self.config['host'],
self.config['port'],
self.jolokia_path,
self.LIST_URL)
#
# maxCollectionSize=0 means "unlimited". This works around an issue
# prior to Jolokia 1.3 where results were truncated at 1000
#
url = "http://%s:%s/%s%s?maxDepth=1&maxCollectionSize=0" % (
self.config['host'],
self.config['port'],
self.jolokia_path,
self.LIST_URL)
# need some time to process the downloaded metrics, so that's why
# timeout is lower than the interval.
timeout = max(2, float(self.config['interval']) * 2 / 3)
Expand All @@ -221,6 +227,7 @@ def _list_request(self):
def _read_request(self, domain):
try:
url_path = '/?%s' % urllib.urlencode({
'maxCollectionSize': '0',
'ignoreErrors': 'true',
'canonicalNaming':
'true' if self.config['use_canonical_names'] else 'false',
Expand All @@ -240,8 +247,8 @@ def _read_request(self, domain):
self.log.error('Unable to read JSON response.')
return {}

# escape the JMX domain per https://jolokia.org/reference/html/protocol.html
# the Jolokia documentation suggests that, when using the p query parameter,
# escape JMX domain per https://jolokia.org/reference/html/protocol.html
# the Jolokia documentation suggests that when using the p query parameter,
# simply urlencoding should be sufficient, but in practice, the '!' appears
# necessary (and not harmful)
def _escape_domain(self, domain):
Expand Down

0 comments on commit b2fd65a

Please sign in to comment.