Merge "Support activate_alarming and enable_notification"

This commit is contained in:
Jenkins 2016-09-20 07:54:49 +00:00 committed by Gerrit Code Review
commit 3d223a2f65
3 changed files with 93 additions and 21 deletions

View File

@ -75,22 +75,37 @@ Would return:
node_clusters.each do |node, clusters|
clusters << "default" if clusters.empty?
node_services = {}
clusters.each do |cluster|
notifications_enabled = 0
afds_map = afds.select {|c, a| a.has_key?('apply_to_node') and a['apply_to_node'] == cluster}
afds_map.each do |c, a|
a['alarms'].keys.each do |source|
node_services["#{node}.#{cluster}.#{source}"] = "#{ cluster }.#{ source }".gsub(/\s+/, '_')
afds_map.each do |logical_cluster, a|
node_services = {}
if not a.has_key?('activate_alerting')
configure=true
elsif a['activate_alerting'] == true
configure=true
else
configure=false
end
if configure
if a.has_key?('enable_notification') and a['enable_notification'] == true
notifications_enabled = 1
end
a['alarms'].keys.each do |source|
node_services["#{node}.#{logical_cluster}.#{source}"] = "#{ logical_cluster }.#{ source }".gsub(/\s+/, '_')
end
end
unless node_services.empty? then
result["#{ logical_cluster } checks for #{ node }"] = {
'hostname' => node,
'services' => node_services,
'notifications_enabled' => notifications_enabled,
}
end
end
end
unless node_services.empty? then
result["#{ clusters.to_a.sort.join(', ') } checks for #{ node }"] = {
'hostname' => node,
'services' => node_services
}
end
end
return result

View File

@ -74,16 +74,14 @@ class lma_infra_alerting::nagios::hosts (
$role_key,
$node_profiles,
$node_cluster_alarms)
#$afd_service_defaults = {'notifications_enabled' => 0}
create_resources(lma_infra_alerting::nagios::services, $afd_nodes, {})
create_resources(lma_infra_alerting::nagios::services, $afd_nodes)
$afd_services = afds_to_nagios_services($hosts,
$host_name_key,
$role_key,
$node_profiles,
$service_cluster_alarms)
$afd_service_defaults = {'notifications_enabled' => 0}
create_resources(lma_infra_alerting::nagios::services, $afd_services, $afd_service_defaults)
create_resources(lma_infra_alerting::nagios::services, $afd_services)
if empty($node_profiles) and empty($node_cluster_alarms) {
$node_uid= hiera('uid')

View File

@ -16,6 +16,16 @@ require 'spec_helper'
describe 'afds_to_nagios_services' do
all_nodes = [
{"fqdn" => "node-5.test.domain.local",
"internal_address" => "10.109.5.5",
"internal_netmask" => "255.255.255.0",
"name" => "node-5",
"node_roles" => ["elasticsearch_kibana"],
"storage_address" => "10.109.10.2",
"storage_netmask" => "255.255.255.0",
"swift_zone" => "1",
"uid" => "5",
"user_node_name" => "slave-03_alerting"},
{"fqdn" => "node-1.test.domain.local",
"internal_address" => "10.109.2.5",
"internal_netmask" => "255.255.255.0",
@ -58,16 +68,29 @@ describe 'afds_to_nagios_services' do
"swift_zone" => "2",
"uid" => "2",
"user_node_name" => "slave-02_compute_cinder"},
{"fqdn" => "node-42.test.domain.local",
"internal_address" => "10.109.2.42",
"internal_netmask" => "255.255.255.0",
"name" => "node-2",
"node_roles" => ["foo-role"],
"storage_address" => "10.109.4.42",
"storage_netmask" => "255.255.255.0",
"swift_zone" => "2",
"uid" => "42",
"user_node_name" => "slave-42_foo-role"},
]
role_to_cluster = {
"controller" => {"roles" => ["primary-controller", "controller"]},
"compute" => {"roles" => ["compute"]},
"storage" => {"roles" => ["cinder", "ceph-osd"]}
"storage" => {"roles" => ["cinder", "ceph-osd"]},
"elasticsearch" => {"roles" => ["elasticsearch_kibana"]},
"foo" => {"roles" => ["foo-role"]}
}
afds = {
"controller" => {
"apply_to_node" => "controller",
"enable_notification" => true,
"alarms" => {
"system-ctrl" => ["cpu-critical-controller", "cpu-warning-controller"],
"fs" => ["fs-critical", "fs-warning"]
@ -75,6 +98,7 @@ describe 'afds_to_nagios_services' do
},
"compute" => {
"apply_to_node" => "compute",
"enable_notification" => true,
"alarms" => {
"system-compute" => ["cpu-critical-compute", "cpu-warning-compute"],
"fs" => ["fs-critical", "fs-critical-compute", "fs-warning"]
@ -82,13 +106,31 @@ describe 'afds_to_nagios_services' do
},
"storage" => {
"apply_to_node" => "storage",
"enable_notification" => true,
"alarms" => {
"system-storage" => ["cpu-critical-storage", "cpu-warning-storage"],
"fs" => ["fs-critical-storage", "fs-warning-storage"]
}
},
"elasticsearch-cluster" => {
"apply_to_node" => "elasticsearch",
"activate_alerting" => true,
"alarms" => {
"cpu" => ["cpu-critical-es"],
"fs" => ["fs-critical-es", "fs-warning-es"]
}
},
"default" => {
"apply_to_node" => "default",
"activate_alerting" => true,
"alarms" => {
"cpu" => ["cpu-critical-default"],
"fs" => ["fs-critical", "fs-warning"]
}
},
"bar-cluster" => {
"apply_to_node" => "bar",
"activate_alerting" => false,
"alarms" => {
"cpu" => ["cpu-critical-default"],
"fs" => ["fs-critical", "fs-warning"]
@ -100,30 +142,47 @@ describe 'afds_to_nagios_services' do
{
"default checks for node-1" => {
"hostname" => "node-1",
"notifications_enabled" => 0,
"services" => {
"node-1.default.cpu" => "default.cpu",
"node-1.default.fs" => "default.fs",
}},
"controller checks for node-3" => {
"hostname" => "node-3",
"notifications_enabled" => 1,
"services" => {
"node-3.controller.fs" => "controller.fs",
"node-3.controller.system-ctrl" => "controller.system-ctrl"
}},
"default checks for node-4" => {
"elasticsearch-cluster checks for node-4" => {
"hostname" => "node-4",
"notifications_enabled" => 0,
"services" => {
"node-4.default.cpu" => "default.cpu",
"node-4.default.fs" => "default.fs"
"node-4.elasticsearch-cluster.cpu" => "elasticsearch-cluster.cpu",
"node-4.elasticsearch-cluster.fs" => "elasticsearch-cluster.fs"
}},
"compute, storage checks for node-2" => {
"elasticsearch-cluster checks for node-5" => {
"hostname" => "node-5",
"notifications_enabled" => 0,
"services" => {
"node-5.elasticsearch-cluster.cpu" => "elasticsearch-cluster.cpu",
"node-5.elasticsearch-cluster.fs" => "elasticsearch-cluster.fs"
}},
"compute checks for node-2" => {
"hostname" => "node-2",
"notifications_enabled" => 1,
"services" => {
"node-2.compute.fs" => "compute.fs",
"node-2.compute.system-compute" => "compute.system-compute",
}},
"storage checks for node-2" => {
"hostname" => "node-2",
"notifications_enabled" => 1,
"services" => {
"node-2.storage.fs" => "storage.fs",
"node-2.storage.system-storage" => "storage.system-storage"
}}})
}}
})
}
end
end