ES - script pour avoir quelques stats/info sur un serveur ES
Alasta 28 Avril 2016 bigdata shell cli elasticsearch BigData
Description : Voici un script pour avoir des informations sur un serveur Elasticsearch.
Description :
Voici un script pour des informations sur un serveur ES.
Script : elasticstats.sh
Help
./elasticstats.sh -h
Description : Script to check Elasticsearch Stats.
Usage : elasticstats.sh [-h] [-S] [-D] -H <host> -P <port> -p <proxypass path> -c <command info> [-o <output file>] [-f <output format>] [-V]
-h : Help
-D : Debug script
-S : Web Server is HTTPS
-H : Elasticsearch host - mandatory
-P : Elasticsearch port - mandatory
-p : Web Server proxypass if is set (set -P to listen port of Web Server) - mandatory
-o : Output file
-c : Command :
- info
- indices
- clusterhealth
- clustersettings
- clusterstats
- nodesettings
- nodestats
- process
- settings
-f : Output format :
- brute (without formatting)
- json
- yaml (default)
-V : Version
-u : Human (Statistics are returned in a format suitable for humans)
Informations
./elasticstats.sh -H 127.0.0.1 -P 9200 -c info
#####=> Result to info
{
"status" : 200,
"name" : "node1",
"version" : {
"number" : "1.3.2",
"build_hash" : "dee175dbe2f254f3f26992f5d7591939aaefd12f",
"build_timestamp" : "2014-08-13T14:29:30Z",
"build_snapshot" : false,
"lucene_version" : "4.9"
},
"tagline" : "You Know, for Search"
}
Liste des index
./elasticstats.sh -H 127.0.0.1 -P 9200 -c indices
#####=> Result to indices
health index pri rep docs.count docs.deleted store.size pri.store.size
green logstash-2015.07.30 5 0 86 0 292.4kb 292.4kb
green logstash-2014.09.28 5 0 376 0 407.7kb 407.7kb
green kibana-int 5 0 3 0 43.3kb 43.3kb
green nodes_stats 1 0 56 0 561.6kb 561.6kb
green logstash-2014.10.18 5 0 7 0 36.3kb 36.3kb
yellow logstash-2016.04.27 5 1 32 0 151.6kb 151.6kb
green logstash-2014.09.08 5 0 114 0 242kb 242kb
yellow logstash-2016.04.28 5 1 69 0 373.9kb 373.9kb
Etat de santé du cluster
./elasticstats.sh -H 127.0.0.1 -P 9200 -c clusterhealth
#####=> Result to clusterhealth
{
"cluster_name" : "elasticsearch",
"status" : "yellow",
"timed_out" : false,
"number_of_nodes" : 2,
"number_of_data_nodes" : 1,
"active_primary_shards" : 36,
"active_shards" : 36,
"relocating_shards" : 0,
"initializing_shards" : 0,
"unassigned_shards" : 10
}
D’autres commandes sont disponibles comme les stats de cluster ou node.
Cas de passage par un reverse proxy
./elasticstats.sh -H 192.168.5.40 -P 80 -p /my_elasticsearch -c info
#####=> Result to info
{
"status" : 200,
"name" : "node1",
"version" : {
"number" : "1.3.2",
"build_hash" : "dee175dbe2f254f3f26992f5d7591939aaefd12f",
"build_timestamp" : "2014-08-13T14:29:30Z",
"build_snapshot" : false,
"lucene_version" : "4.9"
},
"tagline" : "You Know, for Search"
}
Sortie de commande dans un fichier
./elasticstats.sh -H 192.168.5.40 -P 80 -p /my_elasticsearch -c info -o output_info.txt
#####=> Result to info in output_info.txt