Add service checks for the LMA backend components
Add simple HTTP checks for Elasticsearch, Kibana, InfluxDB and Grafana. These checks verify the HTTP return code and the presence of one expected string in the response. Change-Id: Iff7c55e6525d86745d710dda3afc01f0cbef6bf1
This commit is contained in:
parent
2bae4e709e
commit
262ba9baa7
@ -131,4 +131,48 @@ if $plugin['node_name'] == hiera('user_node_name') {
|
||||
require => Class[lma_infra_alerting],
|
||||
}
|
||||
}
|
||||
|
||||
# Configure Grafana and InfluxDB checks
|
||||
$influxdb_grafana = hiera('influxdb_grafana', {})
|
||||
$influxdb_node_name = $influxdb_grafana['node_name']
|
||||
$influxdb_nodes = filter_nodes(hiera('nodes'), 'user_node_name', $influxdb_node_name)
|
||||
if ! empty($influxdb_nodes){
|
||||
lma_infra_alerting::nagios::check_http { 'Grafana':
|
||||
host_name => $influxdb_nodes[0]['name'],
|
||||
port => $lma_infra_alerting::params::grafana_port,
|
||||
url => '/login',
|
||||
custom_var_address => 'internal_address',
|
||||
string_expected_in_content => 'grafana',
|
||||
}
|
||||
lma_infra_alerting::nagios::check_http { 'InfluxDB':
|
||||
host_name => $influxdb_nodes[0]['name'],
|
||||
port => $lma_infra_alerting::params::influxdb_port,
|
||||
url => '/ping',
|
||||
custom_var_address => 'internal_address',
|
||||
string_expected_in_status => '204 No Content',
|
||||
string_expected_in_headers => 'X-Influxdb-Version',
|
||||
}
|
||||
}
|
||||
|
||||
# Configure Elasticsearch and Kibana checks
|
||||
$es_kibana = hiera('elasticsearch_kibana', {})
|
||||
$es_node_name = $es_kibana['node_name']
|
||||
$es_kibana_nodes = filter_nodes(hiera('nodes'), 'user_node_name', $es_node_name)
|
||||
if ! empty($es_kibana_nodes){
|
||||
lma_infra_alerting::nagios::check_http { 'Kibana':
|
||||
host_name => $es_kibana_nodes[0]['name'],
|
||||
port => $lma_infra_alerting::params::kibana_port,
|
||||
url => '/',
|
||||
custom_var_address => 'internal_address',
|
||||
string_expected_in_content => 'Kibana 3',
|
||||
}
|
||||
|
||||
lma_infra_alerting::nagios::check_http { 'Elasticsearch':
|
||||
host_name => $es_kibana_nodes[0]['name'],
|
||||
port => $lma_infra_alerting::params::elasticserach_port,
|
||||
url => '/',
|
||||
custom_var_address => 'internal_address',
|
||||
string_expected_in_content => '"status" : 200',
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,91 @@
|
||||
# Copyright 2015 Mirantis, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
# === Resource lma_infra_alerting::nagios::check_http
|
||||
#
|
||||
# Configure HTTP check
|
||||
#
|
||||
# === Parameters
|
||||
# host_name: The nagios host name
|
||||
# custom_var_address: (optional) the name of the custom variable used for the
|
||||
# IP address, if not defined the address of the host is used.
|
||||
# port: the HTTP port
|
||||
# url: URL to GET
|
||||
# string_expected_*: string to expect in the response
|
||||
# response_time_*: configure the warning and critical thresholds of the response time
|
||||
# timeout: seconds before connection times out
|
||||
#
|
||||
define lma_infra_alerting::nagios::check_http(
|
||||
$host_name = undef,
|
||||
$custom_var_address = undef,
|
||||
$port = undef,
|
||||
$url = '/',
|
||||
$string_expected_in_status = '200 OK',
|
||||
$string_expected_in_content = undef,
|
||||
$string_expected_in_headers = undef,
|
||||
$response_time_warning = 2,
|
||||
$response_time_critical = 3,
|
||||
$timeout = 5,
|
||||
){
|
||||
|
||||
include lma_infra_alerting::params
|
||||
|
||||
$prefix = $lma_infra_alerting::params::nagios_config_filename_prefix
|
||||
|
||||
$base_options = "-w ${response_time_warning} -c ${response_time_critical} -t ${timeout}"
|
||||
$port_option = "-p ${port}"
|
||||
$url_option = "-u '${url}'"
|
||||
if $string_expected_in_status {
|
||||
$expect_in_status_option = "-e '${string_expected_in_status}'"
|
||||
} else {
|
||||
$expect_in_status_option = ''
|
||||
}
|
||||
if $string_expected_in_content {
|
||||
$expect_in_content_option = "-s '${string_expected_in_content}'"
|
||||
} else {
|
||||
$expect_in_content_option = ''
|
||||
}
|
||||
if $string_expected_in_headers {
|
||||
$expect_in_headers_option = "-d '${string_expected_in_headers}'"
|
||||
} else {
|
||||
$expect_in_headers_option = ''
|
||||
}
|
||||
|
||||
if $custom_var_address {
|
||||
$up_var= upcase($custom_var_address)
|
||||
$hostaddress = "\$_HOST${up_var}\$"
|
||||
$check_command = "check_http_${name}_${custom_var_address}"
|
||||
} else {
|
||||
$hostaddress = '$HOSTADDRESS$'
|
||||
$check_command = "check_http_${name}"
|
||||
}
|
||||
|
||||
nagios::command { $check_command:
|
||||
prefix => $prefix,
|
||||
properties => {
|
||||
command_line => rstrip("${nagios::params::nagios_plugin_dir}/check_http -4 -I '${hostaddress}' ${base_options} ${port_option} ${url_option} ${expect_in_status_option} ${expect_in_content_option} ${expect_in_headers_option}"),
|
||||
}
|
||||
}
|
||||
|
||||
nagios::service { "HTTP ${name}":
|
||||
prefix => $prefix,
|
||||
properties => {
|
||||
host_name => $host_name,
|
||||
check_command => $check_command,
|
||||
},
|
||||
defaults => {
|
||||
'use' => $lma_infra_alerting::params::nagios_generic_service_template,
|
||||
}
|
||||
}
|
||||
}
|
@ -81,4 +81,10 @@ class lma_infra_alerting::params {
|
||||
# lma_collector::params::nagios_hostname_service_status.
|
||||
# The numeric prefix is used to orderer the display in Nagios UI
|
||||
$nagios_openstack_hostname_prefix = '00-openstack-services'
|
||||
|
||||
# TCP ports of LMA backends and dashboards
|
||||
$influxdb_port = 8086
|
||||
$grafana_port = 8000
|
||||
$elasticserach_port = 9200
|
||||
$kibana_port = 80
|
||||
}
|
||||
|
@ -0,0 +1,27 @@
|
||||
# Copyright 2015 Mirantis, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'lma_infra_alerting::nagios::check_http' do
|
||||
let(:title) { :rscname}
|
||||
let(:facts) do
|
||||
{:kernel => 'Linux', :operatingsystem => 'Ubuntu',
|
||||
:osfamily => 'Debian', :operatingsystemrelease => '12.4'}
|
||||
end
|
||||
|
||||
describe 'with default' do
|
||||
it { should contain_nagios__command('check_http_rscname') }
|
||||
it { should contain_nagios__service('HTTP rscname') }
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user