diff --git a/.travis.yml b/.travis.yml
index 86222c281..bd66c7d1c 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,6 +1,6 @@
---
language: ruby
-bundler_args: --without development
+bundler_args: --without system_tests
script: "bundle exec rake validate && bundle exec rake lint && bundle exec rake spec SPEC_OPTS='--format documentation'"
matrix:
fast_finish: true
diff --git a/Gemfile b/Gemfile
index e960f7c4b..abcb4b54e 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,15 +1,18 @@
source ENV['GEM_SOURCE'] || "https://rubygems.org"
-group :development, :test do
- gem 'rake', :require => false
- gem 'rspec-puppet', :require => false
- gem 'puppetlabs_spec_helper', :require => false
- gem 'serverspec', :require => false
- gem 'puppet-lint', :require => false
- gem 'beaker', :require => false
- gem 'beaker-rspec', :require => false
- gem 'pry', :require => false
- gem 'simplecov', :require => false
+group :development, :unit_tests do
+ gem 'rake', :require => false
+ gem 'rspec-puppet', :require => false
+ gem 'puppetlabs_spec_helper', :require => false
+ gem 'puppet-lint', :require => false
+ gem 'simplecov', :require => false
+ gem 'puppet_facts', :require => false
+ gem 'json', :require => false
+end
+
+group :system_tests do
+ gem 'beaker-rspec', :require => false
+ gem 'serverspec', :require => false
end
if facterversion = ENV['FACTER_GEM_VERSION']
diff --git a/README.md b/README.md
index bc08e6c81..ee6f084b7 100644
--- a/README.md
+++ b/README.md
@@ -59,6 +59,7 @@ documentation for each plugin for configurable attributes.
* `apache` (see [collectd::plugin::apache](#class-collectdpluginapache) below)
* `bind` (see [collectd::plugin::bind](#class-collectdpluginbind) below)
* `cpu` (see [collectd::plugin::cpu](#class-collectdplugincpu) below)
+* `cpufreq` (see [collectd::plugin::cpufreq](#class-collectdplugincpufreq) below)
* `csv` (see [collectd::plugin::csv](#class-collectdplugincsv) below)
* `curl` (see [collectd::plugin::curl](#class-collectdplugincurl) below)
* `curl_json` (see [collectd::plugin::curl_json](#class-collectdplugincurl_json) below)
@@ -146,6 +147,14 @@ class { 'collectd::plugin::bind':
```puppet
class { 'collectd::plugin::cpu':
}
+
+
+```
+####Class: `collectd::plugin::cpufreq`
+
+```puppet
+class { 'collectd::plugin::cpufreq':
+}
```
####Class: `collectd::plugin::csv`
diff --git a/manifests/plugin.pp b/manifests/plugin.pp
index 53fc66cd6..76d411235 100644
--- a/manifests/plugin.pp
+++ b/manifests/plugin.pp
@@ -1,9 +1,11 @@
#
define collectd::plugin (
- $ensure = 'present',
- $content = undef,
- $order = '10',
- $plugin = $name
+ $ensure = 'present',
+ $content = undef,
+ $order = '10',
+ $globals = false,
+ $interval = undef,
+ $plugin = $name
) {
include collectd::params
@@ -16,7 +18,7 @@
owner => root,
group => $root_group,
mode => '0640',
- content => "# Generated by Puppet\nLoadPlugin ${plugin}\n\n${content}",
+ content => template('collectd/loadplugin.conf.erb'),
notify => Service['collectd'],
}
diff --git a/manifests/plugin/conntrack.pp b/manifests/plugin/conntrack.pp
new file mode 100644
index 000000000..76030434d
--- /dev/null
+++ b/manifests/plugin/conntrack.pp
@@ -0,0 +1,8 @@
+# https://collectd.org/wiki/index.php/Plugin:ConnTrack
+class collectd::plugin::conntrack (
+ $ensure = present,
+) {
+ collectd::plugin {'conntrack':
+ ensure => $ensure
+ }
+}
diff --git a/manifests/plugin/cpufreq.pp b/manifests/plugin/cpufreq.pp
new file mode 100644
index 000000000..ff90048a5
--- /dev/null
+++ b/manifests/plugin/cpufreq.pp
@@ -0,0 +1,8 @@
+# https://collectd.org/wiki/index.php/Plugin:CPUFreq
+class collectd::plugin::cpufreq (
+ $ensure = present,
+) {
+ collectd::plugin {'cpufreq':
+ ensure => $ensure
+ }
+}
diff --git a/manifests/plugin/curl/page.pp b/manifests/plugin/curl/page.pp
index 64c5bb90e..d91c06d73 100644
--- a/manifests/plugin/curl/page.pp
+++ b/manifests/plugin/curl/page.pp
@@ -10,7 +10,7 @@
$header = undef,
$post = undef,
$measureresponsetime = undef,
- $matches = [{ }],
+ $matches = undef,
$plugininstance = $name, # You can have multiple with the same name.
) {
include collectd::params
@@ -20,6 +20,10 @@
validate_string($url)
+ if $matches != undef {
+ validate_array($matches)
+ }
+
file { "${conf_dir}/curl-${name}.conf":
ensure => $ensure,
mode => '0640',
diff --git a/manifests/plugin/perl.pp b/manifests/plugin/perl.pp
index f49d51c91..2eb2faaeb 100644
--- a/manifests/plugin/perl.pp
+++ b/manifests/plugin/perl.pp
@@ -9,6 +9,7 @@
collectd::plugin { 'perl':
ensure => $ensure,
+ globals => true,
order => $order,
content => template('collectd/plugin/perl.conf.erb')
}
diff --git a/spec/classes/collectd_plugin_curl_spec.rb b/spec/classes/collectd_plugin_curl_spec.rb
index 7b76eabc6..964452aae 100644
--- a/spec/classes/collectd_plugin_curl_spec.rb
+++ b/spec/classes/collectd_plugin_curl_spec.rb
@@ -49,6 +49,33 @@
end
end
+ context ':ensure => present, verifypeer => false, verifyhost => \'false\', measureresponsetime => true, matches empty' do
+ let :facts do
+ {:osfamily => 'Debian'}
+ end
+ let :params do
+ {
+ :ensure => 'present',
+ :pages => {
+ 'selfsigned_ssl' => {
+ 'url' => 'https://some.selfsigned.ssl.site/',
+ 'verifypeer' => false,
+ 'verifyhost' => 'false',
+ 'measureresponsetime' => true,
+ },
+ }
+ }
+ end
+
+ it 'Will create /etc/collectd.d/conf.d/curl-selfsigned_ssl.conf' do
+ should contain_file('/etc/collectd/conf.d/curl-selfsigned_ssl.conf').with({
+ :ensure => 'present',
+ :path => '/etc/collectd/conf.d/curl-selfsigned_ssl.conf',
+ :content => "\n \n URL \"https://some.selfsigned.ssl.site/\"\n VerifyPeer false\n VerifyHost false\n MeasureResponseTime true\n \n\n",
+ })
+ end
+ end
+
context ':ensure => absent' do
let :facts do
{:osfamily => 'RedHat'}
diff --git a/spec/classes/collectd_plugin_swap_spec.rb b/spec/classes/collectd_plugin_swap_spec.rb
index ea9274d0e..3bb6f17e0 100644
--- a/spec/classes/collectd_plugin_swap_spec.rb
+++ b/spec/classes/collectd_plugin_swap_spec.rb
@@ -26,7 +26,7 @@
should contain_file('swap.load').with({
:ensure => 'present',
:path => '/etc/collectd.d/10-swap.conf',
- :content => "# Generated by Puppet\nLoadPlugin swap\n\n\n ReportByDevice false\n\n",
+ :content => "# Generated by Puppet\n\n Globals false\n\n\n\n ReportByDevice false\n\n\n",
})
end
end
@@ -42,7 +42,7 @@
should contain_file('swap.load').with({
:ensure => 'present',
:path => '/etc/collectd.d/10-swap.conf',
- :content => "# Generated by Puppet\nLoadPlugin swap\n\n\n ReportByDevice false\n ReportBytes true\n\n",
+ :content => "# Generated by Puppet\n\n Globals false\n\n\n\n ReportByDevice false\n ReportBytes true\n\n\n",
})
end
end
diff --git a/spec/defines/collectd_plugin_spec.rb b/spec/defines/collectd_plugin_spec.rb
new file mode 100644
index 000000000..b2e59c0a5
--- /dev/null
+++ b/spec/defines/collectd_plugin_spec.rb
@@ -0,0 +1,34 @@
+require 'spec_helper'
+
+describe 'collectd::plugin', :type => :define do
+
+ context 'loading a plugin on collectd <= 4.9.4' do
+ let(:title) { 'test' }
+ let :facts do
+ {
+ :collectd_version => '5.3',
+ :osfamily => 'Debian',
+ }
+ end
+
+ it 'Will create /etc/collectd/conf.d/10-test.conf with the LoadPlugin syntax with brackets' do
+ should contain_file('test.load').with_content(/ 4.9.3' do
+ let(:title) { 'test' }
+ let :facts do
+ {
+ :collectd_version => '4.9.3',
+ :osfamily => 'Debian',
+ }
+ end
+
+ it 'Will create /etc/collectd/conf.d/10-test.conf with the LoadPlugin syntax without brackets' do
+ should contain_file('test.load').without_content(/= 0) -%>
+>
+ Globals <%= @globals %>
+<% if @interval and @collectd_version and (scope.function_versioncmp([@collectd_version, '5.2']) >= 0) -%>
+ Interval <%= @interval %>
+<% end -%>
+
+<% else -%>
+LoadPlugin <%= @plugin %>
+<% end -%>
+
+<%= @content %>
diff --git a/templates/plugin/curl-page.conf.erb b/templates/plugin/curl-page.conf.erb
index 8ecccef34..3caf4b011 100644
--- a/templates/plugin/curl-page.conf.erb
+++ b/templates/plugin/curl-page.conf.erb
@@ -7,11 +7,11 @@
<% if @password -%>
Password "<%= @password %>"
<% end -%>
-<% if @verifypeer -%>
- VerifyPeer "<%= @verifypeer %>"
+<% unless @verifypeer.nil? -%>
+ VerifyPeer <%= @verifypeer %>
<% end -%>
-<% if @verifyhost %>
- VerifyHost "<%= @verifyhost %>"
+<% unless @verifyhost.nil? -%>
+ VerifyHost <%= @verifyhost %>
<% end -%>
<% if @cacert -%>
CACert "<%= @cacert %>"
@@ -22,9 +22,11 @@
<% if @post and @collectd_version and (scope.function_versioncmp([@collectd_version, '5.3']) >= 0) -%>
Post "<%= @post %>"
<% end -%>
-<% if @measureresponsetime -%>
+<% unless @measureresponsetime.nil? -%>
MeasureResponseTime <%= @measureresponsetime %>
<% end -%>
+<% if @matches -%>
<%= scope.function_template(["collectd/plugin/match.tpl.erb"]) %>
+<% end -%>
diff --git a/templates/plugin/perl.conf.erb b/templates/plugin/perl.conf.erb
index 0f27ee7f5..ac33d21e6 100644
--- a/templates/plugin/perl.conf.erb
+++ b/templates/plugin/perl.conf.erb
@@ -1,7 +1,2 @@
-#
-
- Globals true
-
-
Include "<%= @conf_dir %>/perl/*.conf"
diff --git a/templates/plugin/statsd.conf.erb b/templates/plugin/statsd.conf.erb
index a3b13e5c8..acd5cd82a 100644
--- a/templates/plugin/statsd.conf.erb
+++ b/templates/plugin/statsd.conf.erb
@@ -3,21 +3,21 @@
Host "<%= @host %>"
<% end -%>
<% if @port -%>
- Port <%= port %>
+ Port <%= @port %>
<% end -%>
<% if @deletecounters -%>
- DeleteCounters <%= deletecounters %>
+ DeleteCounters <%= @deletecounters %>
<% end -%>
<% if @deletetimers -%>
- DeleteTimers <%= deletetimers %>
+ DeleteTimers <%= @deletetimers %>
<% end -%>
<% if @deletegauges -%>
- DeleteGauges <%= deletegauges %>
+ DeleteGauges <%= @deletegauges %>
<% end -%>
<% if @deletesets -%>
- Deletesets <%= deletesets %>
+ Deletesets <%= @deletesets %>
<% end -%>
<% if @timerpercentile -%>
- TimerPercentile <%= timerpercentile %>
+ TimerPercentile <%= @timerpercentile %>
<% end -%>
diff --git a/tests/plugin.pp b/tests/plugin.pp
index 6237009a3..d3ebf8491 100644
--- a/tests/plugin.pp
+++ b/tests/plugin.pp
@@ -16,4 +16,4 @@
collectd::plugin { 'processes': }
collectd::plugin { 'swap': }
collectd::plugin { 'users': }
-
+collects::plugin { 'cpufreq': }