Implicitly configure Nagios outputs if available

Change-Id: Ibf5b4c2239004a4fa8e99bcaaf2949a5155543ed
This commit is contained in:
Swann Croiset 2017-01-09 13:21:24 +01:00
parent b7c7e7bdc2
commit 3bd7d7d76a
2 changed files with 13 additions and 23 deletions

View File

@ -143,25 +143,21 @@ if ($plugin_data) {
} }
} }
if $plugin_data['alerting_mode'] { # Infrastructure Alerting
# Infrastructure Alerting $lma_infra_alerting = hiera('lma_infrastructure_alerting', {})
$lma_infra_alerting = hiera('lma_infrastructure_alerting', {}) $infra_alerting_nodes = get_nodes_hash_by_roles($network_metadata, ['infrastructure_alerting', 'primary-infrastructure_alerting'])
$infra_alerting_nodes = get_nodes_hash_by_roles($network_metadata, ['infrastructure_alerting', 'primary-infrastructure_alerting']) $infra_alerting_nodes_count = count($infra_alerting_nodes)
$infra_alerting_nodes_count = count($infra_alerting_nodes) $infra_vip_name = 'infrastructure_alerting_mgmt_vip'
$infra_vip_name = 'infrastructure_alerting_mgmt_vip' if $network_metadata['vips'][$infra_vip_name] {
if $network_metadata['vips'][$infra_vip_name] { $nagios_server = $network_metadata['vips'][$infra_vip_name]['ipaddr']
$nagios_server = $network_metadata['vips'][$infra_vip_name]['ipaddr']
} else {
$nagios_server = undef
}
$nagios_password = $lma_infra_alerting['nagios_password'] $nagios_password = $lma_infra_alerting['nagios_password']
if $infra_alerting_nodes_count > 0 or $nagios_server {
$nagios_is_deployed = true
} else {
$nagios_is_deployed = false
}
} else { } else {
$nagios_is_deployed = false $nagios_server = undef
}
if $infra_alerting_nodes_count > 0 and $nagios_server {
$nagios_is_deployed = true
} else {
$nagios_is_deployed = false
} }
$hiera_file = '/etc/hiera/plugins/lma_collector.yaml' $hiera_file = '/etc/hiera/plugins/lma_collector.yaml'

View File

@ -87,9 +87,3 @@ attributes:
type: "password" type: "password"
regex: *not_empty_parameter regex: *not_empty_parameter
restrictions: *disable_influxdb_parameters restrictions: *disable_influxdb_parameters
alerting_mode:
type: "checkbox"
weight: 90
value: true
label: "Alerts sent to the StackLight Infrastructure Alerting plugin (Nagios) if deployed."