From 2e40ce9f7207a762b8511434ccaab62c4d544bdd Mon Sep 17 00:00:00 2001 From: Weidong Shao Date: Mon, 27 Oct 2014 20:29:58 +0000 Subject: [PATCH] Use cluster_id from the chef attribute Change-Id: Icbdfc6b7185725efbf8e57d5005395912ba6b413 --- chef/cookbooks/collectd/recipes/kairosdb.rb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/chef/cookbooks/collectd/recipes/kairosdb.rb b/chef/cookbooks/collectd/recipes/kairosdb.rb index c2b9fcd..75a47da 100644 --- a/chef/cookbooks/collectd/recipes/kairosdb.rb +++ b/chef/cookbooks/collectd/recipes/kairosdb.rb @@ -25,16 +25,17 @@ cookbook_file "#{node['collectd']['plugin_dir']}/kairosdb_writer.py" do notifies :restart, resources(:service => "collectd") end -if ! node['cluster'] - node.set['cluster'] = "no_cluster_defined" +cluster_id = 'no_cluster_defined' +if node['compass'] and node['compass']['cluster_id'] + cluster_id = node['compass']['cluster_id'] end + collectd_python_plugin "kairosdb_writer" do opts = {"KairosDBHost"=>node['collectd']['server']['host'], "KairosDBPort"=>node['collectd']['server']['port'], "KairosDBProtocol"=>node['collectd']['server']['protocol'], - "Tags" => "host=#{node['fqdn']}\" \"role=OSROLE\" \"location=China.Beijing.TsingHua\" \"cluster=#{node['cluster']}", + "Tags" => "host=#{node['fqdn']}\" \"role=OSROLE\" \"location=China.Beijing.TsingHua\" \"cluster=#{cluster_id}", "TypesDB" => node['collectd']['types_db'], - "LowercaseMetricNames"=>"true" } options(opts) end