Skip to content

Instantly share code, notes, and snippets.

@portante
Created June 23, 2017 00:17
Show Gist options
  • Select an option

  • Save portante/ed1b66a85d40a253a4886e6e0bf589b4 to your computer and use it in GitHub Desktop.

Select an option

Save portante/ed1b66a85d40a253a4886e6e0bf589b4 to your computer and use it in GitHub Desktop.
A simple script to calculate the total size of data per day for all indices
#!/bin/bash
ES_URL='https://localhost:9200'
curl_get='curl -s -X GET --cacert /etc/elasticsearch/secret/admin-ca --cert /etc/elasticsearch/secret/admin-cert --key /etc/elasticsearch/secret/admin-key'
$curl_get $ES_URL/_cat/indices?bytes=m > /tmp/indices.lis
for days_back in {1..7}; do
thedate=$(date --date="-${days_back} day" +"%Y.%m.%d")
echo "$thedate: $(grep $thedate /tmp/indices.lis | awk '{sum += $8} END {print sum}')"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment