From 1fdf8afb7f4efb3cc57d20a0186d8eebb1f828fe Mon Sep 17 00:00:00 2001 From: Lukas Bezdicka Date: Fri, 19 Jun 2015 11:00:50 +0200 Subject: [PATCH] Update module-collectd to a6c102b528946a22449ffdfb615db92eab3b3f96 a6c102b528946a22449ffdfb615db92eab3b3f96 Merge pull request #252 from simonpasquier/issue-251 07326b3ab2f806e76c5274d2f9b8ba6e65d25078 Drop support for Ubuntu 10.04 83095e1c0e30623eede8c3fd4cdc9dc8f91ca9da Bump version in metadata.json to 3.4.0 76d4ebebd45e056e6f80cc7806c662e0f951850e Merge pull request #277 from pdxcat/release_340 3f06a17e60cc24998616e77cc64b2d7b181c0f04 Release 3.4.0 a622ba8aa04c4d8f78cc5f48e5914135e0d2b60c Merge pull request #276 from pdxcat/ruby220 e4f3a17d7a0a20404be6064766bd27e181a8c562 Add ruby 2.2.0 4b569da7d00c1daaef90263c36796cb9506128b7 Merge pull request #275 from pdxcat/test_puppet4 ea331d656b430be6cbcd4cd5099b990cec582499 Drop tests for puppet 3.0 b7abefba07cc30be8e9cc52aeecd03efb3fcecfe Update all the gems 63bf721c499ee27b219659218c110b3f0049bbc1 Add puppet4 to .travis and update ruby to 2.1.6 b9b1cc1567a55a179d015b1626e36d0bdc85218e Merge pull request #270 from piotr1212/cpu_options df5d2bbe9135efc62fc493858c1a97ac84975fcd Merge pull request #272 from piotr1212/rake_validate_type 016458c14bb2ea028d66bc2b3604d29940c6cad1 Merge pull request #273 from piotr1212/validate_re_on_int 7acc2bda3fbacfda3f75295f636ffacb0c546bf5 Merge branch 'issue-251' of github.com:simonpasquier/puppet-module-collectd into issue-251 cff8b951a3d17682fba6e62dce803e70c19984ae Fix collectd::plugin::write_http for RedHat a442bac78e1e4d01a349cd15d1134896b96efcb3 plugin_cpu: add version info to readme ade651efc0bdb8202b1b4a89c21c7ff67071d158 add tests for cpu plugin f00ef922cc84a05bc82336b75a0e4bb49a2c97ef snpm/host.pp validate_re validate on string 192eab7ee709792186ba516b7d8cc3c6542c5bf0 quote reserved word type in tail.pp so rake validate succeeds 2c5e0301d299ab4c7f99205c81d99d91baac7d92 add new cpu plugin options introduced in collectd 5.5 ce656cebe5e16e1b32430f3cac4d53fd33f8a77d Fix collectd::plugin::write_http for RedHat Change-Id: I3574692a6e64c9f8a0c57c2936aee5c0ae589116 --- Puppetfile | 2 +- module-collectd/.travis.yml | 24 ++-- module-collectd/CHANGELOG.md | 22 ++++ module-collectd/Gemfile.lock | 105 ++++++++++-------- module-collectd/README.md | 11 +- module-collectd/manifests/plugin/cpu.pp | 15 ++- module-collectd/manifests/plugin/snmp/host.pp | 2 +- .../manifests/plugin/write_http.pp | 6 - module-collectd/metadata.json | 3 +- .../spec/classes/collectd_plugin_cpu_spec.rb | 86 ++++++++++++++ module-collectd/templates/plugin/cpu.conf.erb | 7 ++ module-collectd/tests/plugins/tail.pp | 24 ++-- 12 files changed, 222 insertions(+), 85 deletions(-) create mode 100644 module-collectd/spec/classes/collectd_plugin_cpu_spec.rb create mode 100644 module-collectd/templates/plugin/cpu.conf.erb diff --git a/Puppetfile b/Puppetfile index 74aade367..48eb127cd 100644 --- a/Puppetfile +++ b/Puppetfile @@ -95,7 +95,7 @@ mod 'memcached', :git => 'https://github.com/saz/puppet-memcached.git' mod 'module-collectd', - :commit => '27c81f69d00722ce7a6ac1e9c13b8e76fc7a5204', + :commit => 'a6c102b528946a22449ffdfb615db92eab3b3f96', :git => 'https://github.com/pdxcat/puppet-module-collectd.git' mod 'module-data', diff --git a/module-collectd/.travis.yml b/module-collectd/.travis.yml index 1d6ecb14d..e904792d0 100644 --- a/module-collectd/.travis.yml +++ b/module-collectd/.travis.yml @@ -2,21 +2,21 @@ sudo: false language: ruby bundler_args: --without system_tests -script: "bundle exec rake validate && bundle exec rake lint && bundle exec rake spec SPEC_OPTS='--format documentation'" +script: + - 'puppet --version' + - 'bundle exec rake validate' + - 'bundle exec rake lint' + - "bundle exec rake spec SPEC_OPTS='--format documentation'" matrix: fast_finish: true include: - rvm: 1.9.3 - env: PUPPET_GEM_VERSION="~> 3.0" - - rvm: 2.0.0 - env: PUPPET_GEM_VERSION="~> 3.0" - - rvm: 1.9.3 - env: PUPPET_GEM_VERSION="~> 3.5.0" STRICT_VARIABLES="yes" - - rvm: 2.0.0 - env: PUPPET_GEM_VERSION="~> 3.5.0" STRICT_VARIABLES="yes" - - rvm: 1.9.3 - env: PUPPET_GEM_VERSION="~> 3.7.5" STRICT_VARIABLES="yes" - - rvm: 2.0.0 - env: PUPPET_GEM_VERSION="~> 3.7.5" STRICT_VARIABLES="yes" + env: PUPPET_GEM_VERSION="~> 3.0" STRICT_VARIABLES="yes" + - rvm: 2.1.6 + env: PUPPET_GEM_VERSION="~> 3.0" STRICT_VARIABLES="yes" + - rvm: 2.1.6 + env: PUPPET_GEM_VERSION="~> 4.0" STRICT_VARIABLES="yes" + - rvm: 2.2.0 + env: PUPPET_GEM_VERSION="~> 4.0" STRICT_VARIABLES="yes" notifications: email: false diff --git a/module-collectd/CHANGELOG.md b/module-collectd/CHANGELOG.md index f2414f1bf..3ccf0acde 100644 --- a/module-collectd/CHANGELOG.md +++ b/module-collectd/CHANGELOG.md @@ -1,3 +1,25 @@ +## 2015-06-16 Release 3.4.0 + +### Backwards-incompatible changes: + +* Implement support for mupltiple Python modules + +### Bug fixes + +* snmp/host.pp validate_re validate on string +* quote reserved word type in tail.pp + +### New features + +* add new cpu plugin options introduced in collectd 5.5 +* Added absent timers for statsd module. + +### Testing enhancements + +* Add ruby 2.2.0 to TravisCI +* Add puppet4 to .travis and update ruby to 2.1.6 +* Add metadata-json-lint gem + ## 2015-04-22 Release 3.3.0 ### Backwards-incompatible changes: diff --git a/module-collectd/Gemfile.lock b/module-collectd/Gemfile.lock index 1a5005f05..f06159581 100644 --- a/module-collectd/Gemfile.lock +++ b/module-collectd/Gemfile.lock @@ -1,8 +1,8 @@ GEM remote: https://rubygems.org/ specs: - CFPropertyList (2.3.1) - activesupport (4.2.1) + CFPropertyList (2.2.8) + activesupport (4.2.2) i18n (~> 0.7) json (~> 1.7, >= 1.7.7) minitest (~> 5.1) @@ -18,13 +18,13 @@ GEM aws-sdk-v1 (1.64.0) json (~> 1.4) nokogiri (>= 1.4.4) - beaker (2.10.0) + beaker (2.14.1) aws-sdk (~> 1.57) docker-api fission (~> 0.4) fog (~> 1.25) google-api-client (~> 0.8) - hocon (~> 0.0.4) + hocon (~> 0.1) inifile (~> 2.0) json (~> 1.8) minitest (~> 5.4) @@ -33,7 +33,7 @@ GEM rbvmomi (~> 1.8) rsync (~> 1.0.9) unf (~> 0.1) - beaker-rspec (5.0.2) + beaker-rspec (5.1.0) beaker (~> 2.0) rspec serverspec (~> 2) @@ -41,22 +41,24 @@ GEM builder (3.2.2) diff-lcs (1.2.5) docile (1.1.5) - docker-api (1.21.1) + docker-api (1.21.4) excon (>= 0.38.0) json excon (0.45.3) extlib (0.9.16) - facter (1.7.6) + facter (2.4.4) + CFPropertyList (~> 2.2.6) faraday (0.9.1) multipart-post (>= 1.2, < 3) fission (0.5.0) CFPropertyList (~> 2.2) - fog (1.29.0) + fog (1.31.0) fog-atmos fog-aws (~> 0.0) fog-brightbox (~> 0.4) - fog-core (~> 1.27, >= 1.27.4) + fog-core (~> 1.30) fog-ecloud + fog-google (>= 0.0.2) fog-json fog-local fog-powerdns (>= 0.1.1) @@ -76,7 +78,7 @@ GEM fog-atmos (0.1.0) fog-core fog-xml - fog-aws (0.1.2) + fog-aws (0.4.1) fog-core (~> 1.27) fog-json (~> 1.0) fog-xml (~> 0.1) @@ -92,19 +94,23 @@ GEM mime-types net-scp (~> 1.1) net-ssh (>= 2.1.3) - fog-ecloud (0.1.1) + fog-ecloud (0.1.3) fog-core fog-xml - fog-json (1.0.1) + fog-google (0.0.5) + fog-core + fog-json + fog-xml + fog-json (1.0.2) fog-core (~> 1.0) - multi_json (~> 1.0) + multi_json (~> 1.10) fog-local (0.2.1) fog-core (~> 1.27) fog-powerdns (0.1.1) fog-core (~> 1.27) fog-json (~> 1.0) fog-xml (~> 0.1) - fog-profitbricks (0.0.2) + fog-profitbricks (0.0.3) fog-core fog-xml nokogiri @@ -122,7 +128,7 @@ GEM fog-serverlove (0.1.2) fog-core fog-json - fog-softlayer (0.4.5) + fog-softlayer (0.4.6) fog-core fog-json fog-storm_on_demand (0.1.1) @@ -152,37 +158,37 @@ GEM multi_json (~> 1.10) retriable (~> 1.4) signet (~> 0.6) - googleauth (0.4.0) + googleauth (0.4.1) faraday (~> 0.9) jwt (~> 1.4) - logging (~> 1.8) - memoist (~> 0.11) + logging (~> 2.0) + memoist (~> 0.12) multi_json (= 1.11) signet (~> 0.6) - hiera (1.3.4) + hiera (2.0.0) json_pure - hocon (0.0.7) + hocon (0.9.0) i18n (0.7.0) inflecto (0.0.2) inifile (2.0.2) ipaddress (0.8.0) - json (1.8.2) + json (1.8.3) json_pure (1.8.2) - jwt (1.4.1) + jwt (1.5.0) launchy (2.4.3) addressable (~> 2.3) little-plugger (1.1.3) - logging (1.8.2) - little-plugger (>= 1.1.3) - multi_json (>= 1.8.4) + logging (2.0.0) + little-plugger (~> 1.1) + multi_json (~> 1.10) memoist (0.12.0) metaclass (0.0.4) metadata-json-lint (0.0.6) json spdx-licenses (~> 1.0) - mime-types (2.4.3) + mime-types (2.6.1) mini_portile (0.6.2) - minitest (5.6.0) + minitest (5.7.0) mocha (1.1.0) metaclass (~> 0.0.1) multi_json (1.11.0) @@ -192,15 +198,15 @@ GEM net-ssh (2.9.2) nokogiri (1.6.6.2) mini_portile (~> 0.6.0) - puppet (3.7.5) - facter (> 1.6, < 3) - hiera (~> 1.0) + puppet (4.1.0) + facter (> 2.0, < 4) + hiera (>= 2.0, < 3) json_pure puppet-lint (1.1.0) puppet-syntax (2.0.0) rake puppet_facts (0.2.1) - puppetlabs_spec_helper (0.10.2) + puppetlabs_spec_helper (0.10.3) mocha puppet-lint puppet-syntax @@ -212,35 +218,35 @@ GEM nokogiri (>= 1.4.1) trollop retriable (1.4.1) - rspec (3.2.0) - rspec-core (~> 3.2.0) - rspec-expectations (~> 3.2.0) - rspec-mocks (~> 3.2.0) - rspec-core (3.2.3) - rspec-support (~> 3.2.0) - rspec-expectations (3.2.1) + rspec (3.3.0) + rspec-core (~> 3.3.0) + rspec-expectations (~> 3.3.0) + rspec-mocks (~> 3.3.0) + rspec-core (3.3.0) + rspec-support (~> 3.3.0) + rspec-expectations (3.3.0) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.2.0) + rspec-support (~> 3.3.0) rspec-its (1.2.0) rspec-core (>= 3.0.0) rspec-expectations (>= 3.0.0) - rspec-mocks (3.2.1) + rspec-mocks (3.3.0) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.2.0) - rspec-puppet (2.1.0) + rspec-support (~> 3.3.0) + rspec-puppet (2.2.0) rspec - rspec-support (3.2.2) + rspec-support (3.3.0) rsync (1.0.9) - serverspec (2.14.1) + serverspec (2.18.0) multi_json rspec (~> 3.0) rspec-its - specinfra (~> 2.25) - signet (0.6.0) + specinfra (~> 2.35) + signet (0.6.1) addressable (~> 2.3) extlib (~> 0.9) faraday (~> 0.9) - jwt (~> 1.0) + jwt (~> 1.5) multi_json (~> 1.10) simplecov (0.10.0) docile (~> 1.1.0) @@ -249,7 +255,7 @@ GEM simplecov-html (0.10.0) spdx-licenses (1.0.0) json - specinfra (2.30.0) + specinfra (2.36.0) net-scp net-ssh thread_safe (0.3.5) @@ -276,3 +282,6 @@ DEPENDENCIES rspec-puppet serverspec simplecov + +BUNDLED WITH + 1.10.3 diff --git a/module-collectd/README.md b/module-collectd/README.md index fd7d44c75..7bb37bdb4 100644 --- a/module-collectd/README.md +++ b/module-collectd/README.md @@ -158,8 +158,17 @@ class { 'collectd::plugin::conntrack': ####Class: `collectd::plugin::cpu` + * `reportbystate` available from collectd version >= 5.5 + * `reportbycpu` available from collectd version >= 5.5 + * `valuespercentage` available from collectd version >= 5.5 + + See [collectd plugin_cpu documentation](https://collectd.org/documentation/manpages/collectd.conf.5.shtml#plugin_cpu) for more details. + ```puppet class { 'collectd::plugin::cpu': + reportbystate => true, + reportbycpu => true, + valuespercentage => true, } @@ -977,4 +986,4 @@ This module shall not use unsupported configuration directives. Look at [templat Please make use of the search by branch/tags on the collectd github to see when a function has been first released. -Reading the [collectd.conf.pod](https://github.com/collectd/collectd/blob/master/src/collectd.conf.pod) file is good, validating the presence of the code in the .c files is even better. \ No newline at end of file +Reading the [collectd.conf.pod](https://github.com/collectd/collectd/blob/master/src/collectd.conf.pod) file is good, validating the presence of the code in the .c files is even better. diff --git a/module-collectd/manifests/plugin/cpu.pp b/module-collectd/manifests/plugin/cpu.pp index 3de279df1..3f8a0a94b 100644 --- a/module-collectd/manifests/plugin/cpu.pp +++ b/module-collectd/manifests/plugin/cpu.pp @@ -1,10 +1,21 @@ # https://collectd.org/wiki/index.php/Plugin:CPU class collectd::plugin::cpu ( - $ensure = present, - $interval = undef, + $ensure = present, + $reportbystate = true, + $reportbycpu = true, + $valuespercentage = false, + $interval = undef, ) { + + validate_bool( + $reportbystate, + $reportbycpu, + $valuespercentage, + ) + collectd::plugin {'cpu': ensure => $ensure, + content => template('collectd/plugin/cpu.conf.erb'), interval => $interval, } } diff --git a/module-collectd/manifests/plugin/snmp/host.pp b/module-collectd/manifests/plugin/snmp/host.pp index 03495f723..7438e4e68 100644 --- a/module-collectd/manifests/plugin/snmp/host.pp +++ b/module-collectd/manifests/plugin/snmp/host.pp @@ -3,7 +3,7 @@ $collect, $ensure = present, $address = $name, - $version = 1, + $version = '1', $community = 'public', $interval = undef, ) { diff --git a/module-collectd/manifests/plugin/write_http.pp b/module-collectd/manifests/plugin/write_http.pp index cfa5e7942..3497071bf 100644 --- a/module-collectd/manifests/plugin/write_http.pp +++ b/module-collectd/manifests/plugin/write_http.pp @@ -7,12 +7,6 @@ validate_hash($urls) - if $::osfamily == 'Redhat' { - package { 'collectd-write_http': - ensure => $ensure, - } - } - collectd::plugin {'write_http': ensure => $ensure, content => template('collectd/plugin/write_http.conf.erb'), diff --git a/module-collectd/metadata.json b/module-collectd/metadata.json index 3c6355fc8..70eb423a5 100644 --- a/module-collectd/metadata.json +++ b/module-collectd/metadata.json @@ -42,7 +42,6 @@ { "operatingsystem": "Ubuntu", "operatingsystemrelease": [ - "10.04", "12.04", "14.04" ] @@ -71,7 +70,7 @@ } ], "name": "pdxcat-collectd", - "version": "3.3.0", + "version": "3.4.0", "source": "https://github.com/pdxcat/puppet-module-collectd", "author": "Computer Action Team", "license": "Apache-2.0", diff --git a/module-collectd/spec/classes/collectd_plugin_cpu_spec.rb b/module-collectd/spec/classes/collectd_plugin_cpu_spec.rb new file mode 100644 index 000000000..4f22c4845 --- /dev/null +++ b/module-collectd/spec/classes/collectd_plugin_cpu_spec.rb @@ -0,0 +1,86 @@ +require 'spec_helper' + +describe 'collectd::plugin::cpu', :type => :class do + + let :facts do + {:osfamily => 'RedHat'} + end + + context ':ensure => present' do + context ':ensure => present and collectd version < 5.5' do + + it 'Will create /etc/collectd.d/10-cpu.conf to load the plugin' do + should contain_file('cpu.load').with({ + :ensure => 'present', + :path => '/etc/collectd.d/10-cpu.conf', + :content => /LoadPlugin cpu/, + }) + end + + it 'Will not include ReportByState in /etc/collectd.d/10-cpu.conf' do + should_not contain_file('cpu.load').with_content(/ReportByState/) + end + + it 'Will not include ReportByCpu in /etc/collectd.d/10-cpu.conf' do + should_not contain_file('cpu.load').with_content(/ReportByCpu/) + end + + it 'Will not include ValuesPercentage in /etc/collectd.d/10-cpu.conf' do + should_not contain_file('cpu.load').with_content(/ValuesPercentage/) + end + end + + context 'cpu options should be set with collectd 5.5' do + let :facts do + {:osfamily => 'RedHat', + :collectd_version => '5.5', + } + end + let :params do + {:reportbystate => false, + :reportbycpu => false, + :valuespercentage => true, + } + end + + it 'Will include ReportByState in /etc/collectd.d/10-cpu.conf' do + should contain_file('cpu.load').with_content(/ReportByState = false/) + end + + it 'Will include ReportByCpu in /etc/collectd.d/10-cpu.conf' do + should contain_file('cpu.load').with_content(/ReportByCpu = false/) + end + + it 'Will include ValuesPercentage in /etc/collectd.d/10-cpu.conf' do + should contain_file('cpu.load').with_content(/ValuesPercentage = true/) + end + end + end + + context 'default parameters are not booleans' do + let :params do + {:reportbystate => 'string_a', + :reportbycpu => 'string_b', + :valuespercentage => 'string_c', + } + end + + it 'Will raise an error about parameters not being boolean' do + should compile.and_raise_error(/bool/) + end + + end + + context ':ensure => absent' do + let :params do + {:ensure => 'absent'} + end + it 'Will remove /etc/collectd.d/10-cpu.conf' do + should contain_file('cpu.load').with({ + :ensure => 'absent', + :path => '/etc/collectd.d/10-cpu.conf', + :content => /LoadPlugin cpu/, + }) + end + end +end diff --git a/module-collectd/templates/plugin/cpu.conf.erb b/module-collectd/templates/plugin/cpu.conf.erb new file mode 100644 index 000000000..afe04045f --- /dev/null +++ b/module-collectd/templates/plugin/cpu.conf.erb @@ -0,0 +1,7 @@ + +<% if @collectd_version and (scope.function_versioncmp([@collectd_version, '5.5']) >= 0) -%> + ReportByState = <%= @reportbystate %> + ReportByCpu = <%= @reportbycpu %> + ValuesPercentage = <%= @valuespercentage %> +<% end -%> + diff --git a/module-collectd/tests/plugins/tail.pp b/module-collectd/tests/plugins/tail.pp index 05454efe5..26d749a6b 100644 --- a/module-collectd/tests/plugins/tail.pp +++ b/module-collectd/tests/plugins/tail.pp @@ -5,16 +5,16 @@ instance => 'exim', matches => [ { - regex => 'S=([1-9][0-9]*)', - dstype => 'CounterAdd', - type => 'ipt_bytes', - instance => 'total', + 'regex' => 'S=([1-9][0-9]*)', + 'dstype' => 'CounterAdd', + 'type' => 'ipt_bytes', + 'instance' => 'total', }, { - regex => '\\', - dstype => 'CounterInc', - type => 'counter', - instance => 'local_user', + 'regex' => '\\', + 'dstype' => 'CounterInc', + 'type' => 'counter', + 'instance' => 'local_user', } ] } @@ -24,10 +24,10 @@ instance => 'auth', matches => [ { - regex => '\\', - dstype => 'CounterInc', - type => 'counter', - instance => 'auth-publickey', + 'regex' => '\\', + 'dstype' => 'CounterInc', + 'type' => 'counter', + 'instance' => 'auth-publickey', } ] }