Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Zookeeper plugin #670

Merged
merged 4 commits into from
Oct 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,8 @@ documentation for each plugin for configurable attributes.
* `write_tsdb` (see [collectd::plugin::write_tsdb](#class-collectdpluginwrite_tsdb)
below)
* `zfs_arc` (see [collectd::plugin::zfs_arc](#class-collectdpluginzfs_arc) below)
* `zookeeper` (see
[collectd::plugin::zookeeper](#class-collectdzookeeper) below)

### Class: `collectd::plugin::aggregation`

Expand Down Expand Up @@ -1833,6 +1835,15 @@ class { 'collectd::plugin::zfs_arc':
}
```

#### Class: `collectd::plugin::zookeeper`

```puppet
class { 'collectd::plugin::zookeeper':
zookeeper_host => 'localhost',
zookeeper_port => '2181',
}
```

##### types.db

Collectd needs to know how to handle each collected datapoint.
Expand Down
15 changes: 15 additions & 0 deletions manifests/plugin/zookeeper.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
class collectd::plugin::zookeeper (
Enum['present', 'absent'] $ensure = 'present',
Optional[Integer] $interval = undef,
String $zookeeper_host = 'localhost',
String $zookeeper_port = '2181',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

datatypes \o/

) {

include ::collectd

collectd::plugin { 'zookeeper':
ensure => $ensure,
content => template('collectd/plugin/zookeeper.conf.erb'),
interval => $interval,
}
}
36 changes: 36 additions & 0 deletions spec/classes/collectd_plugin_zookeeper_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
require 'spec_helper'

describe 'collectd::plugin::zookeeper', type: :class do
let :facts do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you use rspec-puppet.-facts here?

{
osfamily: 'RedHat',
collectd_version: '5.5.0',
operatingsystemmajrelease: '7',
python_dir: '/usr/local/lib/python2.7/dist-packages'
}
end

context ':ensure => present and :zookeeper_host => \'myhost\'' do
let :params do
{ zookeeper_host: 'myhost', zookeeper_port: '2181' }
end

it 'Will create /etc/collectd.d/10-zookeeper.conf' do
is_expected.to contain_file('write_riemann.load').with(ensure: 'present')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

write_riemann.load here is also wrong. no idea how this went green on travis

is_expected.to contain_file('write_riemann.load').with(path: '/etc/collectd.d/10-zookeeper.conf')
is_expected.to contain_file('write_riemann.load').with(content: %r{Host "myhost"})
is_expected.to contain_file('write_riemann.load').with(content: %r{Port "2181"})
end
end

context ':ensure => absent' do
let :params do
{ zookeeper_host: ['myhost'], ensure: 'absent' }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How did this pass the tests. This is clearly wrong. Defined datatype is String, but this is a tuple. Strange

end

it 'Will not create ' do
is_expected.to contain_file('zookeeper.load').with(ensure: 'absent',
path: '/etc/collectd.d/10-zookeeper.conf')
end
end
end
4 changes: 4 additions & 0 deletions templates/plugin/zookeeper.conf.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<Plugin "zookeeper">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you migrate this to a epp template?

Host "<%= @zookeeper_host %>"
Port "<%= @zookeeper_port %>"
</Plugin>