Skip to content

Commit 12ff387

Browse files
committed
Merge pull request ganglia#205 from jeffk/dyn_elasticsearch_version
Dyn elasticsearch version
2 parents 2b04b99 + e23009b commit 12ff387

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

elasticsearch/python_modules/elasticsearch.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,12 +187,20 @@ def metric_init(params):
187187

188188
host = params.get('host', 'http://localhost:9200/')
189189

190-
version = params.get('version', '1.2')
191-
190+
try:
191+
result = json.load(urllib.urlopen(host))
192+
except (ValueError, IOError):
193+
result = {}
194+
195+
host_version = result.get('version',{}).get('number') or "1.2"
196+
version = params.get('version', host_version)
197+
192198
m = re.match('(?P<major>\d+)\.(?P<minor>(\d+(\.\d+)*))', version)
193-
199+
194200
if m and m.group('major') == '0':
195201
url_cluster = '{0}_cluster/nodes/_local/stats?all=true'.format(host)
202+
elif m and m.group('major') == '1' and m.group('minor') == '3.2':
203+
url_cluster = '{0}_nodes/_local/stats'.format(host)
196204
else:
197205
url_cluster = '{0}_cluster/state/nodes'.format(host)
198206

0 commit comments

Comments
 (0)