OSDN Git Service

Merge branch 'chef-vendor-java'
[metasearch/grid-chef-repo.git] / roles / praesepe-gm.rb
1 $LOAD_PATH.push("#{File.dirname(__FILE__)}/../_lib")
2 #${chef-repo}/_lib/grid.rb
3 require 'grid'
4 require 'rubygems'
5 require 'bracecomp'
6
7 cluster_name = 'praesepe'
8 cluster_sym = cluster_name.to_sym
9 datanode_prefix = 'dn1'
10 datanode_digit_nums = 4
11
12 name "#{cluster_name}-gm"
13 description "#{cluster_name.capitalize} ganglia gmetad node"
14
15 run_list(
16   'role[node_commons]',
17   #'role[nameservice-client-grid]',
18   'role[ganglia-gmond]',
19   'role[ganglia-gmetad]',
20   'role[ganglia-web]'
21 )
22
23 #env_run_lists()
24
25 this_subcluster = Grid::CLUSTERS[cluster_sym][:gmetads]
26 mcast_addr = this_subcluster[:mcast_addr]
27 port = '8649'
28 polling_interval = '30'
29 # uni-cast
30 udp_send_channels4ucast = []
31 this_subcluster[:nodes].first(2).each {|host|
32   udp_send_channels4ucast.push(
33     {
34       'mcast_join' => '',
35       'host' => "#{host}.#{Grid::DOMAIN}",
36       'port' => port,
37       'ttl' => ''
38     }
39   )
40 }
41
42 # for non-DataNodes
43 data_sources = []
44 Grid::CLUSTERS[cluster_sym].select{|key| key != :datanodes}.each {|key, cluster|
45   data_sources.push(
46     {
47       :name => cluster[:alias],
48       :polling_interval => polling_interval,
49       # head nodes: 2
50       :address_list => cluster[:nodes].first(2).map{|host| "#{host}.#{Grid::DOMAIN}"}
51     }
52   )
53 }
54
55 # for DataNodes
56 head_node_nums = 2
57 digit_nums = datanode_digit_nums
58 padstr = '0'
59 dn_data_sources = []
60 (0...2).step(40) {|v|
61 #(0...80).step(40) {|v|
62   first_head = v.to_s.rjust(digit_nums, padstr)
63   last_head = (v + head_node_nums -1).to_s.rjust(digit_nums, padstr)
64   dn_data_sources.push( 
65     {
66       :name => "DataNode#{first_head}",
67       :polling_interval => polling_interval,
68       # dn10000
69       :address_list => "#{datanode_prefix}{#{first_head}..#{last_head}}.#{Grid::DOMAIN}".expand
70     }
71   )
72 }
73
74 default_attributes(
75   'ganglia' => {
76     'web' => {
77 =begin
78       'Allow' => [
79         "from .#{Grid::DOMAIN}",
80         'from 192.168.0.0/16'],
81       'AuthType' => 'Kerberos',
82       'mod_auth_kerb' => {
83         'KrbAuthRealms' => Grid::REALM,
84         'Krb5Keytab' => '/etc/krb5.keytab'
85       }
86 =end
87     }
88   },
89 )
90
91 nagios_nodes = []
92 if defined? Grid::CLUSTERS[cluster_sym][:nagioses][:nodes] then
93   nagios_nodes = Grid::CLUSTERS[cluster_sym][:nagioses][:nodes].map{|host| "#{host}.#{Grid::DOMAIN}"}
94 end
95
96 override_attributes(
97   'ganglia' => {
98     # gmond
99     'cluster' => {
100       'name' => this_subcluster[:alias],
101       'owner' => Grid::DOMAIN
102     },
103     'static' => {
104 =begin
105       ## static multi-cast
106       'udp_send_channels' => [
107         {
108           'mcast_join' => mcast_addr,
109           'host' => '',
110           'port' => port,
111           'ttl' => '1'
112         }
113       ],
114       'udp_recv_channels' => [
115         {
116           'mcast_join' => mcast_addr,
117           'port' => port,
118           'bind' => mcast_addr
119         }
120       ],
121 =end
122       ## static uni-cast
123       'udp_send_channels' => udp_send_channels4ucast,
124       'udp_recv_channels' => [
125         {
126           'mcast_join' => '',
127           'port' => port,
128           'bind' => ''
129         }
130       ],
131     },
132     # gmetad
133     'gridname' => cluster_name.capitalize,
134     'trusted_hosts' => ['127.0.0.1'] + nagios_nodes,
135     'data_sources' => data_sources + dn_data_sources
136   }
137 )