forked from redhat-openstack/openstack-puppet-modules
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request redhat-openstack#226 from 3dna/jmx-plugin
java and genericjmx plugins
- Loading branch information
Showing
14 changed files
with
600 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# https://collectd.org/wiki/index.php/Plugin:GenericJMX | ||
class collectd::plugin::genericjmx ( | ||
$jvmarg = [], | ||
) { | ||
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: | ||
mode => '0640', | ||
owner => 'root', | ||
group => $collectd::params::root_group, | ||
notify => Service['collectd'], | ||
ensure_newline => true, | ||
} | ||
concat::fragment { | ||
'collectd_plugin_genericjmx_conf_header': | ||
order => '00', | ||
content => template('collectd/plugin/genericjmx.conf.header.erb'), | ||
target => $config_file; | ||
'collectd_plugin_genericjmx_conf_footer': | ||
order => '99', | ||
content => " </Plugin>\n</Plugin>\n", | ||
target => $config_file; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# https://collectd.org/wiki/index.php/Plugin:GenericJMX | ||
define collectd::plugin::genericjmx::connection ( | ||
$host = $name, | ||
$service_url, | ||
$user = undef, | ||
$password = undef, | ||
$instance_prefix = undef, | ||
$collect, | ||
) { | ||
include collectd::plugin::genericjmx | ||
concat::fragment { "collectd_plugin_genericjmx_conf_${name}": | ||
order => 20, | ||
content => template('collectd/plugin/genericjmx/connection.conf.erb'), | ||
target => $collectd::plugin::genericjmx::config_file; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# https://collectd.org/wiki/index.php/Plugin:GenericJMX | ||
define collectd::plugin::genericjmx::mbean ( | ||
$object_name, | ||
$instance_prefix = undef, | ||
$instance_from = undef, | ||
$values, | ||
) { | ||
include collectd::plugin::genericjmx | ||
validate_array($values) | ||
|
||
concat::fragment { | ||
"collectd_plugin_genericjmx_conf_${name}": | ||
order => '10', | ||
content => template('collectd/plugin/genericjmx/mbean.conf.erb'), | ||
target => $collectd::plugin::genericjmx::config_file; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# https://collectd.org/wiki/index.php/Plugin:Java | ||
class collectd::plugin::java ( | ||
$ensure = present, | ||
$jvmarg = [], | ||
$interval = undef, | ||
) { | ||
collectd::plugin { 'java': | ||
ensure => $ensure, | ||
content => template('collectd/plugin/java.conf.erb'), | ||
interval => $interval, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
require 'spec_helper' | ||
|
||
describe 'collectd::plugin::genericjmx', :type => :class do | ||
let (:facts) {{ | ||
:osfamily => 'Debian', | ||
:id => 'root', | ||
:concat_basedir => tmpfilename('collectd-genericjmx'), | ||
:path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', | ||
}} | ||
|
||
let (:config_filename) { '/etc/collectd/conf.d/15-genericjmx.conf' } | ||
|
||
context 'defaults' do | ||
it 'will include the java plugin' do | ||
should contain_class('collectd::plugin::java') | ||
end | ||
|
||
it 'will load the genericjmx plugin' do | ||
should contain_concat(config_filename).with({ | ||
:ensure => 'present', | ||
:mode => '0640', | ||
:owner => 'root', | ||
:group => 'root', | ||
:ensure_newline => true | ||
}) | ||
end | ||
|
||
it { should contain_concat(config_filename).that_notifies('Service[collectd]') } | ||
|
||
it do | ||
should contain_concat__fragment('collectd_plugin_genericjmx_conf_header').with({ | ||
:order => '00', | ||
:target => config_filename, | ||
:content => /<Plugin "java">.+LoadPlugin "org\.collectd\.java\.GenericJMX".+<Plugin "GenericJMX">/m | ||
}) | ||
end | ||
|
||
it do | ||
should contain_concat__fragment('collectd_plugin_genericjmx_conf_footer').with({ | ||
:order => '99', | ||
:target => config_filename, | ||
:content => %r{</Plugin>.+</Plugin>}m, | ||
}) | ||
end | ||
|
||
end | ||
|
||
context 'jvmarg parameter array' do | ||
let (:params) {{ :jvmarg => %w{ foo bar baz } }} | ||
it 'should have multiple jvmarg parameters' do | ||
should contain_concat__fragment('collectd_plugin_genericjmx_conf_header').with_content(/JVMArg "foo".*JVMArg "bar".*JVMArg "baz"/m) | ||
end | ||
end | ||
|
||
context 'jvmarg parameter string' do | ||
let (:params) {{ :jvmarg => "bat" }} | ||
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 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 other than classpath' do | ||
should contain_concat__fragment('collectd_plugin_genericjmx_conf_header').without_content(/(.*JVMArg.*){2,}/m) | ||
end | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
require 'spec_helper' | ||
|
||
describe 'collectd::plugin::java', :type => :class do | ||
let :facts do | ||
{:osfamily => 'RedHat'} | ||
end | ||
|
||
context ':ensure => present, defaults' do | ||
it 'Will load the plugin' do | ||
should contain_collectd__plugin('java').with({ | ||
:ensure => 'present', | ||
}) | ||
end | ||
end | ||
|
||
context ':ensure => absent' do | ||
let (:params) {{ | ||
:ensure => 'absent', | ||
}} | ||
|
||
it 'will not load the plugin' do | ||
should contain_collectd__plugin('java').with({ | ||
:ensure => 'absent' | ||
}) | ||
end | ||
end | ||
|
||
context 'jvmarg parameter array' do | ||
let (:params) {{ | ||
:jvmarg => %w{ foo bar baz } | ||
}} | ||
|
||
it 'will have multiple jvmarg parameters' do | ||
should contain_collectd__plugin('java').with_content(/JVMArg "foo".+JVMArg "bar".+JVMArg "baz"/m) | ||
end | ||
end | ||
|
||
context 'jvmarg parameter string' do | ||
let (:params) {{ | ||
:jvmarg => 'bat' | ||
}} | ||
|
||
it 'will have a JVMArg parameter' do | ||
should contain_collectd__plugin('java').with_content(/JVMArg "bat"/) | ||
end | ||
|
||
it 'will only have one JVMArg parameter' do | ||
should contain_collectd__plugin('java').without_content(/(.*JVMArg.*){2,}/m) | ||
end | ||
end | ||
|
||
context 'jvmarg parameter empty' do | ||
let (:params) {{ | ||
:jvmarg => [], | ||
}} | ||
|
||
it 'will not have a <Plugin java> stanza' do | ||
should contain_collectd__plugin('java').without_content(/<Plugin java>/) | ||
end | ||
it 'will not have any jvmarg parameters' do | ||
should contain_collectd__plugin('java').without_content(/JVMArg/) | ||
end | ||
end | ||
end |
Oops, something went wrong.