Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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