summaryrefslogtreecommitdiffstats
path: root/sdc-os-chef/sdc-init-elasticsearch/chef-repo/cookbooks/init-sdc-elasticsearch/recipes/ES_3_create_monitoring_template.rb
diff options
context:
space:
mode:
authorTal Gitelman <tg851x@intl.att.com>2018-01-24 17:59:53 +0200
committerMichael Lando <ml636r@att.com>2018-01-25 20:21:27 +0000
commit38211c83410f610aa889a687fdecebb3fed53f02 (patch)
tree17c46fdd2a49c97ae87641b7d940f4e998edb08b /sdc-os-chef/sdc-init-elasticsearch/chef-repo/cookbooks/init-sdc-elasticsearch/recipes/ES_3_create_monitoring_template.rb
parent62ae83d66ecdc04ee722f5219aba687873d76760 (diff)
ES OOM alignment
Change-Id: I986fc13f8e32a103e3868f4da9ffb41631c70201 Issue-ID: SDC-912 Signed-off-by: Tal Gitelman <tg851x@intl.att.com>
Diffstat (limited to 'sdc-os-chef/sdc-init-elasticsearch/chef-repo/cookbooks/init-sdc-elasticsearch/recipes/ES_3_create_monitoring_template.rb')
-rw-r--r--sdc-os-chef/sdc-init-elasticsearch/chef-repo/cookbooks/init-sdc-elasticsearch/recipes/ES_3_create_monitoring_template.rb53
1 files changed, 53 insertions, 0 deletions
diff --git a/sdc-os-chef/sdc-init-elasticsearch/chef-repo/cookbooks/init-sdc-elasticsearch/recipes/ES_3_create_monitoring_template.rb b/sdc-os-chef/sdc-init-elasticsearch/chef-repo/cookbooks/init-sdc-elasticsearch/recipes/ES_3_create_monitoring_template.rb
new file mode 100644
index 0000000000..02b20f8cce
--- /dev/null
+++ b/sdc-os-chef/sdc-init-elasticsearch/chef-repo/cookbooks/init-sdc-elasticsearch/recipes/ES_3_create_monitoring_template.rb
@@ -0,0 +1,53 @@
+ruby_block "check_ElasticSearch_Cluster_Health" do
+ block do
+ #tricky way to load this Chef::Mixin::ShellOut utilities
+ Chef::Resource::RubyBlock.send(:include, Chef::Mixin::ShellOut)
+ curl_command = "http://#{node['Nodes']['ES']}:9200/_cluster/health?pretty=true"
+ resp = Net::HTTP.get_response URI.parse(curl_command)
+ stat = JSON.parse(resp.read_body)['status']
+
+ case stat
+ when "green"
+ printf("\033[32m%s\n\033[0m", " ElasticSearch Cluster status is green.")
+ when "yellow"
+ printf("\033[33m%s\n\033[0m", " ElasticSearch Cluster status is yellow...")
+ when "red"
+ printf("\033[31m%s\n\033[0m", " ElasticSearch Cluster status is red!")
+ break;
+ end
+ end
+ retries 10
+ retry_delay 2
+end
+
+bash "echo status" do
+ code <<-EOH
+ echo "DOCKER STARTED"
+ EOH
+end
+
+bash "create monitoring mapping" do
+ code <<-EOH
+ curl -i -X PUT -d '{ "order": 1, "template": "monitoring_events-*", "settings": {}, "mappings":
+ {
+ "monitoringevent": {
+ "properties": {
+ "hostid": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
+ "hostcpu": { "include_in_all": true, "type": "long" },
+ "hostmem": { "include_in_all": true, "type": "double" },
+ "hostdisk": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
+ "jvmid": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
+ "jvmcpu": { "include_in_all": true,"type": "long" },
+ "jvmmem": { "include_in_all": true, "type": "long" },
+ "jvmtnum": { "include_in_all": true, "type": "integer" },
+ "appid": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
+ "appstat": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
+ "timestamp": { "include_in_all": true, "index": "not_analyzed", "ignore_malformed": false, "format": "yyyy-MM-dd HH:mm:ss.SSS z", "precision_step": 4, "type": "date" }
+ },
+ "_all": { "enabled": true }
+ }
+ },
+ "aliases": { "last_3_months": {} }
+ }' http://#{node['Nodes']['ES']}:9200/_template/monitoring_template
+ EOH
+end