Description :

Voici un script pour des informations sur un serveur ES.

Script : elasticstats.sh

Help

 1 ./elasticstats.sh -h
 2 
 3 Description : Script to check Elasticsearch Stats.
 4 
 5 Usage : elasticstats.sh [-h] [-S] [-D] -H <host> -P <port> -p <proxypass path> -c <command info> [-o <output file>] [-f <output format>] [-V]
 6 
 7    -h : Help
 8    -D : Debug script
 9    -S : Web Server is HTTPS
10    -H : Elasticsearch host - mandatory
11    -P : Elasticsearch port - mandatory
12    -p : Web Server proxypass if is set (set -P to listen port of Web Server) - mandatory
13          -o : Output file
14    -c : Command :
15         - info
16         - indices
17         - clusterhealth
18         - clustersettings
19         - clusterstats
20         - nodesettings
21         - nodestats
22         - process
23         - settings
24    -f : Output format :
25         - brute (without formatting)
26         - json
27         - yaml (default)
28    -V : Version
29    -u : Human (Statistics are returned in a format suitable for humans)

Informations

 1 ./elasticstats.sh -H 127.0.0.1 -P 9200 -c info
 2 #####=> Result to info
 3 {
 4   "status" : 200,
 5   "name" : "node1",
 6   "version" : {
 7     "number" : "1.3.2",
 8     "build_hash" : "dee175dbe2f254f3f26992f5d7591939aaefd12f",
 9     "build_timestamp" : "2014-08-13T14:29:30Z",
10     "build_snapshot" : false,
11     "lucene_version" : "4.9"
12   },
13   "tagline" : "You Know, for Search"
14 }

Liste des index

 1 ./elasticstats.sh -H 127.0.0.1 -P 9200 -c indices
 2 #####=> Result to indices
 3 health index               pri rep docs.count docs.deleted store.size pri.store.size
 4 green  logstash-2015.07.30   5   0         86            0    292.4kb        292.4kb
 5 green  logstash-2014.09.28   5   0        376            0    407.7kb        407.7kb
 6 green  kibana-int            5   0          3            0     43.3kb         43.3kb
 7 green  nodes_stats           1   0         56            0    561.6kb        561.6kb
 8 green  logstash-2014.10.18   5   0          7            0     36.3kb         36.3kb
 9 yellow logstash-2016.04.27   5   1         32            0    151.6kb        151.6kb
10 green  logstash-2014.09.08   5   0        114            0      242kb          242kb
11 yellow logstash-2016.04.28   5   1         69            0    373.9kb        373.9kb 

Etat de santé du cluster

 1 ./elasticstats.sh -H 127.0.0.1 -P 9200 -c clusterhealth
 2 #####=> Result to clusterhealth
 3 {
 4   "cluster_name" : "elasticsearch",
 5   "status" : "yellow",
 6   "timed_out" : false,
 7   "number_of_nodes" : 2,
 8   "number_of_data_nodes" : 1,
 9   "active_primary_shards" : 36,
10   "active_shards" : 36,
11   "relocating_shards" : 0,
12   "initializing_shards" : 0,
13   "unassigned_shards" : 10
14 }

D'autres commandes sont disponibles comme les stats de cluster ou node.

Cas de passage par un reverse proxy

 1 ./elasticstats.sh -H 192.168.5.40 -P 80 -p /my_elasticsearch -c info
 2 #####=> Result to info
 3 {
 4   "status" : 200,
 5   "name" : "node1",
 6   "version" : {
 7     "number" : "1.3.2",
 8     "build_hash" : "dee175dbe2f254f3f26992f5d7591939aaefd12f",
 9     "build_timestamp" : "2014-08-13T14:29:30Z",
10     "build_snapshot" : false,
11     "lucene_version" : "4.9"
12   },
13   "tagline" : "You Know, for Search"
14 }

Sortie de commande dans un fichier

1 ./elasticstats.sh -H 192.168.5.40 -P 80 -p /my_elasticsearch -c info -o output_info.txt
2 #####=> Result to info in output_info.txt

Source