From 81b55c1355684e83f98cd84a7cee07a37a0f9b33 Mon Sep 17 00:00:00 2001 From: Matthias Runge Date: Thu, 23 Jul 2020 11:07:03 +0200 Subject: [PATCH 1/3] 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| { -%> From 9f098b811d9d1f2d91f83188dd8b24062a65ba98 Mon Sep 17 00:00:00 2001 From: Matthias Runge Date: Thu, 23 Jul 2020 14:09:22 +0200 Subject: [PATCH 2/3] Fix check errors (single newline) --- examples/plugins/ceph.pp | 1 - examples/plugins/filecount.pp | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/examples/plugins/ceph.pp b/examples/plugins/ceph.pp index cc30b53c4..9837b2f40 100644 --- a/examples/plugins/ceph.pp +++ b/examples/plugins/ceph.pp @@ -4,4 +4,3 @@ osds => [ 'osd.0', 'osd.1', 'osd.2'], } - diff --git a/examples/plugins/filecount.pp b/examples/plugins/filecount.pp index 993f426d0..9b75b132b 100644 --- a/examples/plugins/filecount.pp +++ b/examples/plugins/filecount.pp @@ -7,11 +7,11 @@ }, } -collectd::plugin::filecount::directory {'foodir': +collectd::plugin::filecount::directory { 'foodir': path => '/path/to/dir', } -collectd::plugin::filecount::directory {'aborted-uploads': +collectd::plugin::filecount::directory { 'aborted-uploads': path => '/var/spool/foo/upload', pattern => '.part.*', mtime => '5m', From 0b6a991e485b5e350402a5de59f125e770bcde8b Mon Sep 17 00:00:00 2001 From: Matthias Runge Date: Fri, 31 Jul 2020 10:09:35 +0200 Subject: [PATCH 3/3] Revert "Fix check errors (single newline)" This reverts commit 9f098b811d9d1f2d91f83188dd8b24062a65ba98. It is only indirectly connected with the SendQueueLength patch. --- examples/plugins/ceph.pp | 1 + examples/plugins/filecount.pp | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/examples/plugins/ceph.pp b/examples/plugins/ceph.pp index 9837b2f40..cc30b53c4 100644 --- a/examples/plugins/ceph.pp +++ b/examples/plugins/ceph.pp @@ -4,3 +4,4 @@ osds => [ 'osd.0', 'osd.1', 'osd.2'], } + diff --git a/examples/plugins/filecount.pp b/examples/plugins/filecount.pp index 9b75b132b..993f426d0 100644 --- a/examples/plugins/filecount.pp +++ b/examples/plugins/filecount.pp @@ -7,11 +7,11 @@ }, } -collectd::plugin::filecount::directory { 'foodir': +collectd::plugin::filecount::directory {'foodir': path => '/path/to/dir', } -collectd::plugin::filecount::directory { 'aborted-uploads': +collectd::plugin::filecount::directory {'aborted-uploads': path => '/var/spool/foo/upload', pattern => '.part.*', mtime => '5m',