From e7850503f20ceaeeb35ffe79ded47523c0aefaf3 Mon Sep 17 00:00:00 2001 From: Jeremy Kitchen Date: Tue, 20 Jan 2015 01:20:46 +0000 Subject: [PATCH] collectd doesn't auto-include its java dir in class path :( --- manifests/params.pp | 7 +++++++ manifests/plugin/genericjmx.pp | 2 +- spec/classes/collectd_plugin_genericjmx_spec.rb | 12 ++++++------ templates/plugin/genericjmx.conf.header.erb | 1 + 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/manifests/params.pp b/manifests/params.pp index f2ce6c92b..b7070ea14 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -10,6 +10,7 @@ $service_name = 'collectd' $config_file = "${collectd_dir}/collectd.conf" $root_group = 'root' + $java_dir = '/usr/share/collectd/java' } 'Solaris': { $package = 'CSWcollectd' @@ -19,6 +20,7 @@ $service_name = 'collectd' $config_file = "${collectd_dir}/collectd.conf" $root_group = 'root' + # FIXME: $java_dir } 'Redhat': { $package = 'collectd' @@ -28,6 +30,7 @@ $service_name = 'collectd' $config_file = '/etc/collectd.conf' $root_group = 'root' + $java_dir = '/usr/share/collectd/java' } 'Suse': { $package = 'collectd' @@ -37,6 +40,7 @@ $service_name = 'collectd' $config_file = '/etc/collectd.conf' $root_group = 'root' + # FIXME: $java_dir } 'FreeBSD': { $package = 'collectd5' @@ -46,6 +50,7 @@ $service_name = 'collectd' $config_file = '/usr/local/etc/collectd.conf' $root_group = 'wheel' + # FIXME: $java_dir } 'Archlinux': { $package = 'collectd' @@ -55,6 +60,7 @@ $service_name = 'collectd' $config_file = '/etc/collectd.conf' $root_group = 'wheel' + # FIXME: $java_dir } 'Gentoo': { $package = 'app-admin/collectd' @@ -64,6 +70,7 @@ $service_name = 'collectd' $config_file = '/etc/collectd.conf' $root_group = 'collectd' + # FIXME: $java_dir } default: { diff --git a/manifests/plugin/genericjmx.pp b/manifests/plugin/genericjmx.pp index 1cc2081d8..eb5df8c33 100644 --- a/manifests/plugin/genericjmx.pp +++ b/manifests/plugin/genericjmx.pp @@ -6,7 +6,7 @@ include collectd include collectd::params include collectd::plugin::java - + $class_path = "${collectd::params::java_dir}/collectd-api.jar:${collectd::params::java_dir}/generic-jmx.jar" $config_file = "${collectd::params::plugin_conf_dir}/15-genericjmx.conf" concat { $config_file: diff --git a/spec/classes/collectd_plugin_genericjmx_spec.rb b/spec/classes/collectd_plugin_genericjmx_spec.rb index adc8cee2a..5dc0a84e9 100644 --- a/spec/classes/collectd_plugin_genericjmx_spec.rb +++ b/spec/classes/collectd_plugin_genericjmx_spec.rb @@ -2,11 +2,11 @@ describe 'collectd::plugin::genericjmx', :type => :class do let (:facts) {{ - :osfamily => 'RedHat', + :osfamily => 'Debian', :concat_basedir => tmpfilename('collectd-genericjmx'), }} - let (:config_filename) { '/etc/collectd.d/15-genericjmx.conf' } + let (:config_filename) { '/etc/collectd/conf.d/15-genericjmx.conf' } context ':ensure => present, defaults' do it 'will include the java plugin' do @@ -64,15 +64,15 @@ it 'should have one jvmarg parameter' do should contain_concat__fragment('collectd_plugin_genericjmx_conf_header').with_content(/JVMArg "bat"/) end - it 'should have ONLY one jvmarg parameter' do - should contain_concat__fragment('collectd_plugin_genericjmx_conf_header').without_content(/(.*JVMArg.*){2,}/m) + it 'should have ONLY one jvmarg parameter other than classpath' do + should contain_concat__fragment('collectd_plugin_genericjmx_conf_header').without_content(/(.*JVMArg.*){3,}/m) end end context 'jvmarg parameter empty' do let (:params) {{ :jvmarg => [] }} - it 'should not have any jvmarg parameters' do - should contain_concat__fragment('collectd_plugin_genericjmx_conf_header').without_content(/JVMArg/) + it 'should wnot have any jvmarg parameters other than classpath' do + should contain_concat__fragment('collectd_plugin_genericjmx_conf_header').without_content(/(.*JVMArg.*){2,}/m) end end end diff --git a/templates/plugin/genericjmx.conf.header.erb b/templates/plugin/genericjmx.conf.header.erb index 26e52d30e..1a8ec7fc9 100644 --- a/templates/plugin/genericjmx.conf.header.erb +++ b/templates/plugin/genericjmx.conf.header.erb @@ -1,4 +1,5 @@ + JVMArg "-Djava.class.path=<%= @class_path %>" <% Array(@jvmarg).each do |jvmarg| -%> JVMArg "<%= jvmarg %>" <% end -%>