70 lines
2.7 KiB
Puppet
70 lines
2.7 KiB
Puppet
# 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.
|
|
#
|
|
define lma_collector::afd_nagios(
|
|
$server,
|
|
$http_port,
|
|
$http_path,
|
|
$user,
|
|
$password,
|
|
$http_scheme = 'http',
|
|
$ensure = present,
|
|
$hostname = $::hostname,
|
|
$service_template = '%{node_role}.%{source}',
|
|
$message_type = 'afd_node_metric',
|
|
){
|
|
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}":
|
|
ensure => $ensure,
|
|
config_dir => $lma_collector::params::metric_config_dir,
|
|
filename => "${lma_collector::params::plugins_dir}/encoders/status_nagios.lua",
|
|
config => $config,
|
|
module_directory => $lua_modules_dir,
|
|
notify => Class['lma_collector::service::metric'],
|
|
}
|
|
|
|
$matcher = join(["Fields[${lma_collector::params::aggregator_flag}] == NIL",
|
|
"Type == 'heka.sandbox.${message_type}'",
|
|
'Fields[no_alerting] == NIL',
|
|
'Fields[hostname] != NIL'], ' && ')
|
|
|
|
heka::output::http { "nagios_afd_${title}":
|
|
ensure => $ensure,
|
|
config_dir => $lma_collector::params::metric_config_dir,
|
|
url => $url,
|
|
message_matcher => $matcher,
|
|
username => $user,
|
|
password => $password,
|
|
encoder => "nagios_afd_${title}",
|
|
timeout => $lma_collector::params::nagios_timeout,
|
|
headers => {
|
|
'Content-Type' => 'application/x-www-form-urlencoded'
|
|
},
|
|
use_buffering => $lma_collector::params::buffering_enabled,
|
|
max_buffer_size => $lma_collector::params::buffering_max_buffer_size_for_nagios,
|
|
max_file_size => $lma_collector::params::buffering_max_file_size_for_nagios,
|
|
queue_full_action => $lma_collector::params::queue_full_action_for_nagios,
|
|
require => Heka::Encoder::Sandbox["nagios_afd_${title}"],
|
|
notify => Class['lma_collector::service::metric'],
|
|
}
|
|
}
|