Try to configure Nagios by default

The LMA collector uses by default the "infrastructure alerting" plugin
to send statuses if it is deployed within the environnement.
Previously, the user had to select explicitly the good option but
in practice the user forgot to select this option which leads to UNKNOWN
status for all service in the Nagios UI

Change-Id: Ia08f7e7f6763aeb3710ba26f88bfce6130a218bd
Fixes-bug: #1541462
This commit is contained in:
Swann Croiset 2016-02-03 18:19:35 +01:00
parent 6ebef8aa0a
commit baeca5ef6f
4 changed files with 65 additions and 74 deletions

View File

@ -54,21 +54,3 @@ if $influxdb_mode == 'local' {
fail("Could not find node with role 'influxdb_grafana' in the environment")
}
}
$alerting_mode = $lma_collector['alerting_mode']
if $alerting_mode == 'local' {
# Check that the LMA-Infrastructure-Alerting plugin is enabled for that environment
# and that the node names match
$infra_alerting = hiera_hash('lma_infrastructure_alerting', false)
if ! $infra_alerting {
fail('Could not get the LMA Infrastructure Alerting parameters. The LMA-Infrastructure-Alerting plugin is probably not installed.')
}
elsif ! $infra_alerting['metadata']['enabled'] {
fail('Could not get the LMA Infrastructure Alerting parameters. The LMA-Infrastructure-Alerting plugin is probably not enabled for this environment.')
}
# Check that the LMA-Infrastructure-Alerting node exists in the environment
$infra_alerting_nodes = get_nodes_hash_by_roles($network_metadata, ['infrastructure_alerting', 'primary-infrastructure_alerting'])
if size(keys($infra_alerting_nodes)) < 1 {
fail("Could not find node with role 'infrastructure_alerting' in the environment")
}
}

View File

@ -41,7 +41,8 @@ class { 'lma_collector::afds':
alarms => $alarms_definitions,
}
# Forward AFD status to Nagios
# Forward AFD status to Nagios if deployed
$network_metadata = hiera_hash('network_metadata')
$alerting_mode = $lma['alerting_mode']
if $alerting_mode == 'remote' {
$nagios_enabled = true
@ -49,15 +50,25 @@ if $alerting_mode == 'remote' {
$nagios_user = $lma['nagios_user']
$nagios_password = $lma['nagios_password']
} elsif $alerting_mode == 'local' {
$nagios_enabled = true
$lma_infra_alerting = hiera_hash('lma_infrastructure_alerting', false)
$network_metadata = hiera_hash('network_metadata')
$nagios_server = $network_metadata['vips']['infrastructure_alerting_mgmt_vip']['ipaddr']
$nagios_user = $lma_infra_alerting['nagios_user']
$nagios_password = $lma_infra_alerting['nagios_password']
$http_port = $lma_collector::params::nagios_http_port
$http_path = $lma_collector::params::nagios_http_path
$nagios_url = "http://${nagios_server}:${http_port}/${http_path}"
$infra_alerting_nodes = get_nodes_hash_by_roles($network_metadata, ['infrastructure_alerting', 'primary-infrastructure_alerting'])
if size(keys($infra_alerting_nodes)) > 0 {
$nagios_enabled = true
$nagios_server = $network_metadata['vips']['infrastructure_alerting_mgmt_vip']['ipaddr']
$nagios_user = $lma_infra_alerting['nagios_user']
$nagios_password = $lma_infra_alerting['nagios_password']
$http_port = $lma_collector::params::nagios_http_port
$http_path = $lma_collector::params::nagios_http_path
$nagios_url = "http://${nagios_server}:${http_port}/${http_path}"
} else {
if ! $lma_infra_alerting {
notice('Could not get the LMA Infrastructure Alerting parameters. The LMA-Infrastructure-Alerting plugin is probably not installed.')
} elsif ! $lma_infra_alerting['metadata']['enabled'] {
notice('Could not get the LMA Infrastructure Alerting parameters. The LMA-Infrastructure-Alerting plugin is probably not enabled for this environment.')
} else {
notice('The LMA-Infrastructure-Alerting plugin is enabled but no alerting node for this environment.')
}
}
} else {
$nagios_enabled = false
}

View File

@ -257,18 +257,18 @@ if $lma_collector['influxdb_mode'] != 'disabled' {
}
$alerting_mode = $lma_collector['alerting_mode']
if $alerting_mode != 'disabled' {
$deployment_id = hiera('deployment_id')
if $alerting_mode == 'remote' {
$use_nagios = true
$nagios_url = $lma_collector['nagios_url']
$nagios_user = $lma_collector['nagios_user']
$nagios_password = $lma_collector['nagios_password']
} elsif $alerting_mode == 'local' {
$deployment_id = hiera('deployment_id')
if $alerting_mode == 'remote' {
$use_nagios = true
$nagios_url = $lma_collector['nagios_url']
$nagios_user = $lma_collector['nagios_user']
$nagios_password = $lma_collector['nagios_password']
} elsif $alerting_mode == 'local' {
$network_metadata = hiera_hash('network_metadata')
$infra_alerting_nodes = get_nodes_hash_by_roles($network_metadata, ['infrastructure_alerting', 'primary-infrastructure_alerting'])
if size(keys($infra_alerting_nodes)) > 0 {
$use_nagios = true
$lma_infra_alerting = hiera_hash('lma_infrastructure_alerting', false)
$network_metadata = hiera_hash('network_metadata')
$nagios_server = $network_metadata['vips']['infrastructure_alerting_mgmt_vip']['ipaddr']
$nagios_user = $lma_infra_alerting['nagios_user']
$nagios_password = $lma_infra_alerting['nagios_password']
@ -278,39 +278,39 @@ if $alerting_mode != 'disabled' {
$http_port = $lma_collector::params::nagios_http_port
$http_path = $lma_collector::params::nagios_http_path
$nagios_url = "http://${nagios_server}:${http_port}/${http_path}"
} elsif $alerting_mode == 'standalone' {
$use_nagios = false
$subject = "${lma_collector::params::smtp_subject} environment ${deployment_id}"
class { 'lma_collector::smtp_alert':
send_from => $lma_collector['alerting_send_from'],
send_to => [$lma_collector['alerting_send_to']],
subject => $subject,
host => $lma_collector['alerting_smtp_host'],
auth => $lma_collector['alerting_smtp_auth'],
user => $lma_collector['alerting_smtp_user'],
password => $lma_collector['alerting_smtp_password'],
}
} else {
fail("'${alerting_mode}' mode not supported for the infrastructure alerting service")
}
} elsif $alerting_mode == 'standalone' {
$use_nagios = false
$subject = "${lma_collector::params::smtp_subject} environment ${deployment_id}"
class { 'lma_collector::smtp_alert':
send_from => $lma_collector['alerting_send_from'],
send_to => [$lma_collector['alerting_send_to']],
subject => $subject,
host => $lma_collector['alerting_smtp_host'],
auth => $lma_collector['alerting_smtp_auth'],
user => $lma_collector['alerting_smtp_user'],
password => $lma_collector['alerting_smtp_password'],
}
} else {
fail("'${alerting_mode}' mode not supported for the infrastructure alerting service")
}
if $use_nagios {
lma_collector::gse_nagios { 'global_clusters':
openstack_deployment_name => $deployment_id,
url => $nagios_url,
user => $nagios_user,
password => $nagios_password,
message_type => $lma_collector['gse_cluster_global']['output_message_type'],
virtual_hostname => $lma_collector::params::nagios_hostname_for_cluster_global,
}
if $use_nagios {
lma_collector::gse_nagios { 'global_clusters':
openstack_deployment_name => $deployment_id,
url => $nagios_url,
user => $nagios_user,
password => $nagios_password,
message_type => $lma_collector['gse_cluster_global']['output_message_type'],
virtual_hostname => $lma_collector::params::nagios_hostname_for_cluster_global,
}
lma_collector::gse_nagios { 'node_clusters':
openstack_deployment_name => $deployment_id,
url => $nagios_url,
user => $nagios_user,
password => $nagios_password,
message_type => $lma_collector['gse_cluster_node']['output_message_type'],
virtual_hostname => $lma_collector::params::nagios_hostname_for_cluster_nodes,
}
lma_collector::gse_nagios { 'node_clusters':
openstack_deployment_name => $deployment_id,
url => $nagios_url,
user => $nagios_user,
password => $nagios_password,
message_type => $lma_collector['gse_cluster_node']['output_message_type'],
virtual_hostname => $lma_collector::params::nagios_hostname_for_cluster_nodes,
}
}

View File

@ -100,15 +100,13 @@ attributes:
alerting_mode:
type: "radio"
weight: 90
value: "disabled"
value: "local"
label: "Alerting"
values:
- data: "disabled"
label: "Disabled"
- data: "local"
label: "Alerts sent to a local cluster running the LMA Infrastructure Alerting plugin (if deployed)"
- data: "standalone"
label: "Alerts sent by email (requires a SMTP server)"
- data: "local"
label: "Alerts sent to a local node running the LMA Infrastructure Alerting plugin"
- data: "remote"
label: "Alerts sent to a remote Nagios server"
restrictions: *all_disabled_msg