From 81b55c1355684e83f98cd84a7cee07a37a0f9b33 Mon Sep 17 00:00:00 2001 From: Matthias Runge Date: Thu, 23 Jul 2020 11:07:03 +0200 Subject: [PATCH] Add options to limit the send queue length Collectd has the option to limit the send queue lenght for amqp1. This patch adds support for that. For reference, that was added in https://github.com/collectd/collectd/pull/3432/files --- manifests/plugin/amqp1.pp | 27 +++++++++++++--------- spec/classes/collectd_plugin_amqp1_spec.rb | 2 ++ templates/plugin/amqp1.conf.epp | 3 +++ 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/manifests/plugin/amqp1.pp b/manifests/plugin/amqp1.pp index 83c94f2e8..4e8950763 100644 --- a/manifests/plugin/amqp1.pp +++ b/manifests/plugin/amqp1.pp @@ -47,6 +47,10 @@ # before attempting to reconnect. # Defaults to 1 # +# [*send_queue_limit*] +# Limits the SentQueue to a defined value, helps to keep memory usage low +# when the write target does not respond. +# # [*interval*] # Interval setting for the plugin # Defaults to undef @@ -100,17 +104,18 @@ # preserved, i.e. passed through. # class collectd::plugin::amqp1 ( - Enum['present', 'absent'] $ensure = 'present', - Boolean $manage_package = $collectd::manage_package, - String $transport = 'metrics', - Stdlib::Host $host = 'localhost', - Stdlib::Port $port = 5672, - String $user = 'guest', - String $password = 'guest', - String $address = 'collectd', - Hash $instances = {}, - Optional[Integer] $retry_delay = undef, - Optional[Integer] $interval = undef, + Enum['present', 'absent'] $ensure = 'present', + Boolean $manage_package = $collectd::manage_package, + String $transport = 'metrics', + Stdlib::Host $host = 'localhost', + Stdlib::Port $port = 5672, + String $user = 'guest', + String $password = 'guest', + String $address = 'collectd', + Hash $instances = {}, + Optional[Integer] $retry_delay = undef, + Optional[Integer] $send_queue_limit = undef, + Optional[Integer] $interval = undef, ) { include collectd diff --git a/spec/classes/collectd_plugin_amqp1_spec.rb b/spec/classes/collectd_plugin_amqp1_spec.rb index dd9d8e34d..ae68420ea 100644 --- a/spec/classes/collectd_plugin_amqp1_spec.rb +++ b/spec/classes/collectd_plugin_amqp1_spec.rb @@ -45,6 +45,7 @@ password: 'password', address: 'address', retry_delay: 30, + send_queue_limit: 40, instances: { instance: { format: 'JSON', @@ -68,6 +69,7 @@ it { is_expected.to contain_file('amqp1.load').with(content: %r{Password "password"}) } it { is_expected.to contain_file('amqp1.load').with(content: %r{Address "address"}) } it { is_expected.to contain_file('amqp1.load').with(content: %r{RetryDelay 30}) } + it { is_expected.to contain_file('amqp1.load').with(content: %r{SendQueueLimit 40}) } it { is_expected.to contain_file('amqp1.load').with(content: %r{}) } it { is_expected.to contain_file('amqp1.load').with(content: %r{Format "JSON"}) } it { is_expected.to contain_file('amqp1.load').with(content: %r{PreSettle true}) } diff --git a/templates/plugin/amqp1.conf.epp b/templates/plugin/amqp1.conf.epp index b7fac2d1c..fdf44989b 100644 --- a/templates/plugin/amqp1.conf.epp +++ b/templates/plugin/amqp1.conf.epp @@ -8,6 +8,9 @@ <% unless $::collectd::plugin::amqp1::retry_delay =~ Undef { -%> RetryDelay <%= $::collectd::plugin::amqp1::retry_delay %> <% } -%> +<% unless $::collectd::plugin::amqp1::send_queue_limit =~ Undef { -%> + SendQueueLimit <%= $::collectd::plugin::amqp1::send_queue_limit %> +<% } -%> <% $::collectd::plugin::amqp1::instances.keys.sort.each |$name| { -%> "> <% $::collectd::plugin::amqp1::instances[$name].keys.sort.each |$key| { -%>