OSDN Git Service

add IPv4/6 setting support for Ganglia.
[metasearch/grid-chef-repo.git] / roles / pleiades-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 = 'pleiades'
8 cluster_sym = cluster_name.to_sym
9
10 name "#{cluster_name}-gm"
11 description "#{cluster_name.capitalize} ganglia gmetad node"
12
13 run_list(
14   'role[node_commons]',
15   'role[nameservice-client-grid]',
16   'role[ganglia-gmond]',
17   'role[ganglia-gmetad]',
18   'role[ganglia-web]'
19 )
20
21 #env_run_lists()
22
23 this_subcluster = Grid::CLUSTERS[cluster_sym][:gmetads]
24 mcast_addr = this_subcluster[:mcast_addr]
25 port = '8649'
26 polling_interval = '30'
27 =begin
28 # uni-cast
29 udp_send_channels4ucast = []
30 this_subcluster[:nodes].first(2).each {|host|
31   udp_send_channels4ucast.push(
32     {
33       'mcast_join' => '',
34       'host' => "#{host}.#{Grid::DOMAIN}",
35       'port' => port,
36       'ttl' => ''
37     }
38   )
39 }
40 =end
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 = 5
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       :address_list => "dn{#{first_head}..#{last_head}}.#{Grid::DOMAIN}".expand
69     }
70   )
71 }
72
73 default_attributes(
74   'ganglia' => {
75     'web' => {
76       'Allow' => [
77         "from .#{Grid::DOMAIN}",
78         'from 192.168.0.0/16'],
79       'AuthType' => 'Kerberos',
80       'mod_auth_kerb' => {
81         'KrbAuthRealms' => Grid::REALM,
82         'Krb5Keytab' => '/etc/krb5.keytab'
83       }
84     }
85   },
86 )
87
88 nagios_nodes = []
89 if defined? Grid::CLUSTERS[cluster_sym][:nagioses][:nodes] then
90   nagios_nodes = Grid::CLUSTERS[cluster_sym][:nagioses][:nodes].map{|host| "#{host}.#{Grid::DOMAIN}"}
91 end
92
93 override_attributes(
94   'ganglia' => {
95     # gmond
96     'cluster' => {
97       'name' => this_subcluster[:alias],
98       'owner' => Grid::DOMAIN
99     },
100     ## static multi-cast
101     'static' => {
102       'udp_send_channels' => [
103         {
104           'mcast_join' => mcast_addr,
105           'host' => '',
106           'port' => port,
107           'ttl' => '1'
108         }
109       ],
110       'udp_recv_channels' => [
111         {
112           'mcast_join' => mcast_addr,
113           'port' => port,
114           'bind' => mcast_addr
115         }
116       ],
117 =begin
118       ## static uni-cast
119       'udp_send_channels' => udp_send_channels4ucast,
120       'udp_recv_channels' => [
121         {
122           'mcast_join' => '',
123           'port' => port,
124           'bind' => ''
125         }
126       ],
127 =end
128     },
129     # gmetad
130     'gridname' => 'Pleiades',
131     'trusted_hosts' => ['127.0.0.1'] + nagios_nodes,
132     'data_sources' => data_sources + dn_data_sources
133   }
134 )