Skip to content

Instantly share code, notes, and snippets.

@DavidWittman
Last active March 19, 2017 04:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DavidWittman/d3a68b15c27944cf646b5a33fa60cfaf to your computer and use it in GitHub Desktop.
Save DavidWittman/d3a68b15c27944cf646b5a33fa60cfaf to your computer and use it in GitHub Desktop.
One-liner to list the number of primary shards per data node in Elasticsearch

List the number of primary shards per data node in Elasticsearch:

curl -s localhost:9200/_cat/shards?h=node,prirep | awk '
$2 == "p" { 
  result[$1] += 1; total += 1
}
END {
  for (var in result)
    printf "%s\t%s (%0.2f%%)\n",var,result[var],result[var]/total*100
}'

It's not exactly a one-liner but I tried to make the AWK somewhat legible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment