Skip to content

Instantly share code, notes, and snippets.

@jeffbryner
Created April 12, 2014 22:38
Show Gist options
  • Save jeffbryner/10560321 to your computer and use it in GitHub Desktop.
Save jeffbryner/10560321 to your computer and use it in GitHub Desktop.
elastic search node status
#!/usr/bin/env python
import json
import requests
r=requests.get(url="http://servername:9200/_nodes/stats?pretty=true")
if r.status_code == 200:
nodestats=r.json()
for node in nodestats['nodes']:
loadaverage=nodestats['nodes'][node]['os']['load_average']
cpuusage=nodestats['nodes'][node]['os']['cpu']['usage']
nodename=nodestats['nodes'][node]['name']
jvmused=nodestats['nodes'][node]['jvm']['mem']['heap_used_percent']
print('{0}: cpu {1}% jvm {2}% load average: {3}'.format(nodename,cpuusage,jvmused,loadaverage))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment