OSDN Git Service

adds workaround for `check_all_disks` command failure.
[metasearch/grid-chef-repo.git] / roles / grid-nm.rb
index a70412a..5285c81 100644 (file)
@@ -1,5 +1,21 @@
-$LOAD_PATH.push("#{File.dirname(__FILE__)}/../_lib")
-#${chef-repo}/_lib/grid.rb
+#
+# Copyright 2013-2014, whitestar
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+$LOAD_PATH.push("#{File.dirname(__FILE__)}/_lib")
+#${chef-repo}/roles/_lib/grid.rb
 require 'grid'
 
 name 'grid-nm'
@@ -14,8 +30,24 @@ run_list(
 
 #env_run_lists "prod" => ["recipe[apache2]"], "staging" => ["recipe[apache2::staging]"], "_default" => []
 
-mcast_addr = Grid::CLUSTERS[:base][:nagioses][:mcast_addr]
+this_cluster = Grid::CLUSTERS[:base]
+this_subcluster = Grid::CLUSTERS[:base][:nagioses]
+mcast_addr = this_subcluster[:mcast_addr]
 port = '8649'
+=begin
+# uni-cast
+udp_send_channels4ucast = []
+this_subcluster[:nodes].first(2).each {|host|
+  udp_send_channels4ucast.push(
+    {
+      'mcast_join' => '',
+      'host' => "#{host}.#{Grid::DOMAIN}",
+      'port' => port,
+      'ttl' => ''
+    }
+  )
+}
+=end
 
 host_templates = []
 hosts = []
@@ -80,7 +112,8 @@ nagios_objects = {
     {
       'contactgroup_name' => 'grid-admins',
       'alias' => 'Grid Administrators',
-      'members' => 'alice,bob'
+      'members' => 'root'
+      #'members' => 'alice,bob'
     }
   ],
   'hosts' => [
@@ -94,7 +127,7 @@ nagios_objects = {
       'notification_period' => '24x7',
       'notification_options' => 'd,u,r',
       'register' => '0',
-    },
+    }
   ] + host_templates + hosts,
   'hostgroups' => \
     hostgroups + [
@@ -102,65 +135,97 @@ nagios_objects = {
       {
         'hostgroup_name' => 'grid-servers',
         'alias' => 'GridServers',
-        'members' => hostgroup_names.join(',')
+        'hostgroup_members' => hostgroup_names.join(',')
       }
     ],
   'services' => [
+    # ganglia gmetad monitoring
+    {
+      'use' => 'generic-check_ganglia_cache-service',
+      'host_name' => 'localhost',
+      'contact_groups' => 'grid-admins',
+    },
+    {
+      'use' => 'generic-ganglia_heartbeat-service',
+      'hostgroup_name' => "#{this_cluster[:gmetads][:name]}",
+      'contact_groups' => 'grid-admins',
+    },
+    # standard monitoring.
     {
       'use' => 'generic-ping-service',
       'hostgroup_name' => 'grid-servers',
+      'contact_groups' => 'grid-admins',
     },
     {
       'use' => 'generic-ssh-service',
       'hostgroup_name' => 'grid-servers',
+      'contact_groups' => 'grid-admins',
     },
     {
       'use' => 'generic-ntp-service',
       'hostgroup_name' => 'grid-servers',
-    },
-    {
-      'use' => 'generic-check_ganglia_cache-service',
-      'hostgroup_name' => 'grid-servers',
+      'contact_groups' => 'grid-admins',
     },
     {
       'use' => 'generic-load_one-service',
       'hostgroup_name' => 'grid-servers',
+      'contact_groups' => 'grid-admins',
     },
     {
       'use' => 'generic-load_five-service',
       'hostgroup_name' => 'grid-servers',
+      'contact_groups' => 'grid-admins',
     },
     {
       'use' => 'generic-load_fifteen-service',
       'hostgroup_name' => 'grid-servers',
+      'contact_groups' => 'grid-admins',
     },
     {
       'use' => 'generic-part_max_used-service',
       'hostgroup_name' => 'grid-servers',
+      'contact_groups' => 'grid-admins',
     },
     {
       'use' => 'generic-proc_total-service',
       'hostgroup_name' => 'grid-servers',
+      'contact_groups' => 'grid-admins',
     },
     {
       'use' => 'generic-http-service',
-      'hostgroup_name' => 'ganglia,nagioses',
+      'hostgroup_name' \
+        => "#{this_cluster[:gmetads][:name]},#{this_cluster[:nagioses][:name]}",
+      'contact_groups' => 'grid-admins',
     },
 =begin
     {
       'use' => 'generic-ldap-service',
       'hostgroup_name' => 'grid-nameservice-servers',
       'check_command' => 'check_ldap3!dc=grid,dc=example,dc=com',
+      'contact_groups' => 'grid-admins',
     },
 =end
   ],
+  'servicedependencies' => [
+    {
+      'host_name' => 'localhost',
+      'service_description' => 'Cache for check_ganglia_metric',
+      #'dependent_host_name' => '.*',  # NG!
+      'dependent_hostgroup_name' => 'grid-servers',
+      'dependent_service_description' => '.* via Ganglia$',
+      'execution_failure_criteria' => 'c,p'
+    }
+  ]
 }
 
 default_attributes(
   'nagios' => {
+    'cluster_name' => 'grid-base',
     'objects' => nagios_objects,
     'web' => {
-      'Allow' => ["from .#{Grid::DOMAIN}"],
+      'Allow' => [
+        "from .#{Grid::DOMAIN}",
+        'from 192.168.0.0/16'],
       'AuthType' => 'Kerberos',
       'mod_auth_kerb' => {
         'KrbAuthRealms' => Grid::REALM,
@@ -178,7 +243,7 @@ default_attributes(
     'authorized_for_all_host_commands' => '*',
     'check_ganglia_metric' => {
       'enabled' => true,
-      'gmetad_host' => "gm90.#{Grid::DOMAIN}"
+      'gmetad_host' => "#{this_cluster[:gmetads][:service_hostname]}.#{Grid::DOMAIN}"
     },
   }
 )
@@ -187,7 +252,7 @@ override_attributes(
   'ganglia' => {
     # gmond
     'cluster' => {
-      'name' => Grid::CLUSTERS[:base][:nagioses][:alias],
+      'name' => this_subcluster[:alias],
       'owner' => Grid::DOMAIN
     },
     'static' => {
@@ -209,20 +274,7 @@ override_attributes(
       ]
 =begin
       ## static uni-cast
-      'udp_send_channels' => [
-        {
-          'mcast_join' => '',
-          'host' => "nm00.#{Grid::DOMAIN}",
-          'port' => port,
-          'ttl' => ''
-        },
-        {
-          'mcast_join' => '',
-          'host' => "nm01.#{Grid::DOMAIN}",
-          'port' => port,
-          'ttl' => ''
-        }
-      ],
+      'udp_send_channels' => udp_send_channels4ucast,
       'udp_recv_channels' => [
         {
           'mcast_join' => '',