From c1720b05a67e758e3412118af335d71b72c91cc3 Mon Sep 17 00:00:00 2001 From: Andrew Ward Date: Fri, 10 Mar 2017 16:30:17 -0800 Subject: [PATCH] Fix writing of postgresql query params and add a test --- README.md | 1 + spec/classes/collectd_plugin_postgresql_spec.rb | 2 ++ templates/plugin/postgresql/query.conf.erb | 4 ++-- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3b42d2a5c..41327eff0 100644 --- a/README.md +++ b/README.md @@ -1242,6 +1242,7 @@ collectd::plugin::postgresql::database{'monitoring_node1': } collectd::plugin::postgresql::query{'log_delay': statement => 'SELECT * FROM log_delay_repli;', + params => ['database'], results => [{ type => 'gauge', instanceprefix => 'log_delay', diff --git a/spec/classes/collectd_plugin_postgresql_spec.rb b/spec/classes/collectd_plugin_postgresql_spec.rb index 93c7d7684..df3edecde 100644 --- a/spec/classes/collectd_plugin_postgresql_spec.rb +++ b/spec/classes/collectd_plugin_postgresql_spec.rb @@ -43,6 +43,7 @@ queries: { 'log_delay' => { 'statement' => 'SELECT * FROM log_delay_repli;', + 'params' => ['database'], 'results' => [{ 'type' => 'gauge', 'instanceprefix' => 'log_delay', @@ -64,6 +65,7 @@ is_expected.to contain_concat__fragment('collectd_plugin_postgresql_conf_db_postgres').with(content: %r{Query \"disk_io\"}) is_expected.to contain_concat__fragment('collectd_plugin_postgresql_conf_query_log_delay').with(content: %r{Statement \"SELECT \* FROM log_delay_repli;\"\n}) is_expected.to contain_concat__fragment('collectd_plugin_postgresql_conf_query_log_delay').with(content: %r{\n}) + is_expected.to contain_concat__fragment('collectd_plugin_postgresql_conf_query_log_delay').with(content: %r{Param \"database\"}) is_expected.to contain_concat__fragment('collectd_plugin_postgresql_conf_writer_sqlstore').with(content: %r{\n}) end end diff --git a/templates/plugin/postgresql/query.conf.erb b/templates/plugin/postgresql/query.conf.erb index 145cdb4a9..8caa64bec 100644 --- a/templates/plugin/postgresql/query.conf.erb +++ b/templates/plugin/postgresql/query.conf.erb @@ -1,7 +1,7 @@ > Statement "<%= @statement %>" <% @params.each do |param| -%> - Param "<%= @param %>" + Param "<%= param %>" <% end -%> <% if @minversion -%> MinVersion <%= @minversion %> @@ -21,4 +21,4 @@ ValuesFrom "<%= result['valuesfrom'] %>" <% end -%> - \ No newline at end of file +