How to display active Elasticsearch searches

Display active Elasticsearch searches and calculate average value.

Display search thread pool statistics for each node in a cluster.

$ curl --silent "http://127.0.0.1:9200/_cat/thread_pool/search?v"
node_name   name   active queue rejected
es-node-a   search     10     3        0
es-node-b   search      4     0        0
es-node-c   search      9     2        0
es-node-d   search      6     0        0
es-node-e   search      5     0        0

Display active Elasticsearch searches and calculate average value.

$ curl --silent http://127.0.0.1:9200/_cat/thread_pool/search | awk '{sum+=$3} END {print "There are " NR " running servers, " sum " active searches, with average of " sum/NR " searches per server" }'
There are 5 running servers, 34 active searches, with average of 6.8 searches per server