Created
April 12, 2014 22:38
-
-
Save jeffbryner/10560321 to your computer and use it in GitHub Desktop.
elastic search node status
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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