Last active
December 31, 2015 04:39
-
-
Save RickyCook/7936070 to your computer and use it in GitHub Desktop.
Record free RAM and number of docs in an index for ElasticSearch over time
This file contains hidden or 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
#!/bin/bash | |
######## | |
ELASTIC_URL="<host>:9200/<index>/" | |
SLEEP=5 | |
######## | |
# AHAHHAHAHAHAHHAHAHH awwwwwful | |
PYTHON_CODE=' | |
import fileinput,json | |
whole = "" | |
for line in fileinput.input(): | |
whole += line | |
j = json.loads(whole) | |
print j["_all"]["total"]["docs"]["count"] | |
' | |
while true; do | |
cat /proc/meminfo | grep MemFree | grep -oE '[0-9]+' >> mem.txt | |
curl -s "$ELASTIC_URL/_stats" | python -c "$PYTHON_CODE" >> es.txt | |
echo "MEM: $(tail -n 1 mem.txt)" | |
echo "DOC: $(tail -n 1 es.txt)" | |
sleep $SLEEP | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment