Last active
August 24, 2017 17:35
-
-
Save salekseev/5a572c5f80ae521e15250acec0fb365d to your computer and use it in GitHub Desktop.
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 | |
elasticsearch_url="https://elasticsearchlog.athenahealth.com:9200" | |
month=$(date +%Y.%m) | |
indices=$(curl -s "${elasticsearch_url}/_cat/indices?bytes=b" | sort -rnk8) | |
echo "Statistics for the month of $month" | |
echo -n "Events stored month-to-date: " | |
echo "${indices}" | grep $month | awk '{print $6}' | paste -sd+ - | bc | |
echo -n "GigaBytes stored month-to-date: " | |
echo "${indices}" | grep $month | awk '{print $8}' | paste -sd+ - | bc | awk '{$1=$1/(1024^3); print $1,"GB";}' | |
echo -n "Total events stored: " | |
echo "${indices}" | awk '{print $6}' | paste -sd+ - | bc | |
echo -n "Total gigabytes stored: " | |
echo "${indices}" | awk '{print $8}' | paste -sd+ - | bc | awk '{$1=$1/(1024^3); print $1,"GB";}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment