Skip to content

Commit

Permalink
Merge pull request #584 from crimpy88/multiple_mbean_attribute_support
Browse files Browse the repository at this point in the history
Allow multiple genericjmx mbean attribute entries
  • Loading branch information
bastelfreak authored Dec 1, 2016
2 parents 975daf3 + e1a1f0a commit c3bd7bb
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
19 changes: 19 additions & 0 deletions spec/defines/collectd_plugin_genericjmx_mbean_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,25 @@
it { is_expected.to contain_concat__fragment(concat_fragment_name).without_content(%r{InstancePrefix}) }
end

context 'value section attribute array' do
let(:params) do
default_params.merge(values: [default_values_args.merge('attribute' => %w(alice bob carol))])
end

it { is_expected.to contain_concat__fragment(concat_fragment_name).with_content(%r{Attribute "alice"}) }
it { is_expected.to contain_concat__fragment(concat_fragment_name).with_content(%r{Attribute "bob"}) }
it { is_expected.to contain_concat__fragment(concat_fragment_name).with_content(%r{Attribute "carol"}) }
end

context 'value section attribute string' do
let(:params) do
default_params.merge(values: [default_values_args.merge('attribute' => 'dave')])
end

it { is_expected.to contain_concat__fragment(concat_fragment_name).with_content(%r{Attribute "dave"}) }
it { is_expected.to contain_concat__fragment(concat_fragment_name).without_content(%r{(.*Attribute.*){2,}}) }
end

context 'value section table true-like' do
['true', true].each do |truthy|
let(:params) do
Expand Down
4 changes: 3 additions & 1 deletion templates/plugin/genericjmx/mbean.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
<% end -%>
<% end -%>
Table <%= scope.function_str2bool([value['table'] || false ]) ? 'true' : 'false' %>
Attribute "<%= value['attribute'] %>"
<% Array(value['attribute']).each do |attribute_item| -%>
Attribute "<%= attribute_item %>"
<% end -%>
</Value>
<% end -%>
</MBean>

0 comments on commit c3bd7bb

Please sign in to comment.