Support activate_alerting and enable_notification properties for GSE

blueprint: alarming-refactoring
Change-Id: Ifdc6d4f8ae273af0db354cbc7c57c0ae5aa70808
This commit is contained in:
Swann Croiset 2016-09-14 00:15:43 +02:00
parent 086b96b7c6
commit 9d5c256e13
5 changed files with 62 additions and 17 deletions

View File

@ -56,17 +56,26 @@ $tls_enabled = $nagios_ui['tls_enabled']
$lma_collector = hiera_hash('lma_collector', {})
if $lma_collector['gse_cluster_global'] {
$service_clusters = keys($lma_collector['gse_cluster_global']['clusters'])
if $lma_collector['gse_cluster_global'] and $lma_collector['gse_cluster_global']['activate_alerting'] {
$global_clusters = keys($lma_collector['gse_cluster_global']['clusters'])
$notification_for_global_clusters = $lma_collector['gse_cluster_global']['enable_notification']
}else{
$global_clusters = []
}
if $lma_collector['gse_cluster_node'] and $lma_collector['gse_cluster_node']['activate_alerting'] {
$node_clusters = keys($lma_collector['gse_cluster_node']['clusters'])
$notification_for_node_clusters = $lma_collector['gse_cluster_node']['enable_notification']
}else{
$node_clusters = []
}
if $lma_collector['gse_cluster_service'] and $lma_collector['gse_cluster_service']['activate_alerting'] {
$service_clusters = keys($lma_collector['gse_cluster_service']['clusters'])
$notification_for_service_clusters = $lma_collector['gse_cluster_service']['enable_notification']
}else{
$service_clusters = []
}
if $lma_collector['gse_cluster_node'] {
$node_clusters = keys($lma_collector['gse_cluster_node']['clusters'])
}else{
$node_clusters = []
}
# Install and configure nagios server for StackLight
class { 'lma_infra_alerting::nagios':
@ -96,11 +105,15 @@ class { 'lma_infra_alerting::nagios':
}
class { 'lma_infra_alerting::nagios::vhost':
openstack_deployment_name => $env_id,
openstack_management_vip => $cluster_ip,
global_clusters => $service_clusters,
node_clusters => $node_clusters,
require => Class['lma_infra_alerting::nagios'],
openstack_deployment_name => $env_id,
openstack_management_vip => $cluster_ip,
global_clusters => $global_clusters,
notification_for_global_clusters => $notification_for_global_clusters,
node_clusters => $node_clusters,
notification_for_service_clusters => $notification_for_service_clusters,
service_clusters => $service_clusters,
notification_for_node_clusters => $notification_for_node_clusters,
require => Class['lma_infra_alerting::nagios'],
}
$configure_arp_filter_for_vip = '/usr/local/bin/configure_arp_filter_for_vip'

View File

@ -19,7 +19,11 @@ class lma_infra_alerting::nagios::vhost (
$openstack_management_vip = undef,
$openstack_deployment_name = '',
$global_clusters = [],
$notification_for_global_clusters = 1,
$node_clusters = [],
$notification_for_node_clusters = 1,
$service_clusters = [],
$notification_for_service_clusters = 0,
) inherits lma_infra_alerting::params {
validate_array($global_clusters, $node_clusters)
@ -30,24 +34,51 @@ class lma_infra_alerting::nagios::vhost (
$vhostname_node = join([
$lma_infra_alerting::params::nagios_node_vhostname_prefix,
'-env', $openstack_deployment_name], '')
$vhostname_service = join([
$lma_infra_alerting::params::nagios_service_vhostname_prefix,
'-env', $openstack_deployment_name], '')
if ! empty($global_clusters) {
# Configure the virtual host for the global clusters
if $notification_for_global_clusters {
$global_notification = 1
} else {
$global_notification = 0
}
lma_infra_alerting::nagios::vhost_cluster_status{ 'global':
ip => $openstack_management_vip,
hostname => $vhostname_global,
services => $global_clusters,
notifications_enabled => 1,
notifications_enabled => $global_notification,
}
}
if ! empty($node_clusters) {
if $notification_for_node_clusters {
$node_notification = 1
} else {
$node_notification = 0
}
# Configure the virtual host for the node clusters
lma_infra_alerting::nagios::vhost_cluster_status{ 'nodes':
ip => $openstack_management_vip,
hostname => $vhostname_node,
services => $node_clusters,
notifications_enabled => 0,
notifications_enabled => $node_notification,
}
}
if ! empty($service_clusters) {
# Configure the virtual host for the service clusters
if $notification_for_service_clusters {
$service_notification = 1
} else {
$service_notification = 0
}
lma_infra_alerting::nagios::vhost_cluster_status{ 'services':
ip => $openstack_management_vip,
hostname => $vhostname_service,
services => $service_clusters,
notifications_enabled => $service_notification,
}
}
}

View File

@ -51,6 +51,6 @@ define lma_infra_alerting::nagios::vhost_cluster_status(
hostname => $hostname,
notifications_enabled => $notifications_enabled,
contact_group => $contact_group,
services => $services,
services => prefix($services, "${title} "),
}
}

View File

@ -88,6 +88,7 @@ class lma_infra_alerting::params {
# The numeric prefix is used to fix the display order in the Nagios UI
$nagios_global_vhostname_prefix = '00-global-clusters'
$nagios_node_vhostname_prefix = '00-node-clusters'
$nagios_service_vhostname_prefix = '00-service-clusters'
# TCP ports of LMA backends and dashboards
$influxdb_port = 8086

View File

@ -28,8 +28,8 @@ describe 'lma_infra_alerting::nagios::vhost_cluster_status' do
describe 'with 2 services' do
it { should contain_nagios__host('foohost') }
it { should contain_lma_infra_alerting__nagios__services('footitle for foohost') }
it { should contain_nagios__service('a') }
it { should contain_nagios__service('b') }
it { should contain_nagios__service('footitle a') }
it { should contain_nagios__service('footitle b') }
end
end