Chad has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/155679

Change subject: WIP: Collection of fun bash scripts for managing elasticsearch
......................................................................

WIP: Collection of fun bash scripts for managing elasticsearch

The rolling upgrade dashboard is my favorite. Mainly putting
these in puppet so they don't get lost and will be easier to
call from all elastic hosts. Feel free to organize better,
make es-tool into a wrapper, etc.

Change-Id: Idba07d8d16d0534068e0521d47fcee42ead88bf5
---
A modules/elasticsearch/files/es-tool
1 file changed, 31 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/puppet 
refs/changes/79/155679/1

diff --git a/modules/elasticsearch/files/es-tool 
b/modules/elasticsearch/files/es-tool
new file mode 100755
index 0000000..5f2b084
--- /dev/null
+++ b/modules/elasticsearch/files/es-tool
@@ -0,0 +1,31 @@
+#!/usr/bin/bash
+
+function es_all_indexes() {
+       curl -s localhost:9200/_cluster/state | jq '.indices | keys[]'
+}
+
+function es_large_indexes() {
+       curl -s localhost:9200/_stats?level=shards | jq '.indices | keys[] as 
$index | {
+       index: $index,
+       shards: ([.[$index].shards[]] | length),
+       average_size: ([.[$index].shards[][].store.size_in_bytes] | add / 
length / 1024 / 1024 / 1024),
+       total_size: ([.[$index].shards[][].store.size_in_bytes] | add / 1024 / 
1024 / 1024)
+       }
+       | select(.total_size > 5)'
+}
+
+function es_moving_shards() {
+   curl -s localhost:9200/_cluster/state | jq -c '.nodes as $nodes |
+       .routing_table.indices[].shards[][] |
+       select(.relocating_node) | {index, shard, from: $nodes[.node].name, to: 
$nodes[.relocating_node].name}'
+}
+
+function es_unaliased_indexes() {
+   curl -s localhost:9200/_cluster/state | jq '.metadata.indices |
+       keys[] as $index |
+       select(.[$index].aliases | length == 0) | $index' | head
+}
+
+function es_rolling_upgrade_dashboard() {
+  watch -n5 'curl -s localhost:9200/_cat/health?v; curl -s 
localhost:9200/_cat/allocation?v | sort -rk5; curl -s 
localhost:9200/_cat/nodes?v\&h=h,ip,v,m | sort -rk3'
+}

-- 
To view, visit https://gerrit.wikimedia.org/r/155679
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Idba07d8d16d0534068e0521d47fcee42ead88bf5
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Chad <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to