1 ruby_block "check_ElasticSearch_Cluster_Health" do
3 #tricky way to load this Chef::Mixin::ShellOut utilities
4 Chef::Resource::RubyBlock.send(:include, Chef::Mixin::ShellOut)
5 #curl_command = "http://#{node['ipaddress']}:9200/_cluster/health?pretty=true"
6 curl_command = "http://localhost:9200/_cluster/health?pretty=true"
7 resp = Net::HTTP.get_response URI.parse(curl_command)
8 stat = JSON.parse(resp.read_body)['status']
12 printf("\033[32m%s\n\033[0m", " ElasticSearch Cluster status is green.")
14 printf("\033[33m%s\n\033[0m", " ElasticSearch Cluster status is yellow...")
16 printf("\033[31m%s\n\033[0m", " ElasticSearch Cluster status is red!")
23 bash "create monitoring mapping" do
25 curl -i -X PUT -d '{ "order": 1, "template": "monitoring_events-*", "settings": {}, "mappings":
29 "hostid": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
30 "hostcpu": { "include_in_all": true, "type": "long" },
31 "hostmem": { "include_in_all": true, "type": "double" },
32 "hostdisk": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
33 "jvmid": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
34 "jvmcpu": { "include_in_all": true,"type": "long" },
35 "jvmmem": { "include_in_all": true, "type": "long" },
36 "jvmtnum": { "include_in_all": true, "type": "integer" },
37 "appid": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
38 "appstat": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
39 "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" }
41 "_all": { "enabled": true }
44 "aliases": { "last_3_months": {} }
45 }' http://localhost:9200/_template/monitoring_template