Remove the remote Nagios alerting mode

This use case is not really supported because Nagios configuration is
too dependent on the LMA Collector plugin and in practice, no one
chooses this option.

DocImpact

Change-Id: Ia09efb40f476c1daec51530e2c0fb16bc6f99393
This commit is contained in:
Swann Croiset 2016-05-24 13:48:56 +02:00
parent a513e7aaea
commit 123a86590f
8 changed files with 40 additions and 64 deletions

View File

@ -45,12 +45,14 @@ class { 'fuel_lma_collector::afds':
}
# Forward AFD status to Nagios if deployed
if hiera('lma::collector::infrastructure_alerting::url', false) {
if hiera('lma::collector::infrastructure_alerting::server', false) {
lma_collector::afd_nagios { 'nodes':
ensure => present,
hostname => $::hostname,
url => hiera('lma::collector::infrastructure_alerting::url'),
user => hiera('lma::collector::infrastructure_alerting::user'),
password => hiera('lma::collector::infrastructure_alerting::password'),
ensure => present,
hostname => $::hostname,
server => hiera('lma::collector::infrastructure_alerting::server'),
http_port => hiera('lma::collector::infrastructure_alerting::http_port'),
http_path => hiera('lma::collector::infrastructure_alerting::http_path'),
user => hiera('lma::collector::infrastructure_alerting::user'),
password => hiera('lma::collector::infrastructure_alerting::password'),
}
}

View File

@ -450,10 +450,12 @@ if $alerting_mode == 'standalone' {
}
}
if hiera('lma::collector::infrastructure_alerting::url', false) {
if hiera('lma::collector::infrastructure_alerting::server', false) {
lma_collector::gse_nagios { 'global_clusters':
openstack_deployment_name => $deployment_id,
url => hiera('lma::collector::infrastructure_alerting::url'),
server => hiera('lma::collector::infrastructure_alerting::server'),
http_port => hiera('lma::collector::infrastructure_alerting::http_port'),
http_path => hiera('lma::collector::infrastructure_alerting::http_path'),
user => hiera('lma::collector::infrastructure_alerting::user'),
password => hiera('lma::collector::infrastructure_alerting::password'),
message_type => $lma_collector['gse_cluster_global']['output_message_type'],
@ -463,7 +465,9 @@ if hiera('lma::collector::infrastructure_alerting::url', false) {
lma_collector::gse_nagios { 'node_clusters':
openstack_deployment_name => $deployment_id,
url => hiera('lma::collector::infrastructure_alerting::url'),
server => hiera('lma::collector::infrastructure_alerting::server'),
http_port => hiera('lma::collector::infrastructure_alerting::http_port'),
http_path => hiera('lma::collector::infrastructure_alerting::http_path'),
user => hiera('lma::collector::infrastructure_alerting::user'),
password => hiera('lma::collector::infrastructure_alerting::password'),
message_type => $lma_collector['gse_cluster_node']['output_message_type'],

View File

@ -100,11 +100,6 @@ if ($plugin_data) {
$infra_alerting_nodes_count = count($infra_alerting_nodes)
case $alerting_mode {
'remote': {
$nagios_url = $plugin_data['nagios_url']
$nagios_user = $plugin_data['nagios_user']
$nagios_password = $lma['nagios_password']
}
'local': {
$infra_vip_name = 'infrastructure_alerting_mgmt_vip'
if $network_metadata['vips'][$infra_vip_name] {
@ -114,22 +109,14 @@ if ($plugin_data) {
} else {
$nagios_server = undef
}
$nagios_user = 'nagiosadmin'
$nagios_password = $lma_infra_alerting['nagios_password']
if $nagios_server {
# Important: $http_port and $http_path must match the
# lma_infra_monitoring configuration.
$nagios_http_port = 8001
$nagios_http_path = 'status'
$nagios_url = "http://${nagios_server}:${nagios_http_port}/${nagios_http_path}"
}
}
default: {
fail("'${alerting_mode}' mode not supported for Nagios")
}
}
if $infra_alerting_nodes_count > 0 or $nagios_url {
if $infra_alerting_nodes_count > 0 or $nagios_server {
$nagios_is_deployed = true
} else {
$nagios_is_deployed = false
@ -151,8 +138,10 @@ lma::collector::influxdb::user: <%= @influxdb_user %>
lma::collector::influxdb::password: <%= @influxdb_password %>
<% end -%>
<% if @nagios_is_deployed -%>
lma::collector::infrastructure_alerting::url: <%= @nagios_url %>
lma::collector::infrastructure_alerting::user: <%= @nagios_user %>
lma::collector::infrastructure_alerting::server: <%= @nagios_server %>
lma::collector::infrastructure_alerting::http_port: 8001
lma::collector::infrastructure_alerting::http_path: status
lma::collector::infrastructure_alerting::user: nagiosadmin
lma::collector::infrastructure_alerting::password: <%= @nagios_password %>
<% end -%>
')

View File

@ -13,9 +13,12 @@
# under the License.
#
define lma_collector::afd_nagios(
$url,
$server,
$http_port,
$http_path,
$user,
$password,
$http_scheme = 'http',
$ensure = present,
$hostname = $::hostname,
$service_template = '%{node_role}.%{source}',
@ -24,7 +27,10 @@ define lma_collector::afd_nagios(
include lma_collector::params
include lma_collector::service::metric
validate_integer($http_port)
$lua_modules_dir = $lma_collector::params::lua_modules_dir
$url = "${http_scheme}://${server}:${http_port}/${http_path}"
$config = {'nagios_host' => $hostname, 'service_template' => $service_template}
heka::encoder::sandbox { "nagios_afd_${title}":

View File

@ -13,21 +13,25 @@
# under the License.
#
define lma_collector::gse_nagios (
$url,
$server,
$http_port,
$http_path,
$user,
$password,
$message_type,
$virtual_hostname,
$ensure = present,
$http_scheme = 'http',
$openstack_deployment_name = '',
$service_template = '%{cluster_name}',
) {
include lma_collector::params
include lma_collector::service::metric
$lua_modules_dir = $lma_collector::params::lua_modules_dir
validate_integer($http_port)
validate_string($url)
$lua_modules_dir = $lma_collector::params::lua_modules_dir
$url = "${http_scheme}://${server}:${http_port}/${http_path}"
# This must be identical logic than in lma-infra-alerting-plugin
$_nagios_host = "${virtual_hostname}-env${openstack_deployment_name}"

View File

@ -20,7 +20,9 @@ describe 'lma_collector::afd_nagios' do
:osfamily => 'Debian'}
end
let(:params) do
{:url => 'http://nagios.org',
{:server => 'nagios.org',
:http_port => 9999,
:http_path => 'status',
:user => 'foo',
:password => 'secret',
:message_type => 'foo_type'

View File

@ -20,7 +20,9 @@ describe 'lma_collector::gse_nagios' do
:osfamily => 'Debian'}
end
let(:params) do
{:url => 'http://nagios.org',
{:server => 'nagios.org',
:http_port => 9999,
:http_path => 'status',
:user => 'foo',
:password => 'secret',
:message_type => 'foo_type',

View File

@ -98,8 +98,6 @@ attributes:
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: "remote"
label: "Alerts sent to a remote Nagios server"
alerting_send_to:
value: ''
@ -165,34 +163,3 @@ attributes:
weight: 97
type: "password"
restrictions: *not_standalone_and_no_auth
nagios_url:
value: ''
label: 'Nagios URL'
description: 'ie: http://<server>/nagios3/cgi-bin/cmd.cgi'
weight: 100
type: "text"
regex: &node_url_regex
source: '^(http(s?):\/\/)?([a-zA-Z\d]+[a-zA-Z\d_\-.]*)(:[0-9]+)?(\/[a-zA-Z0-9_\-\s.\/\?%#&=]*)?$'
error: "Invalid URL"
restrictions: &not_remote
- condition: "settings:lma_collector.alerting_mode.value != 'remote'"
action: "disable"
nagios_user:
value: 'nagiosadmin'
label: 'Nagios user'
description: ''
weight: 105
type: "text"
regex: *not_empty_parameter
restrictions: *not_remote
nagios_password:
value: ''
label: 'Nagios password'
description: ''
weight: 110
type: "password"
regex: *not_empty_parameter
restrictions: *not_remote