Skip to content

Instantly share code, notes, and snippets.

@salekseev
Last active August 24, 2017 17:35
Show Gist options
  • Save salekseev/5a572c5f80ae521e15250acec0fb365d to your computer and use it in GitHub Desktop.
Save salekseev/5a572c5f80ae521e15250acec0fb365d to your computer and use it in GitHub Desktop.
#!/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