Skip to content

Instantly share code, notes, and snippets.

@DavidWittman
Last active March 19, 2017 04:19
Show Gist options
  • Save DavidWittman/d3a68b15c27944cf646b5a33fa60cfaf to your computer and use it in GitHub Desktop.
Save DavidWittman/d3a68b15c27944cf646b5a33fa60cfaf to your computer and use it in GitHub Desktop.

Revisions

  1. DavidWittman revised this gist Mar 19, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion elasticsearch_primary_shards_per_node.md
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    List the number of primary shards per data node in Elasticsearch:

    ``` bash
    curl localhost:9200/_cat/shards?h=node,prirep | awk '
    curl -s localhost:9200/_cat/shards?h=node,prirep | awk '
    $2 == "p" {
    result[$1] += 1; total += 1
    }
  2. DavidWittman revised this gist Mar 18, 2017. 1 changed file with 3 additions and 2 deletions.
    5 changes: 3 additions & 2 deletions elasticsearch_primary_shards_per_node.md
    Original file line number Diff line number Diff line change
    @@ -4,10 +4,11 @@ List the number of primary shards per data node in Elasticsearch:
    curl localhost:9200/_cat/shards?h=node,prirep | awk '
    $2 == "p" {
    result[$1] += 1; total += 1
    } END {
    }
    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.
    It's not exactly a one-liner but I tried to make the AWK somewhat legible.
  3. DavidWittman created this gist Mar 18, 2017.
    13 changes: 13 additions & 0 deletions elasticsearch_primary_shards_per_node.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    List the number of primary shards per data node in Elasticsearch:

    ``` bash
    curl 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.