From e0e8102c0a7b642c6224f4c6de50f8db5302d7ba Mon Sep 17 00:00:00 2001 From: Piotr Rabiega Date: Fri, 7 Feb 2020 13:32:03 +0100 Subject: [PATCH 01/37] Add pcie_errors plugin --- README.md | 12 +++ manifests/plugin/pcie_errors.pp | 15 +++ .../collectd_plugin_pcie_errors_spec.rb | 98 +++++++++++++++++++ templates/plugin/pcie_errors.conf.epp | 14 +++ 4 files changed, 139 insertions(+) create mode 100644 manifests/plugin/pcie_errors.pp create mode 100644 spec/classes/collectd_plugin_pcie_errors_spec.rb create mode 100644 templates/plugin/pcie_errors.conf.epp diff --git a/README.md b/README.md index 9dbe10c3f..cbfd50f78 100644 --- a/README.md +++ b/README.md @@ -159,6 +159,7 @@ documentation for each plugin for configurable attributes. * `nut` (see [collectd::plugin::nut](#class-collectdpluginnut) below) * `openldap` (see [collectd::plugin::openldap](#class-collectdpluginopenldap) below) * `openvpn` (see [collectd::plugin::openvpn](#class-collectdpluginopenvpn) below) +* `pcie_errors` (see [collectd::plugin::pcie_errors](#class-collectdpluginpcie_errors) below) * `perl` (see [collectd::plugin::perl](#class-collectdpluginperl) below) * `ping` (see [collectd::plugin::ping](#class-collectdpluginping) below) * `postgresql` (see [collectd::plugin::postgresql](#class-collectdpluginpostgresql) @@ -1234,6 +1235,17 @@ class { 'collectd::plugin::openvpn': } ``` +#### Class: `collectd::plugin::pcie_errors` + +```puppet +class { 'collectd::plugin::pcie_errors': + source => undef, + access_dir => undef, + report_masked => false, + persistent_notifications => false, +} +``` + #### Class: `collectd::plugin::perl` This class has no parameters and will load the actual perl plugin. diff --git a/manifests/plugin/pcie_errors.pp b/manifests/plugin/pcie_errors.pp new file mode 100644 index 000000000..99c75cff0 --- /dev/null +++ b/manifests/plugin/pcie_errors.pp @@ -0,0 +1,15 @@ +class collectd::plugin::pcie_errors ( + Enum['present', 'absent'] $ensure = 'present', + Optional[String] $source = 'sysfs', + Optional[String] $access_dir = undef, + Optional[Boolean] $report_masked = false, + Optional[Boolean] $persistent_notifications = false, +) { + + include collectd + + collectd::plugin { 'pcie_errors': + ensure => $ensure, + content => epp('collectd/plugin/pcie_errors.conf.epp'), + } +} diff --git a/spec/classes/collectd_plugin_pcie_errors_spec.rb b/spec/classes/collectd_plugin_pcie_errors_spec.rb new file mode 100644 index 000000000..f1bb00ce0 --- /dev/null +++ b/spec/classes/collectd_plugin_pcie_errors_spec.rb @@ -0,0 +1,98 @@ +require 'spec_helper' + +describe 'collectd::plugin::pcie_errors', type: :class do + on_supported_os(baseline_os_hash).each do |os, facts| + context "on #{os} " do + let :facts do + facts + end + + options = os_specific_options(facts) + + context ':ensure => present, default params' do + content = < + Globals false + + + + Source "sysfs" + ReportMasked false +# PersistentNotifications false + + +EOS + + it "Will create #{options[:plugin_conf_dir]}/10-pcie_errors.conf" do + is_expected.to compile.with_all_deps + is_expected.to contain_file('pcie_errors.load').with( + ensure: 'present', + path: "#{options[:plugin_conf_dir]}/10-pcie_errors.conf", + content: content + ) + end + end + + context ':ensure => present and :source => sfsys' do + let :params do + { source: 'sfsys' } + end + + it "Will create #{options[:plugin_conf_dir]}/10-pcie_errors.conf" do + is_expected.to compile.with_all_deps + is_expected.to contain_file('pcie_errors.load').with( + ensure: 'present', + path: "#{options[:plugin_conf_dir]}/10-pcie_errors.conf", + content: %r{Source "sfsys"}m + ) + end + end + + context ':ensure => present and :access_dir => /sys/bus/pci' do + let :params do + { access_dir: '/sys/bus/pci' } + end + + it "Will create #{options[:plugin_conf_dir]}/10-pcie_errors.conf" do + is_expected.to compile.with_all_deps + is_expected.to contain_file('pcie_errors.load').with( + ensure: 'present', + path: "#{options[:plugin_conf_dir]}/10-pcie_errors.conf", + content: %r{AccessDir "/sys/bus/pci"}m + ) + end + end + + context ':ensure => present and :report_masked => true' do + let :params do + { report_masked: true } + end + + it "Will create #{options[:plugin_conf_dir]}/10-pcie_errors.conf" do + is_expected.to compile.with_all_deps + is_expected.to contain_file('pcie_errors.load').with( + ensure: 'present', + path: "#{options[:plugin_conf_dir]}/10-pcie_errors.conf", + content: %r{ReportMasked true}m + ) + end + end + + context ':ensure => present and :persistent_notifications => true' do + let :params do + { persistent_notifications: true } + end + + it "Will create #{options[:plugin_conf_dir]}/10-pcie_errors.conf" do + is_expected.to compile.with_all_deps + is_expected.to contain_file('pcie_errors.load').with( + ensure: 'present', + path: "#{options[:plugin_conf_dir]}/10-pcie_errors.conf", + content: %r{PersistentNotifications true}m + ) + end + end + end + end +end diff --git a/templates/plugin/pcie_errors.conf.epp b/templates/plugin/pcie_errors.conf.epp new file mode 100644 index 000000000..fa33578b4 --- /dev/null +++ b/templates/plugin/pcie_errors.conf.epp @@ -0,0 +1,14 @@ + +<% if $collectd::plugin::pcie_errors::source { -%> + Source "<%= $collectd::plugin::pcie_errors::source %>" +<% } -%> +<% if $collectd::plugin::pcie_errors::access_dir { -%> + AccessDir "<%= $collectd::plugin::pcie_errors::access_dir %>" +<% } -%> +<% unless $collectd::plugin::pcie_errors::report_masked =~ Undef { -%> + ReportMasked <%= $collectd::plugin::pcie_errors::report_masked %> +<% } -%> +<% unless $collectd::plugin::pcie_errors::persistent_notifications =~ Undef { -%> +# PersistentNotifications <%= $collectd::plugin::pcie_errors::persistent_notifications %> +<% } -%> + From 720186af2da1b34b142fcaf8b78d561af5d0ac6f Mon Sep 17 00:00:00 2001 From: Alexander Fisher Date: Sat, 2 Mar 2019 19:06:57 +0000 Subject: [PATCH 02/37] Change all `port` parameters to use `Stdlib::Port` Instead of having a mix of strings and integers, all port parameters should be using `Stdlib::Port`. I've also changed some `String`s to `Stdlib::Host`, but none of these should be breaking changes. --- manifests/plugin/amqp1.pp | 4 ++-- manifests/plugin/dns.pp | 14 +++++++------- manifests/plugin/hddtemp.pp | 4 ++-- manifests/plugin/mongodb.pp | 6 +++--- manifests/plugin/mysql/database.pp | 2 +- manifests/plugin/network/listener.pp | 2 +- manifests/plugin/network/server.pp | 2 +- manifests/plugin/ntpd.pp | 4 ++-- manifests/plugin/ovs_events.pp | 4 ++-- manifests/plugin/ovs_stats.pp | 4 ++-- manifests/plugin/postgresql/database.pp | 4 ++-- manifests/plugin/statsd.pp | 4 ++-- manifests/plugin/tcpconns.pp | 4 ++-- manifests/plugin/write_graphite/carbon.pp | 4 ++-- manifests/plugin/write_kafka.pp | 2 +- manifests/plugin/write_prometheus.pp | 4 ++-- manifests/plugin/write_sensu.pp | 4 ++-- manifests/plugin/write_tsdb.pp | 4 ++-- manifests/plugin/zookeeper.pp | 4 ++-- spec/classes/collectd_plugin_amqp1_spec.rb | 4 ++-- spec/classes/collectd_plugin_mongodb_spec.rb | 4 ++-- .../classes/collectd_plugin_mysql_database_spec.rb | 2 +- spec/classes/collectd_plugin_postgresql_spec.rb | 4 ++-- spec/classes/collectd_plugin_statsd_spec.rb | 2 +- spec/classes/collectd_plugin_write_kafka_spec.rb | 2 +- .../collectd_plugin_write_prometheus_spec.rb | 4 ++-- spec/classes/collectd_plugin_zookeeper_spec.rb | 2 +- types/redis/node.pp | 2 +- 28 files changed, 53 insertions(+), 53 deletions(-) diff --git a/manifests/plugin/amqp1.pp b/manifests/plugin/amqp1.pp index f2e4c7095..83c94f2e8 100644 --- a/manifests/plugin/amqp1.pp +++ b/manifests/plugin/amqp1.pp @@ -27,7 +27,7 @@ # Service name or port number on which the AMQP 1.0 intermediary accepts # connections. This argument must be a string, even if the numeric form # is used. -# Defaults to '5672' +# Defaults to 5672 # # [*user*] # User part of credentials used to authenticate to the AMQP 1.0 intermediary. @@ -104,7 +104,7 @@ Boolean $manage_package = $collectd::manage_package, String $transport = 'metrics', Stdlib::Host $host = 'localhost', - String $port = '5672', + Stdlib::Port $port = 5672, String $user = 'guest', String $password = 'guest', String $address = 'collectd', diff --git a/manifests/plugin/dns.pp b/manifests/plugin/dns.pp index f58a94069..a4e09d197 100644 --- a/manifests/plugin/dns.pp +++ b/manifests/plugin/dns.pp @@ -1,13 +1,13 @@ # Class: collectd::plugin::dns # class collectd::plugin::dns ( - Enum['present','absent'] $ensure = 'present', - Optional[Stdlib::Compat::Ip_address] $ignoresource = undef, - String $interface = 'any', - Optional[String] $interval = undef, - $manage_package = undef, - $package_name = 'collectd-dns', - Variant[String,Boolean] $selectnumericquerytypes = true, + Enum['present','absent'] $ensure = 'present', + Optional[Stdlib::IP::Address] $ignoresource = undef, + String $interface = 'any', + Optional[String] $interval = undef, + $manage_package = undef, + $package_name = 'collectd-dns', + Variant[String,Boolean] $selectnumericquerytypes = true, ) { include collectd diff --git a/manifests/plugin/hddtemp.pp b/manifests/plugin/hddtemp.pp index 5d169256c..c94f6c399 100644 --- a/manifests/plugin/hddtemp.pp +++ b/manifests/plugin/hddtemp.pp @@ -1,7 +1,7 @@ # https://collectd.org/wiki/index.php/Plugin:HDDTemp class collectd::plugin::hddtemp ( - $host = '127.0.0.1', - Integer $port = 7634, + Stdlib::Host $host = '127.0.0.1', + Stdlib::Port $port = 7634, $ensure = 'present', $interval = undef, ) { diff --git a/manifests/plugin/mongodb.pp b/manifests/plugin/mongodb.pp index 7b8057162..49f5be7fd 100644 --- a/manifests/plugin/mongodb.pp +++ b/manifests/plugin/mongodb.pp @@ -5,8 +5,8 @@ String $db_pass, Enum['absent','present'] $ensure = 'present', Optional[Variant[String,Float]] $interval = undef, - Stdlib::Compat::Ip_address $db_host = '127.0.0.1', - Optional[String] $db_port = undef, + Stdlib::Host $db_host = '127.0.0.1', + Optional[Stdlib::Port] $db_port = undef, Optional[Array] $configured_dbs = undef, $collectd_dir = '/usr/lib/collectd', ) { @@ -14,7 +14,7 @@ include collectd if $configured_dbs { - assert_type(String, $db_port) + assert_type(Stdlib::Port, $db_port) } collectd::plugin { 'mongodb': diff --git a/manifests/plugin/mysql/database.pp b/manifests/plugin/mysql/database.pp index 6783aca67..95174b9dc 100644 --- a/manifests/plugin/mysql/database.pp +++ b/manifests/plugin/mysql/database.pp @@ -5,7 +5,7 @@ String $host = 'UNSET', String $username = 'UNSET', String $password = 'UNSET', - String $port = '3306', + Stdlib::Port $port = 3306, Boolean $masterstats = false, Boolean $slavestats = false, Optional[String] $socket = undef, diff --git a/manifests/plugin/network/listener.pp b/manifests/plugin/network/listener.pp index 59a9957df..7807b2c9a 100644 --- a/manifests/plugin/network/listener.pp +++ b/manifests/plugin/network/listener.pp @@ -2,7 +2,7 @@ define collectd::plugin::network::listener ( Enum['present', 'absent'] $ensure = 'present', Optional[Stdlib::Absolutepath] $authfile = undef, - Optional[Integer] $port = undef, + Optional[Stdlib::Port] $port = undef, Optional[Collectd::Network::SecurityLevel] $securitylevel = undef, Optional[String] $interface = undef, ) { diff --git a/manifests/plugin/network/server.pp b/manifests/plugin/network/server.pp index 1bf23cb40..e9a6d6d51 100644 --- a/manifests/plugin/network/server.pp +++ b/manifests/plugin/network/server.pp @@ -3,7 +3,7 @@ Enum['present', 'absent'] $ensure = 'present', Optional[String] $username = undef, Optional[String] $password = undef, - Optional[Integer] $port = undef, + Optional[Stdlib::Port] $port = undef, Optional[Collectd::Network::SecurityLevel] $securitylevel = undef, Optional[String] $interface = undef, Optional[Boolean] $forward = undef, diff --git a/manifests/plugin/ntpd.pp b/manifests/plugin/ntpd.pp index 34427651a..7cf7d410e 100644 --- a/manifests/plugin/ntpd.pp +++ b/manifests/plugin/ntpd.pp @@ -1,8 +1,8 @@ # https://collectd.org/wiki/index.php/Plugin:NTPd class collectd::plugin::ntpd ( $ensure = 'present', - $host = 'localhost', - $port = 123, + Stdlib::Host $host = 'localhost', + Stdlib::Port $port = 123, $reverselookups = false, $includeunitid = false, $interval = undef, diff --git a/manifests/plugin/ovs_events.pp b/manifests/plugin/ovs_events.pp index 0db41844d..e606dbbb7 100644 --- a/manifests/plugin/ovs_events.pp +++ b/manifests/plugin/ovs_events.pp @@ -36,7 +36,7 @@ # Defaults to 'collectd-ovs_stats' # # [*port*] -# TCP-port to connect to. Either a service name or a port number may be given. +# TCP-port to connect to. # # [*socket*] # The UNIX domain socket path of OVS DB server JSON-RPC interface used @@ -50,7 +50,7 @@ Boolean $manage_package = true, Optional[Boolean] $send_notification = undef, String $package_name = 'collectd-ovs-events', - Optional[Integer] $port = undef, + Optional[Stdlib::Port] $port = undef, Optional[String] $socket = undef, ) { diff --git a/manifests/plugin/ovs_stats.pp b/manifests/plugin/ovs_stats.pp index e24942582..0eec529b9 100644 --- a/manifests/plugin/ovs_stats.pp +++ b/manifests/plugin/ovs_stats.pp @@ -27,7 +27,7 @@ # Defaults to 'collectd-ovs_stats' # # [*port*] -# TCP-port to connect to. Either a service name or a port number may be given. +# TCP-port to connect to. # # [*socket*] # The UNIX domain socket path of OVS DB server JSON-RPC interface used @@ -39,7 +39,7 @@ String $ensure = 'present', Boolean $manage_package = true, String $package_name = 'collectd-ovs-stats', - Optional[Integer] $port = undef, + Optional[Stdlib::Port] $port = undef, Optional[String] $socket = undef, ) { diff --git a/manifests/plugin/postgresql/database.pp b/manifests/plugin/postgresql/database.pp index 020a64f3b..73eacac71 100644 --- a/manifests/plugin/postgresql/database.pp +++ b/manifests/plugin/postgresql/database.pp @@ -2,9 +2,9 @@ # useful if you have multiple instances of different version of pg define collectd::plugin::postgresql::database ( $ensure = 'present', - $host = undef, + Optional[Stdlib::Host] $host = undef, $databasename = $name, - $port = undef, + Optional[Stdlib::Port] $port = undef, $user = undef, $password = undef, $sslmode = undef, diff --git a/manifests/plugin/statsd.pp b/manifests/plugin/statsd.pp index cd0ef9ebc..7abed605c 100644 --- a/manifests/plugin/statsd.pp +++ b/manifests/plugin/statsd.pp @@ -1,8 +1,8 @@ # https://collectd.org/wiki/index.php/Plugin:StatsD class collectd::plugin::statsd ( $ensure = 'present', - $host = undef, - $port = undef, + Optional[Stdlib::Host] $host = undef, + Optional[Stdlib::Port] $port = undef, $deletecounters = undef, $deletetimers = undef, $deletegauges = undef, diff --git a/manifests/plugin/tcpconns.pp b/manifests/plugin/tcpconns.pp index e156e9c62..653cd9662 100644 --- a/manifests/plugin/tcpconns.pp +++ b/manifests/plugin/tcpconns.pp @@ -1,7 +1,7 @@ # https://collectd.org/wiki/index.php/Plugin:TCPConns class collectd::plugin::tcpconns ( - Optional[Array] $localports = undef, - Optional[Array] $remoteports = undef, + Optional[Array[Stdlib::Port]] $localports = undef, + Optional[Array[Stdlib::Port]] $remoteports = undef, $listening = undef, $interval = undef, Optional[Boolean] $allportssummary = undef, diff --git a/manifests/plugin/write_graphite/carbon.pp b/manifests/plugin/write_graphite/carbon.pp index 4dc970eff..ff465e237 100644 --- a/manifests/plugin/write_graphite/carbon.pp +++ b/manifests/plugin/write_graphite/carbon.pp @@ -1,8 +1,8 @@ # a single graphite backend define collectd::plugin::write_graphite::carbon ( $ensure = 'present', - $graphitehost = 'localhost', - $graphiteport = 2003, + Stdlib::Host $graphitehost = 'localhost', + Stdlib::Port $graphiteport = 2003, Boolean $storerates = true, $graphiteprefix = 'collectd.', $graphitepostfix = undef, diff --git a/manifests/plugin/write_kafka.pp b/manifests/plugin/write_kafka.pp index baf36ab94..d33ffc3db 100644 --- a/manifests/plugin/write_kafka.pp +++ b/manifests/plugin/write_kafka.pp @@ -2,7 +2,7 @@ $ensure = 'present', $kafka_host = undef, Array[String] $kafka_hosts = ['localhost:9092'], - $kafka_port = 9092, + Stdlib::Port $kafka_port = 9092, Hash $topics = {}, Hash $properties = {}, Hash $meta = {}, diff --git a/manifests/plugin/write_prometheus.pp b/manifests/plugin/write_prometheus.pp index f750cf9a0..18eac1991 100644 --- a/manifests/plugin/write_prometheus.pp +++ b/manifests/plugin/write_prometheus.pp @@ -1,6 +1,6 @@ class collectd::plugin::write_prometheus ( - String $port = '9103', - $ensure = 'present', + Stdlib::Port $port = 9103, + $ensure = 'present', ) { include collectd diff --git a/manifests/plugin/write_sensu.pp b/manifests/plugin/write_sensu.pp index 3b0ed5119..bf6cbdb85 100644 --- a/manifests/plugin/write_sensu.pp +++ b/manifests/plugin/write_sensu.pp @@ -2,8 +2,8 @@ class collectd::plugin::write_sensu ( $ensure = 'present', $manage_package = undef, - $sensu_host = 'localhost', - $sensu_port = 3030, + Stdlib::Host $sensu_host = 'localhost', + Stdlib::Port $sensu_port = 3030, Boolean $store_rates = false, Boolean $always_append_ds = false, $metrics = false, diff --git a/manifests/plugin/write_tsdb.pp b/manifests/plugin/write_tsdb.pp index 6aa638a50..e02ddeec0 100644 --- a/manifests/plugin/write_tsdb.pp +++ b/manifests/plugin/write_tsdb.pp @@ -2,8 +2,8 @@ class collectd::plugin::write_tsdb ( $ensure = present, Boolean $globals = false, - $host = 'localhost', - $port = 4242, + Stdlib::Host $host = 'localhost', + Stdlib::Port $port = 4242, Array $host_tags = [], Boolean $store_rates = false, Boolean $always_append_ds = false, diff --git a/manifests/plugin/zookeeper.pp b/manifests/plugin/zookeeper.pp index b8c25f0e4..8c6054bab 100644 --- a/manifests/plugin/zookeeper.pp +++ b/manifests/plugin/zookeeper.pp @@ -1,8 +1,8 @@ class collectd::plugin::zookeeper ( Enum['present', 'absent'] $ensure = 'present', Optional[Integer] $interval = undef, - String $zookeeper_host = 'localhost', - String $zookeeper_port = '2181', + Stdlib::Host $zookeeper_host = 'localhost', + Stdlib::Port $zookeeper_port = 2181, ) { include collectd diff --git a/spec/classes/collectd_plugin_amqp1_spec.rb b/spec/classes/collectd_plugin_amqp1_spec.rb index 3e350c462..dd9d8e34d 100644 --- a/spec/classes/collectd_plugin_amqp1_spec.rb +++ b/spec/classes/collectd_plugin_amqp1_spec.rb @@ -40,7 +40,7 @@ { ensure: 'present', transport: 'transport', host: 'host', - port: 'port', + port: 666, user: 'user', password: 'password', address: 'address', @@ -63,7 +63,7 @@ it { is_expected.to contain_file('amqp1.load').with(content: %r{}) } it { is_expected.to contain_file('amqp1.load').with(content: %r{Host "host"}) } - it { is_expected.to contain_file('amqp1.load').with(content: %r{Port "port"}) } + it { is_expected.to contain_file('amqp1.load').with(content: %r{Port "666"}) } it { is_expected.to contain_file('amqp1.load').with(content: %r{User "user"}) } it { is_expected.to contain_file('amqp1.load').with(content: %r{Password "password"}) } it { is_expected.to contain_file('amqp1.load').with(content: %r{Address "address"}) } diff --git a/spec/classes/collectd_plugin_mongodb_spec.rb b/spec/classes/collectd_plugin_mongodb_spec.rb index 7c832292b..e6e18e193 100644 --- a/spec/classes/collectd_plugin_mongodb_spec.rb +++ b/spec/classes/collectd_plugin_mongodb_spec.rb @@ -100,7 +100,7 @@ context 'set to a valid value with db_port defined and a single db' do let :params do default_params.merge(configured_dbs: [25], - db_port: '8080') + db_port: 8080) end dbport_single_fixture = File.read(fixtures('plugins/mongodb.conf.configured_dbs_single')) @@ -110,7 +110,7 @@ context 'set to a valid value with db_port defined and multiple DBs' do let :params do default_params.merge(configured_dbs: [25, 26], - db_port: '8080') + db_port: 8080) end dbport_multi_fixture = File.read(fixtures('plugins/mongodb.conf.configured_dbs_multiple')) diff --git a/spec/classes/collectd_plugin_mysql_database_spec.rb b/spec/classes/collectd_plugin_mysql_database_spec.rb index a32e70363..95db4f537 100644 --- a/spec/classes/collectd_plugin_mysql_database_spec.rb +++ b/spec/classes/collectd_plugin_mysql_database_spec.rb @@ -21,7 +21,7 @@ { 'aliasname' => 'fancyname', 'host' => 'database.serv.er', - 'port' => '8010', + 'port' => 8010, 'username' => 'db_user', 'password' => 'secret', 'sslkey' => '/path/to/key.pem', diff --git a/spec/classes/collectd_plugin_postgresql_spec.rb b/spec/classes/collectd_plugin_postgresql_spec.rb index 86e815f21..65b822689 100644 --- a/spec/classes/collectd_plugin_postgresql_spec.rb +++ b/spec/classes/collectd_plugin_postgresql_spec.rb @@ -79,7 +79,7 @@ 'host' => 'localhost', 'user' => 'postgres', 'password' => 'postgres', - 'port' => '5432', + 'port' => 5432, 'sslmode' => 'disable', 'query' => %w[disk_io log_delay] }, @@ -88,7 +88,7 @@ 'host' => 'localhost', 'user' => 'postgres', 'password' => 'postgres', - 'port' => '5433', + 'port' => 5433, 'sslmode' => 'disable', 'query' => %w[disk_io log_delay] diff --git a/spec/classes/collectd_plugin_statsd_spec.rb b/spec/classes/collectd_plugin_statsd_spec.rb index c1bcba221..00aeda047 100644 --- a/spec/classes/collectd_plugin_statsd_spec.rb +++ b/spec/classes/collectd_plugin_statsd_spec.rb @@ -28,7 +28,7 @@ { ensure: 'present', host: '192.0.0.1', - port: '9876' + port: 9876 } end diff --git a/spec/classes/collectd_plugin_write_kafka_spec.rb b/spec/classes/collectd_plugin_write_kafka_spec.rb index 64941af31..885fad0ca 100644 --- a/spec/classes/collectd_plugin_write_kafka_spec.rb +++ b/spec/classes/collectd_plugin_write_kafka_spec.rb @@ -10,7 +10,7 @@ options = os_specific_options(facts) context ':ensure => present and :kafka_host => \'myhost\'' do let :params do - { kafka_host: 'myhost', kafka_port: '9092', topics: { 'my-topic' => { 'format' => 'JSON' } }, properties: { 'my-property' => 'my-value' }, meta: { 'my-meta' => 'my-value' } } + { kafka_host: 'myhost', kafka_port: 9092, topics: { 'my-topic' => { 'format' => 'JSON' } }, properties: { 'my-property' => 'my-value' }, meta: { 'my-meta' => 'my-value' } } end it "Will create #{options[:plugin_conf_dir]}/10-write_kafka.conf" do diff --git a/spec/classes/collectd_plugin_write_prometheus_spec.rb b/spec/classes/collectd_plugin_write_prometheus_spec.rb index 400709ff9..ba2039208 100644 --- a/spec/classes/collectd_plugin_write_prometheus_spec.rb +++ b/spec/classes/collectd_plugin_write_prometheus_spec.rb @@ -8,9 +8,9 @@ end options = os_specific_options(facts) - context ':ensure => present and :port => "9103"' do + context ':ensure => present and :port => 9103' do let :params do - { port: '9103' } + { port: 9103 } end it "Will create #{options[:plugin_conf_dir]}/10-write_prometheus.conf" do diff --git a/spec/classes/collectd_plugin_zookeeper_spec.rb b/spec/classes/collectd_plugin_zookeeper_spec.rb index 078f13aaa..9d24fed3d 100644 --- a/spec/classes/collectd_plugin_zookeeper_spec.rb +++ b/spec/classes/collectd_plugin_zookeeper_spec.rb @@ -11,7 +11,7 @@ context ":ensure => present and :zookeeper_host => 'myhost'" do let :params do - { zookeeper_host: 'myhost', zookeeper_port: '2181' } + { zookeeper_host: 'myhost', zookeeper_port: 2181 } end it "Will create #{options[:plugin_conf_dir]}/10-zookeeper.load" do diff --git a/types/redis/node.pp b/types/redis/node.pp index 0be8c06ca..2b1968bbe 100644 --- a/types/redis/node.pp +++ b/types/redis/node.pp @@ -1,2 +1,2 @@ # -type Collectd::Redis::Node = Struct[{Optional['host'] => String[1], Optional['port'] => Variant[Integer[0, 65535], String[1]], Optional['password'] => String[1], Optional['timeout'] => Integer[0], Optional['queries'] => Hash[String[1], Hash[String[1], String[1]]]}] +type Collectd::Redis::Node = Struct[{Optional['host'] => String[1], Optional['port'] => Variant[Stdlib::Port, String[1]], Optional['password'] => String[1], Optional['timeout'] => Integer[0], Optional['queries'] => Hash[String[1], Hash[String[1], String[1]]]}] From d80f953333fb79079bd1955dd706e57347a85033 Mon Sep 17 00:00:00 2001 From: michalrebisz Date: Mon, 10 Feb 2020 13:37:49 +0100 Subject: [PATCH 03/37] Added log parser manifest --- manifests/plugin/log_parser.pp | 13 +++++++++++++ types/log_parser/logfile.pp | 5 +++++ types/log_parser/match.pp | 11 +++++++++++ types/log_parser/message.pp | 8 ++++++++ 4 files changed, 37 insertions(+) create mode 100644 manifests/plugin/log_parser.pp create mode 100644 types/log_parser/logfile.pp create mode 100644 types/log_parser/match.pp create mode 100644 types/log_parser/message.pp diff --git a/manifests/plugin/log_parser.pp b/manifests/plugin/log_parser.pp new file mode 100644 index 000000000..d6bc5589a --- /dev/null +++ b/manifests/plugin/log_parser.pp @@ -0,0 +1,13 @@ +#https://wiki.opnfv.org/display/fastpath/Logparser+plugin+HLD +class collectd::plugin::log_parser ( + $ensure = 'present', + Array[Collectd::LOG_PARSER::Logfile] $logfile = [] +){ +include collectd + + collectd::plugin { 'log_parser': + ensure => $ensure, + content => epp('collectd/plugin/log_parser.conf.epp'), + order => '06', + } +} diff --git a/types/log_parser/logfile.pp b/types/log_parser/logfile.pp new file mode 100644 index 000000000..77bc998cb --- /dev/null +++ b/types/log_parser/logfile.pp @@ -0,0 +1,5 @@ +#https://wiki.opnfv.org/display/fastpath/Logparser+plugin+HLD +type Collectd::LOG_PARSER::Logfile = Struct[{ + 'firstfullread' => Boolean, + Array['message'] => Collectd::LOG_PARSER::Message +}] diff --git a/types/log_parser/match.pp b/types/log_parser/match.pp new file mode 100644 index 000000000..3be628115 --- /dev/null +++ b/types/log_parser/match.pp @@ -0,0 +1,11 @@ +#https://wiki.opnfv.org/display/fastpath/Logparser+plugin+HLD +type Collectd::LOG_PARSER::Match = Struct[{ + 'regex' => String, + Optional['submatchidx'] => String, + Optional['excluderegex'] => String, + Optional['ismandatory'] => Boolean, + Optional['severity'] => Enum['ok', 'warning', 'failure'], + Optional['plugininstance'] => String, + Optional['type'] => String, + Optional['typeinstance'] => String +}] diff --git a/types/log_parser/message.pp b/types/log_parser/message.pp new file mode 100644 index 000000000..a6532769d --- /dev/null +++ b/types/log_parser/message.pp @@ -0,0 +1,8 @@ +#https://wiki.opnfv.org/display/fastpath/Logparser+plugin+HLD +type Collectd::LOG_PARSER::Message = Struct[{ + 'defaultplugininstance' => 'plugin instance', + 'defaulttype' => 'type', + 'defaulttypeinstance' => 'type instance', + 'defaultseverity' => 'ok', + Array['match'] => [Collectd::LOG_PARSER::Match] +}] From 0e6afa0906b735e829d0e478c95cd15419064a0b Mon Sep 17 00:00:00 2001 From: michalrebisz Date: Tue, 11 Feb 2020 10:04:08 +0100 Subject: [PATCH 04/37] log parser plugin template --- manifests/plugin/log_parser.pp | 4 ++- templates/plugin/log_parser.conf.epp | 51 ++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 templates/plugin/log_parser.conf.epp diff --git a/manifests/plugin/log_parser.pp b/manifests/plugin/log_parser.pp index d6bc5589a..935f52851 100644 --- a/manifests/plugin/log_parser.pp +++ b/manifests/plugin/log_parser.pp @@ -7,7 +7,9 @@ collectd::plugin { 'log_parser': ensure => $ensure, - content => epp('collectd/plugin/log_parser.conf.epp'), + content => epp('collectd/plugin/log_parser.conf.epp', { + 'logfile' => $logfile, + }), order => '06', } } diff --git a/templates/plugin/log_parser.conf.epp b/templates/plugin/log_parser.conf.epp new file mode 100644 index 000000000..d0c7fb2ad --- /dev/null +++ b/templates/plugin/log_parser.conf.epp @@ -0,0 +1,51 @@ +<%- | Optional $logfile = undef | -%> + +<% $logfile.keys.sort.each |$path,$file| { -%> +"> +<% unless $file['firstfullread'] =~ Undef { -%> +FirstFullRead "<%= $table['firstfullread'] %>" +<% } -%> +<% $file['message'].each |$key,$message| { -%> +"> +<% unless $message['defaultplugininstance'] =~ Undef { -%> +DefaultPluginInstance "<%= $message['defaultplugininstance'] %>" +<% } -%> +<% unless $message['defaulttype'] =~ Undef { -%> +DefaultType "<%= $message['defaulttype'] %>" +<% } -%> +<% unless $message['defaulttypeinstance'] =~ Undef { -%> +DefaultTypeInstance "<%= $message['defaulttypeinstance'] %>" +<% } -%> +<% unless $message['defaultseverity'] =~ Undef { -%> +DefaultSeverity "<%= $message['defaultseverity'] %>" +<% } -%> +<% $message['match'].each |$key,$match| { -%> +"> +Regex "<%= $match['regex'] %>" +<% unless $match['submatchidx'] =~ Undef { -%> +SubmatchIdx "<%= $match['submatchidx'] %>" +<% } -%> +<% unless $match['excluderegex'] =~ Undef { -%> +ExcludeRegex "<%= $match['excluderegex'] %>" +<% } -%> +<% unless $match['ismandatory'] =~ Undef { -%> +IsMandatory "<%= $match['ismandatory'] %>" +<% } -%> +<% unless $match['severity'] =~ Undef { -%> +Severity "<%= $match['severity'] %>" +<% } -%> +<% unless $match['plugininstance'] =~ Undef { -%> +PluginInstance "<%= $message['plugininstance'] %>" +<% } -%> +<% unless $message['type'] =~ Undef { -%> +Type "<%= $match['type'] %>" +<% } -%> +<% unless $match['typeinstance'] =~ Undef { -%> +TypeInstance "<%= $match['typeinstance'] %>" +<% } -%> + +<% } -%> + +<% } -%> + + From 171916572bb1c35ad6851e9f7c237fd97775960b Mon Sep 17 00:00:00 2001 From: michal rebisz Date: Wed, 12 Feb 2020 12:56:55 +0100 Subject: [PATCH 05/37] Added tests for log parser --- manifests/plugin/log_parser.pp | 2 +- .../collectd_plugin_log_parser_spec.rb | 63 +++++++++++++++ templates/plugin/log_parser.conf.epp | 79 ++++++++++++------- types/log_parser/logfile.pp | 2 +- types/log_parser/match.pp | 2 +- types/log_parser/message.pp | 10 +-- 6 files changed, 120 insertions(+), 38 deletions(-) create mode 100644 spec/classes/collectd_plugin_log_parser_spec.rb diff --git a/manifests/plugin/log_parser.pp b/manifests/plugin/log_parser.pp index 935f52851..ee07c43f8 100644 --- a/manifests/plugin/log_parser.pp +++ b/manifests/plugin/log_parser.pp @@ -1,7 +1,7 @@ #https://wiki.opnfv.org/display/fastpath/Logparser+plugin+HLD class collectd::plugin::log_parser ( $ensure = 'present', - Array[Collectd::LOG_PARSER::Logfile] $logfile = [] + Array[Hash[String[1],Collectd::LOG_PARSER::Logfile]] $logfile = [] ){ include collectd diff --git a/spec/classes/collectd_plugin_log_parser_spec.rb b/spec/classes/collectd_plugin_log_parser_spec.rb new file mode 100644 index 000000000..620aa079b --- /dev/null +++ b/spec/classes/collectd_plugin_log_parser_spec.rb @@ -0,0 +1,63 @@ +require 'spec_helper' + +describe 'collectd::plugin::log_parser', type: :class do + on_supported_os(baseline_os_hash).each do |os, facts| + context "on #{os} " do + let :facts do + facts + end + + it { is_expected.to compile.with_all_deps } + + options = os_specific_options(facts) + context ':ensure => present, default params' do + it "Will create #{options[:plugin_conf_dir]}/06-log_parser.conf" do + is_expected.to contain_file('log_parser.load').with( + ensure: 'present', + path: "#{options[:plugin_conf_dir]}/06-log_parser.conf" + ) + end + end + + context ':ensure => log parser created with logfile' do + let :params do + { + logfile:[ + 'file01.log' => { + 'message' => [ + 'msg_1' => { + 'defaultplugininstance' => 'plugin_instance', + 'defaulttype' => 'type', + 'defaulttypeinstance' => 'type_instance', + 'defaultseverity' => 'ok', + 'match' => [ + 'sample_error' => { + 'regex' => 'regex', + 'submatchidx' => 'index', + 'excluderegex' => 'exclude', + 'ismandatory' => false, + 'severity' => 'severity', + 'plugininstance' => 'plugin_instance', + 'type' => 'type', + 'typeinstance' => 'type_instance' + } + ] + } + ], + 'firstfullread' => false + } + ] + } + end + + it "Will create #{options[:plugin_conf_dir]}/06-log_parser.conf" do + is_expected.to contain_file('log_parser.load').with( + ensure: 'present', + path: "#{options[:plugin_conf_dir]}/06-log_parser.conf" + ) + end + end + + end + end +end diff --git a/templates/plugin/log_parser.conf.epp b/templates/plugin/log_parser.conf.epp index d0c7fb2ad..7989bbaf2 100644 --- a/templates/plugin/log_parser.conf.epp +++ b/templates/plugin/log_parser.conf.epp @@ -1,51 +1,70 @@ <%- | Optional $logfile = undef | -%> -<% $logfile.keys.sort.each |$path,$file| { -%> +<% $logfile.each |$file| { -%> +<% $file.keys.sort.each |$key| { -%> "> -<% unless $file['firstfullread'] =~ Undef { -%> -FirstFullRead "<%= $table['firstfullread'] %>" +<% $file[$key].keys.sort.each |$value| { -%> +<% if $value == 'firstfullread' { -%> +FirstFullRead "<%= $file[$key][$value] %>" <% } -%> -<% $file['message'].each |$key,$message| { -%> -"> -<% unless $message['defaultplugininstance'] =~ Undef { -%> -DefaultPluginInstance "<%= $message['defaultplugininstance'] %>" +<% if $value == 'message' { -%> +<% $file[$key][$value].each |$message| { -%> +<% $message.keys.sort.each |$messagekey| { -%> +"> +<% $message[$messagekey].keys.sort.each |$messagevalue| { -%> +<% if $messagevalue == 'defaultplugininstance' { -%> +DefaultPluginInstance "<%= $message[$messagekey][$messagevalue] %>" <% } -%> -<% unless $message['defaulttype'] =~ Undef { -%> -DefaultType "<%= $message['defaulttype'] %>" +<% if $messagevalue == 'defaultseverity' { -%> +DefaultType "<%= $message[$messagekey][$messagevalue] %>" <% } -%> -<% unless $message['defaulttypeinstance'] =~ Undef { -%> -DefaultTypeInstance "<%= $message['defaulttypeinstance'] %>" +<% if $messagevalue == 'defaulttype' { -%> +DefaultTypeInstance "<%= $message[$messagekey][$messagevalue] %>" <% } -%> -<% unless $message['defaultseverity'] =~ Undef { -%> -DefaultSeverity "<%= $message['defaultseverity'] %>" +<% if $messagevalue == 'defaulttypeinstance' { -%> +DefaultSeverity "<%= $message[$messagekey][$messagevalue] %>" <% } -%> -<% $message['match'].each |$key,$match| { -%> -"> -Regex "<%= $match['regex'] %>" -<% unless $match['submatchidx'] =~ Undef { -%> -SubmatchIdx "<%= $match['submatchidx'] %>" +<% if $messagevalue == 'match' { -%> +<% $message[$messagekey][$messagevalue].each |$match| { -%> +<% $match.keys.sort.each |$matchkey| { -%> +"> +<% $match[$matchkey].keys.sort.each |$matchvalue| { -%> +<% if $matchvalue == 'regex' { -%> +Regex "<%= $match[$matchkey][$matchvalue] %>" <% } -%> -<% unless $match['excluderegex'] =~ Undef { -%> -ExcludeRegex "<%= $match['excluderegex'] %>" +<% if $matchvalue == 'submatchidx' { -%> +SubmatchIdx "<%= $match[$matchkey][$matchvalue] %>" <% } -%> -<% unless $match['ismandatory'] =~ Undef { -%> -IsMandatory "<%= $match['ismandatory'] %>" +<% if $matchvalue == 'excluderegex' { -%> +ExcludeRegex "<%= $match[$matchkey][$matchvalue] %>" <% } -%> -<% unless $match['severity'] =~ Undef { -%> -Severity "<%= $match['severity'] %>" +<% if $matchvalue == 'ismandatory' { -%> +IsMandatory "<%= $match[$matchkey][$matchvalue] %>" <% } -%> -<% unless $match['plugininstance'] =~ Undef { -%> -PluginInstance "<%= $message['plugininstance'] %>" +<% if $matchvalue == 'severity' { -%> +Severity "<%= $match[$matchkey][$matchvalue] %>" <% } -%> -<% unless $message['type'] =~ Undef { -%> -Type "<%= $match['type'] %>" +<% if $matchvalue == 'plugininstance' { -%> +PluginInstance "<%= $match[$matchkey][$matchvalue] %>" +<% } -%> +<% if $matchvalue == 'type' { -%> +Type "<%= $match[$matchkey][$matchvalue] %>" +<% } -%> +<% if $matchvalue == 'typeinstance' { -%> +TypeInstance "<%= $match[$matchkey][$matchvalue] %>" <% } -%> -<% unless $match['typeinstance'] =~ Undef { -%> -TypeInstance "<%= $match['typeinstance'] %>" <% } -%> <% } -%> +<% } -%> +<% } -%> +<% } -%> <% } -%> +<% } -%> +<% } -%> +<% } -%> +<% } -%> +<% } -%> diff --git a/types/log_parser/logfile.pp b/types/log_parser/logfile.pp index 77bc998cb..26cfbc4b7 100644 --- a/types/log_parser/logfile.pp +++ b/types/log_parser/logfile.pp @@ -1,5 +1,5 @@ #https://wiki.opnfv.org/display/fastpath/Logparser+plugin+HLD type Collectd::LOG_PARSER::Logfile = Struct[{ 'firstfullread' => Boolean, - Array['message'] => Collectd::LOG_PARSER::Message + 'message' => Array[Hash[String[1],Collectd::LOG_PARSER::Message]] }] diff --git a/types/log_parser/match.pp b/types/log_parser/match.pp index 3be628115..9f98b12b4 100644 --- a/types/log_parser/match.pp +++ b/types/log_parser/match.pp @@ -4,7 +4,7 @@ Optional['submatchidx'] => String, Optional['excluderegex'] => String, Optional['ismandatory'] => Boolean, - Optional['severity'] => Enum['ok', 'warning', 'failure'], + Optional['severity'] => String, Optional['plugininstance'] => String, Optional['type'] => String, Optional['typeinstance'] => String diff --git a/types/log_parser/message.pp b/types/log_parser/message.pp index a6532769d..5d81a1481 100644 --- a/types/log_parser/message.pp +++ b/types/log_parser/message.pp @@ -1,8 +1,8 @@ #https://wiki.opnfv.org/display/fastpath/Logparser+plugin+HLD type Collectd::LOG_PARSER::Message = Struct[{ - 'defaultplugininstance' => 'plugin instance', - 'defaulttype' => 'type', - 'defaulttypeinstance' => 'type instance', - 'defaultseverity' => 'ok', - Array['match'] => [Collectd::LOG_PARSER::Match] + 'defaultplugininstance' => String, + 'defaulttype' => String, + 'defaulttypeinstance' => String, + 'defaultseverity' => String, + 'match' => Array[Hash[String[1],Collectd::LOG_PARSER::Match]] }] From 2228727ce5b9103cfd5bf517e542e317ed03282e Mon Sep 17 00:00:00 2001 From: michalrebisz Date: Thu, 13 Feb 2020 14:22:27 +0100 Subject: [PATCH 06/37] added default config --- manifests/plugin/log_parser.pp | 63 +++++++++++++++++++++++++++++++++- types/log_parser/match.pp | 2 +- 2 files changed, 63 insertions(+), 2 deletions(-) diff --git a/manifests/plugin/log_parser.pp b/manifests/plugin/log_parser.pp index ee07c43f8..f2dbf6417 100644 --- a/manifests/plugin/log_parser.pp +++ b/manifests/plugin/log_parser.pp @@ -1,7 +1,68 @@ #https://wiki.opnfv.org/display/fastpath/Logparser+plugin+HLD class collectd::plugin::log_parser ( $ensure = 'present', - Array[Hash[String[1],Collectd::LOG_PARSER::Logfile]] $logfile = [] + Array[Hash[String[1],Collectd::LOG_PARSER::Logfile]] $logfile = [{ + '/var/log/syslog' => { + 'firstfullread' => false, + 'message' => [{ + 'pcie_errors' => { + 'defaulttype' => 'pcie_error', + 'defaultseverity' => 'warning', + 'match' => [{ + 'aer error' => { + 'regex' => 'AER:.*error received', + 'submatchidx' = -1 + }, + 'incident time' => { + 'regex' => '(... .. ..:..:..) .* pcieport.*AER', + 'submatchidx' => 1, + 'ismandatory' => false + }, + 'root port' => { + 'regex' =>'pcieport (.*): AER:', + 'submatchidx' => 1, + 'ismandatory' => true + }, + 'device' => { + 'plugininstance' => true, + 'regex' => ' ([0-9a-fA-F:\\.]*): PCIe Bus Error', + 'submatchidx' => 1, + 'ismandatory' => false, + }, + 'severity_mandatory' => { + 'regex' => 'severity=', + 'submatchidx' => 1 + }, + 'nonfatal' => { + 'regex' => 'severity=.*\\([nN]on-[fF]atal', + 'typeinstance' => 'non_fatal', + 'ismandatory' => false + }, + 'fatal' => { + 'regex' => 'severity=.*\\([fF]atal', + 'severity' => 'failure', + 'typeinstance' => 'fatal', + 'ismandatory' => false + }, + 'corrected' => { + 'regex' => 'severity=Corrected', + 'typeinstance' => 'correctable', + 'ismandatory' => false + }, + 'error type' => { + 'regex' => 'type=(.*),', + 'submatchidx' => 1, + 'ismandatory' => false + }, + 'id' => { + 'regex' => ', id=(.*)', + 'submatchidx' => 1 + } + }] + } + }] + } + }] ){ include collectd diff --git a/types/log_parser/match.pp b/types/log_parser/match.pp index 9f98b12b4..c1afdc251 100644 --- a/types/log_parser/match.pp +++ b/types/log_parser/match.pp @@ -1,7 +1,7 @@ #https://wiki.opnfv.org/display/fastpath/Logparser+plugin+HLD type Collectd::LOG_PARSER::Match = Struct[{ 'regex' => String, - Optional['submatchidx'] => String, + Optional['submatchidx'] => Integer, Optional['excluderegex'] => String, Optional['ismandatory'] => Boolean, Optional['severity'] => String, From 8cf801faaf2fbf75ea0423b4ad773dde06a9238f Mon Sep 17 00:00:00 2001 From: michal rebisz Date: Fri, 14 Feb 2020 13:08:40 +0100 Subject: [PATCH 07/37] Added default config to log parser --- manifests/plugin/log_parser.pp | 6 +++--- spec/classes/collectd_plugin_log_parser_spec.rb | 2 +- types/log_parser/match.pp | 8 ++++---- types/log_parser/message.pp | 10 +++++----- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/manifests/plugin/log_parser.pp b/manifests/plugin/log_parser.pp index f2dbf6417..74ff14c68 100644 --- a/manifests/plugin/log_parser.pp +++ b/manifests/plugin/log_parser.pp @@ -4,14 +4,14 @@ Array[Hash[String[1],Collectd::LOG_PARSER::Logfile]] $logfile = [{ '/var/log/syslog' => { 'firstfullread' => false, - 'message' => [{ + 'message' => [ 'pcie_errors' => { 'defaulttype' => 'pcie_error', 'defaultseverity' => 'warning', 'match' => [{ 'aer error' => { 'regex' => 'AER:.*error received', - 'submatchidx' = -1 + 'submatchidx' => -1, }, 'incident time' => { 'regex' => '(... .. ..:..:..) .* pcieport.*AER', @@ -60,7 +60,7 @@ } }] } - }] + ] } }] ){ diff --git a/spec/classes/collectd_plugin_log_parser_spec.rb b/spec/classes/collectd_plugin_log_parser_spec.rb index 620aa079b..3ba7aef72 100644 --- a/spec/classes/collectd_plugin_log_parser_spec.rb +++ b/spec/classes/collectd_plugin_log_parser_spec.rb @@ -33,7 +33,7 @@ 'match' => [ 'sample_error' => { 'regex' => 'regex', - 'submatchidx' => 'index', + 'submatchidx' => 0, 'excluderegex' => 'exclude', 'ismandatory' => false, 'severity' => 'severity', diff --git a/types/log_parser/match.pp b/types/log_parser/match.pp index c1afdc251..2b50b83ff 100644 --- a/types/log_parser/match.pp +++ b/types/log_parser/match.pp @@ -3,9 +3,9 @@ 'regex' => String, Optional['submatchidx'] => Integer, Optional['excluderegex'] => String, - Optional['ismandatory'] => Boolean, + Optional['ismandatory'] => Variant[Boolean, String], Optional['severity'] => String, - Optional['plugininstance'] => String, - Optional['type'] => String, - Optional['typeinstance'] => String + Optional['plugininstance'] => Variant[Boolean, String], + Optional['type'] => Variant[Boolean, String], + Optional['typeinstance'] => Variant[Boolean, String], }] diff --git a/types/log_parser/message.pp b/types/log_parser/message.pp index 5d81a1481..83a9f82e2 100644 --- a/types/log_parser/message.pp +++ b/types/log_parser/message.pp @@ -1,8 +1,8 @@ #https://wiki.opnfv.org/display/fastpath/Logparser+plugin+HLD type Collectd::LOG_PARSER::Message = Struct[{ - 'defaultplugininstance' => String, - 'defaulttype' => String, - 'defaulttypeinstance' => String, - 'defaultseverity' => String, - 'match' => Array[Hash[String[1],Collectd::LOG_PARSER::Match]] + Optional['defaultplugininstance'] => String, + Optional['defaulttype'] => String, + Optional['defaulttypeinstance'] => String, + Optional['defaultseverity'] => String, + Optional['match'] => Array[Hash[String[1],Collectd::LOG_PARSER::Match]] }] From a9e1d4533f9856c78f97bce811a008223c3d3a0d Mon Sep 17 00:00:00 2001 From: michal rebisz Date: Sat, 15 Feb 2020 02:26:57 +0100 Subject: [PATCH 08/37] fixed lint issues --- manifests/plugin/log_parser.pp | 24 +++++++++---------- .../collectd_plugin_log_parser_spec.rb | 7 +++--- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/manifests/plugin/log_parser.pp b/manifests/plugin/log_parser.pp index 74ff14c68..ed23ba25f 100644 --- a/manifests/plugin/log_parser.pp +++ b/manifests/plugin/log_parser.pp @@ -16,12 +16,12 @@ 'incident time' => { 'regex' => '(... .. ..:..:..) .* pcieport.*AER', 'submatchidx' => 1, - 'ismandatory' => false + 'ismandatory' => false, }, 'root port' => { 'regex' =>'pcieport (.*): AER:', 'submatchidx' => 1, - 'ismandatory' => true + 'ismandatory' => true, }, 'device' => { 'plugininstance' => true, @@ -31,36 +31,36 @@ }, 'severity_mandatory' => { 'regex' => 'severity=', - 'submatchidx' => 1 + 'submatchidx' => 1, }, 'nonfatal' => { 'regex' => 'severity=.*\\([nN]on-[fF]atal', 'typeinstance' => 'non_fatal', - 'ismandatory' => false + 'ismandatory' => false, }, 'fatal' => { 'regex' => 'severity=.*\\([fF]atal', 'severity' => 'failure', 'typeinstance' => 'fatal', - 'ismandatory' => false + 'ismandatory' => false, }, 'corrected' => { 'regex' => 'severity=Corrected', 'typeinstance' => 'correctable', - 'ismandatory' => false + 'ismandatory' => false, }, 'error type' => { 'regex' => 'type=(.*),', 'submatchidx' => 1, - 'ismandatory' => false + 'ismandatory' => false, }, 'id' => { 'regex' => ', id=(.*)', - 'submatchidx' => 1 - } - }] - } - ] + 'submatchidx' => 1, + }, + }], + }, + ], } }] ){ diff --git a/spec/classes/collectd_plugin_log_parser_spec.rb b/spec/classes/collectd_plugin_log_parser_spec.rb index 3ba7aef72..db734f2c5 100644 --- a/spec/classes/collectd_plugin_log_parser_spec.rb +++ b/spec/classes/collectd_plugin_log_parser_spec.rb @@ -22,8 +22,8 @@ context ':ensure => log parser created with logfile' do let :params do { - logfile:[ - 'file01.log' => { + logfile: [ + 'file01.log' => { 'message' => [ 'msg_1' => { 'defaultplugininstance' => 'plugin_instance', @@ -45,7 +45,7 @@ } ], 'firstfullread' => false - } + } ] } end @@ -57,7 +57,6 @@ ) end end - end end end From f36c06f665a46e0990cdea1db695161255b1083c Mon Sep 17 00:00:00 2001 From: Piotr Rabiega Date: Mon, 17 Feb 2020 09:16:45 +0100 Subject: [PATCH 09/37] Add puppet string documentation --- manifests/plugin/pcie_errors.pp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/manifests/plugin/pcie_errors.pp b/manifests/plugin/pcie_errors.pp index 99c75cff0..305535e7e 100644 --- a/manifests/plugin/pcie_errors.pp +++ b/manifests/plugin/pcie_errors.pp @@ -1,9 +1,17 @@ +# Class to manage pcie_errors plugin for collectd +# +# @param ensure Ensure param for collectd::plugin type. +# @param source Use sysfs or proc to read data from /sysfs or /proc. +# @param access_dir Directory used to access device config space. +# @param report_masked If true plugin will notify about errors that are set to masked in Error Mask register. +# @param persistent_notifications If false plugin will dispatch notification only on set/clear of error. +# class collectd::plugin::pcie_errors ( Enum['present', 'absent'] $ensure = 'present', Optional[String] $source = 'sysfs', Optional[String] $access_dir = undef, - Optional[Boolean] $report_masked = false, - Optional[Boolean] $persistent_notifications = false, + Boolean $report_masked = false, + Boolean $persistent_notifications = false, ) { include collectd From 2fb0e2da90ebacea72db7d5991d9ce5240534644 Mon Sep 17 00:00:00 2001 From: Piotr Rabiega Date: Tue, 18 Feb 2020 08:49:52 +0100 Subject: [PATCH 10/37] Changed $source data type to enum --- manifests/plugin/pcie_errors.pp | 2 +- spec/classes/collectd_plugin_pcie_errors_spec.rb | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/manifests/plugin/pcie_errors.pp b/manifests/plugin/pcie_errors.pp index 305535e7e..4f7dc250d 100644 --- a/manifests/plugin/pcie_errors.pp +++ b/manifests/plugin/pcie_errors.pp @@ -8,7 +8,7 @@ # class collectd::plugin::pcie_errors ( Enum['present', 'absent'] $ensure = 'present', - Optional[String] $source = 'sysfs', + Enum['sysfs', 'proc'] $source = 'sysfs', Optional[String] $access_dir = undef, Boolean $report_masked = false, Boolean $persistent_notifications = false, diff --git a/spec/classes/collectd_plugin_pcie_errors_spec.rb b/spec/classes/collectd_plugin_pcie_errors_spec.rb index f1bb00ce0..22982cb81 100644 --- a/spec/classes/collectd_plugin_pcie_errors_spec.rb +++ b/spec/classes/collectd_plugin_pcie_errors_spec.rb @@ -34,9 +34,9 @@ end end - context ':ensure => present and :source => sfsys' do + context ':ensure => present and :source => proc' do let :params do - { source: 'sfsys' } + { source: 'proc' } end it "Will create #{options[:plugin_conf_dir]}/10-pcie_errors.conf" do @@ -44,7 +44,7 @@ is_expected.to contain_file('pcie_errors.load').with( ensure: 'present', path: "#{options[:plugin_conf_dir]}/10-pcie_errors.conf", - content: %r{Source "sfsys"}m + content: %r{Source "proc"}m ) end end From b155ebade8c8cb4539256c3ea25c5aa6399a37d0 Mon Sep 17 00:00:00 2001 From: michalrebisz Date: Tue, 11 Feb 2020 10:25:26 +0100 Subject: [PATCH 11/37] Fixed default config Added aditional tests for default values fixed lint error --- manifests/plugin/mcelog.pp | 5 ++++- spec/classes/collectd_plugin_mcelog_spec.rb | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/manifests/plugin/mcelog.pp b/manifests/plugin/mcelog.pp index 248e0c10e..0bbb6e129 100644 --- a/manifests/plugin/mcelog.pp +++ b/manifests/plugin/mcelog.pp @@ -3,7 +3,10 @@ Enum['present', 'absent'] $ensure = 'present', # Log file option and memory option are mutualy exclusive. Optional[String] $mceloglogfile = undef, - Optional[Collectd::MCELOG::Memory] $memory = undef + Optional[Collectd::MCELOG::Memory] $memory = { + 'mcelogclientsocket' => '/var/run/mcelog-client', + 'persistentnotification' => false, + } ) { include collectd diff --git a/spec/classes/collectd_plugin_mcelog_spec.rb b/spec/classes/collectd_plugin_mcelog_spec.rb index 23e9bbc53..29c292189 100644 --- a/spec/classes/collectd_plugin_mcelog_spec.rb +++ b/spec/classes/collectd_plugin_mcelog_spec.rb @@ -17,6 +17,9 @@ path: "#{options[:plugin_conf_dir]}/10-mcelog.conf" ) end + it { is_expected.to contain_file('mcelog.load').with(content: %r{}) } + it { is_expected.to contain_file('mcelog.load').with(content: %r{McelogClientSocket "/var/run/mcelog-client"}) } + it { is_expected.to contain_file('mcelog.load').with(content: %r{PersistentNotification false}) } end context ':ensure => :mceloglogfile => true' do From 006e7e226910894bec1caa988bde86812f4dd369 Mon Sep 17 00:00:00 2001 From: michalrebisz Date: Mon, 3 Feb 2020 10:11:27 +0100 Subject: [PATCH 12/37] Added snmp agent plugin --- README.md | 33 ++++++ manifests/plugin/snmp_agent.pp | 54 +++++++++ .../collectd_plugin_snmp_agent_spec.rb | 29 +++++ templates/plugin/snmp_agent.conf.epp | 109 ++++++++++++++++++ types/snmp_agent/data.pp | 11 ++ types/snmp_agent/indexkey.pp | 6 + types/snmp_agent/table.pp | 6 + 7 files changed, 248 insertions(+) create mode 100644 manifests/plugin/snmp_agent.pp create mode 100644 spec/classes/collectd_plugin_snmp_agent_spec.rb create mode 100644 templates/plugin/snmp_agent.conf.epp create mode 100644 types/snmp_agent/data.pp create mode 100644 types/snmp_agent/indexkey.pp create mode 100644 types/snmp_agent/table.pp diff --git a/README.md b/README.md index 8ca3a9fa8..d9657a571 100644 --- a/README.md +++ b/README.md @@ -176,6 +176,7 @@ documentation for each plugin for configurable attributes. * `sensors` (see [collectd::plugin::sensors](#class-collectdpluginsensors) below) * `smart` (see [collectd::plugin::smart](#class-collectdpluginsmart) below) * `snmp` (see [collectd::plugin::snmp](#class-collectdpluginsnmp) below) +* `snmp_agent` (see [collectd::plugin::snmp_agent](#class-collectdpluginsnmpagent) below) * `statsd` (see [collectd::plugin::statsd](#class-collectdpluginstatsd) below) * `swap` (see [collectd::plugin::swap](#class-collectdpluginswap) below) * `syslog` (see [collectd::plugin::syslog](#class-collectdpluginsyslog) below) @@ -1702,7 +1703,39 @@ class { 'collectd::plugin::snmp': }, } ``` +#### Class: `collectd::plugin::snmp_agent` +```puppet +class {'collectd::plugin::snmp_agent': + table => { + ifTable => { + 'indexoid' => 'IF-MIB::ifIndex', + 'sizeoid' => 'IF-MIB::ifNumber', + data => [{ + ifDescr => { + 'plugin' => 'interface', + 'oids' => 'IF-MIB::ifDescr' + }, + 'ifDescr2' => { + 'plugin' => 'interface2', + 'oids' => 'IF-MIB::ifDescr2' + } + }] + } + }, + data => { + memAvailReal => { + 'plugin' => 'memory', + 'type' => 'memory', + 'oids' => '1.3.6.1.4.1.2021.4.6.0', + 'typeinstance' => 'free', + 'indexkey' => { + 'source' => 'PluginInstance' + } + } + } +} +``` #### Class: `collectd::plugin::statsd` ```puppet diff --git a/manifests/plugin/snmp_agent.pp b/manifests/plugin/snmp_agent.pp new file mode 100644 index 000000000..d4c41fa71 --- /dev/null +++ b/manifests/plugin/snmp_agent.pp @@ -0,0 +1,54 @@ +# Class: collectd::plugin::snmp_agent +# +# @see https://wiki.opnfv.org/display/fastpath/SNMP+Agent+HLD +# +# Configues snmp agent plugin. +# +# @param ensure String Passed to package and collectd::plugin resources (both). Default: present +# @param data Optional[Hash[String[1],Collectd::SNMP_AGENT::Data]] Defines scalar field, must be put outside Table block. +# @param table Hash[String[1], Collectd::SNMP_AGENT::Table] Defines a table consisting of several Data blocks being its columns +class collectd::plugin::snmp_agent( + Enum['present', 'absent'] $ensure = 'present', + Optional[Hash[String[1],Collectd::SNMP_AGENT::Data]] $data = { + 'memAvailReal' => { + 'oids' => '1.3.6.1.4.1.2021.4.6.0', + 'plugin' => 'memory', + 'type' => 'memory', + 'typeinstance' => 'free', + }, + }, + Hash[String[1], Collectd::SNMP_AGENT::Table] $table = { + 'ifTable' => { + 'indexoid' => 'IF-MIB::ifIndex', + 'sizeoid' => 'IF-MIB::ifNumber', + 'data'=> { + 'ifDescr' => { + 'plugin' => 'interface', + 'oids' => 'IF-MIB::ifDescr', + 'indexkey' => { + 'source' => 'PluginInstance', + }, + }, + 'ifOctets' => { + 'plugin' => 'interface', + 'oids' => 'F-MIB::ifInOctets" "IF-MIB::ifOutOctets', + 'type' => 'if_octets', + 'typeinstance' => '', + }, + }, + }, + } +) { + + include collectd + + collectd::plugin { 'snmp_agent': + ensure => $ensure, + content => epp('collectd/plugin/snmp_agent.conf.epp', { + 'data' => $data, + 'table' => $table + }), + } +} + + diff --git a/spec/classes/collectd_plugin_snmp_agent_spec.rb b/spec/classes/collectd_plugin_snmp_agent_spec.rb new file mode 100644 index 000000000..00c884b8e --- /dev/null +++ b/spec/classes/collectd_plugin_snmp_agent_spec.rb @@ -0,0 +1,29 @@ +require 'spec_helper' + +describe 'collectd::plugin::snmp_agent', type: :class do + on_supported_os(baseline_os_hash).each do |os, facts| + context "on #{os} " do + let :facts do + facts + end + + it { is_expected.to compile.with_all_deps } + options = os_specific_options(facts) + + context ':ensure => present and default parameters' do + it "Will create #{options[:plugin_conf_dir]}/10-snmp_agent.conf to load the plugin" do + is_expected.to contain_file('snmp_agent.load').with( + ensure: 'present', + path: "#{options[:plugin_conf_dir]}/10-snmp_agent.conf" + ) + end + end + + it { is_expected.to contain_file('snmp_agent.load').with_content(%r{OIDs "F-MIB::ifInOctets" "IF-MIB::ifOutOctets"}) } + it { is_expected.to contain_file('snmp_agent.load').with_content(%r{}) } + it { is_expected.to contain_file('snmp_agent.load').with_content(%r{}) } + it { is_expected.to contain_file('snmp_agent.load').with_content(%r{}) } + it { is_expected.to contain_file('snmp_agent.load').with_content(%r{OIDs "1.3.6.1.4.1.2021.4.6.0"}) } + end + end +end diff --git a/templates/plugin/snmp_agent.conf.epp b/templates/plugin/snmp_agent.conf.epp new file mode 100644 index 000000000..baf7bd15f --- /dev/null +++ b/templates/plugin/snmp_agent.conf.epp @@ -0,0 +1,109 @@ + +<%- | Optional $data = undef, + Optional $table = undef, + | -%> + # THIS FILE IS MANAGED BY PUPPET + +<% if $data { -%> +<% $data.keys.sort.each |$key| { -%> +"> +<% $data[$key].each |$keyvalue, $value| { -%> +<% if $keyvalue == 'plugin' { -%> +Plugin "<%= $value %>" +<% } -%> +<% if $keyvalue == 'oids' { -%> +OIDs "<%= $value %>" +<% } -%> +<% if $keyvalue == 'type' { -%> +Type "<%= $value %>" +<% } -%> +<% if $keyvalue == 'typeinstance' { -%> +TypeInstance "<%= $value %>" +<% } -%> +<% if $keyvalue == 'scale' { -%> +Scale "<%= $value %>" +<% } -%> +<% if $keyvalue == 'shift' { -%> +Shift "<%= $value %>" +<% } -%> +<% if $keyvalue == 'plugininstance' { -%> +PluginInstance "<%= $value %>" +<% } -%> +<% if $keyvalue == 'indexkey' { -%> + +<% $value.keys.sort.each |$indexkey| { -%> +<% if $indexkey == 'source' { -%> +Source "<%= $value[$indexkey] %>" +<% } -%> +<% if $indexkey == 'regex' { -%> +Regex "<%= $value[$indexkey] %>" +<% } -%> +<% if $indexkey == 'group' { -%> +Group "<%= $value[$indexkey] %>" +<% } -%> +<% } -%> + +<% } -%> +<% } -%> + +<% } -%> +<% } -%> +<% if $table { -%> +<% $table.keys.sort.each |$key| { -%> +
"> +<% $table[$key].each |$keyvalue, $value| { -%> +<% if $keyvalue == 'indexoid' { -%> +IndexOID "<%= $value %>" +<% } -%> +<% if $keyvalue == 'sizeoid' { -%> +SizeOID "<%= $value %>" +<% } -%> +<% if $keyvalue == 'data' { -%> +<% $value.keys.sort.each |$key| { -%> +"> +<% $value[$key].each |$keyvalue, $value| { -%> +<% if $keyvalue == 'plugin' { -%> +Plugin "<%= $value %>" +<% } -%> +<% if $keyvalue == 'oids' { -%> +OIDs "<%= $value %>" +<% } -%> +<% if $keyvalue == 'type' { -%> +Type "<%= $value %>" +<% } -%> +<% if $keyvalue == 'typeinstance' { -%> +TypeInstance "<%= $value %>" +<% } -%> +<% if $keyvalue == 'scale' { -%> +Scale "<%= $value %>" +<% } -%> +<% if $keyvalue == 'shift' { -%> +Shift "<%= $value %>" +<% } -%> +<% if $keyvalue == 'plugininstance' { -%> +PluginInstance "<%= $value %>" +<% } -%> +<% if $keyvalue == 'indexkey' { -%> + +<% $value.keys.sort.each |$indexkey| { -%> +<% if $indexkey == 'source' { -%> +Source "<%= $value[$indexkey] %>" +<% } -%> +<% if $indexkey == 'regex' { -%> +Regex "<%= $value[$indexkey] %>" +<% } -%> +<% if $indexkey == 'group' { -%> +Group "<%= $value[$indexkey] %>" +<% } -%> +<% } -%> + +<% } -%> +<% } -%> + +<% } -%> +<% } -%> +<% } -%> +
+<% } -%> +<% } -%> + diff --git a/types/snmp_agent/data.pp b/types/snmp_agent/data.pp new file mode 100644 index 000000000..0f8885984 --- /dev/null +++ b/types/snmp_agent/data.pp @@ -0,0 +1,11 @@ +# https://wiki.opnfv.org/display/fastpath/SNMP+Agent+HLD +type Collectd::SNMP_AGENT::Data = Struct[{ + 'plugin' => String, + 'oids' => String, + Optional['type'] => String, + Optional['typeinstance'] => String, + Optional['scale'] => String, + Optional['shift'] => String, + Optional['indexkey'] => Collectd::SNMP_AGENT::IndexKey, + Optional['plugininstance'] => String, +}] diff --git a/types/snmp_agent/indexkey.pp b/types/snmp_agent/indexkey.pp new file mode 100644 index 000000000..111a3d3a3 --- /dev/null +++ b/types/snmp_agent/indexkey.pp @@ -0,0 +1,6 @@ +# https://wiki.opnfv.org/display/fastpath/SNMP+Agent+HLD +type Collectd::SNMP_AGENT::IndexKey = Struct[ + 'source' => String, + Optional['regex'] => String, + Optional['group'] => String, +] diff --git a/types/snmp_agent/table.pp b/types/snmp_agent/table.pp new file mode 100644 index 000000000..76b153494 --- /dev/null +++ b/types/snmp_agent/table.pp @@ -0,0 +1,6 @@ +# https://wiki.opnfv.org/display/fastpath/SNMP+Agent+HLD +type Collectd::SNMP_AGENT::Table = Struct[{ + Optional['indexoid'] => String, + Optional['sizeoid'] => String, + Optional['data'] => Hash[String[1], Collectd::SNMP_AGENT::Data] +}] From 6478341dd99df62fd5e5759d261200044dfb5d38 Mon Sep 17 00:00:00 2001 From: michalrebisz Date: Thu, 20 Feb 2020 08:50:59 +0100 Subject: [PATCH 13/37] Fixed empty line build issue --- templates/plugin/snmp_agent.conf.epp | 1 - 1 file changed, 1 deletion(-) diff --git a/templates/plugin/snmp_agent.conf.epp b/templates/plugin/snmp_agent.conf.epp index baf7bd15f..13b1e48c9 100644 --- a/templates/plugin/snmp_agent.conf.epp +++ b/templates/plugin/snmp_agent.conf.epp @@ -1,4 +1,3 @@ - <%- | Optional $data = undef, Optional $table = undef, | -%> From fa5cc7564907e5c93ef08355759667902fc5851b Mon Sep 17 00:00:00 2001 From: Piotr Rabiega Date: Thu, 20 Feb 2020 12:52:55 +0100 Subject: [PATCH 14/37] Add dcpmm plugin --- README.md | 12 +++ manifests/plugin/dcpmm.pp | 35 ++++++ spec/classes/collectd_plugin_dcpmm_spec.rb | 120 +++++++++++++++++++++ templates/plugin/dcpmm.conf.epp | 14 +++ 4 files changed, 181 insertions(+) create mode 100644 manifests/plugin/dcpmm.pp create mode 100644 spec/classes/collectd_plugin_dcpmm_spec.rb create mode 100644 templates/plugin/dcpmm.conf.epp diff --git a/README.md b/README.md index a4f7f6fbc..583fdd089 100644 --- a/README.md +++ b/README.md @@ -120,6 +120,7 @@ documentation for each plugin for configurable attributes. * `df` (see [collectd::plugin::df](#class-collectdplugindf) below) * `disk` (see [collectd::plugin::disk](#class-collectdplugindisk) below) * `dns` (see [collectd::plugin::dns](#class-collectdplugindns) below) +* `dcpmm` (see [collectd::plugin::dcpmm](#class-collectdplugindcpmm) below) * `entropy` (see [collectd::plugin::entropy](#class-collectdpluginentropy) below) * `exec` (see [collectd::plugin::exec](#class-collectdpluginexec) below) * `ethstat` (see [collectd::plugin::ethstat](#class-collectdpluginethstat) below) @@ -583,6 +584,17 @@ Boolean for SelectNumericQueryTypes configuration option. - *Default*: true +#### Class: `collectd::plugin::dcpmm` + +```puppet +class { 'collectd::plugin::dcpmm': + interval => 10.0, + collect_health => false, + collect_perf_metrics => true, + enable_dispatch_all => false, +} +``` + #### Class: `collectd::plugin::entropy` ```puppet diff --git a/manifests/plugin/dcpmm.pp b/manifests/plugin/dcpmm.pp new file mode 100644 index 000000000..31da1208c --- /dev/null +++ b/manifests/plugin/dcpmm.pp @@ -0,0 +1,35 @@ +# Class to manage dcpmm plugin for collectd. +# +# The dcpmm plugin will collect Intel(R) Optane(TM) DC Persistent Memory related performance statistics. +# Plugin requires root privileges to perform the statistics collection. +# +# @param ensure Ensure param for collectd::plugin type. +# @param interval Sets interval (in seconds) in which the values will be collected. +# @param collect_health Collects health information. collect_health and collect_perf_metrics cannot be true at the same time. +# @param collect_perf_metrics Collects memory performance metrics. collect_health and collect_perf_metrics cannot be true at the same time. +# @param enable_dispatch_all This parameter helps to seamlessly enable simultaneous health and memory perf metrics collection in future. Unused at the moment and must always be false. +# +class collectd::plugin::dcpmm ( + Enum['present', 'absent'] $ensure = 'present', + Float $interval = 10.0, + Boolean $collect_health = false, + Boolean $collect_perf_metrics = true, + Boolean $enable_dispatch_all = false, + +) { + + include collectd + + if $collect_health and $collect_perf_metrics { + fail('collect_health and collect_perf_metrics cannot be true at the same time.') + } + + if $enable_dispatch_all { + fail('enable_dispatch_all is unused at the moment and must always be false.') + } + + collectd::plugin { 'dcpmm': + ensure => $ensure, + content => epp('collectd/plugin/dcpmm.conf.epp'), + } +} diff --git a/spec/classes/collectd_plugin_dcpmm_spec.rb b/spec/classes/collectd_plugin_dcpmm_spec.rb new file mode 100644 index 000000000..9d62793bd --- /dev/null +++ b/spec/classes/collectd_plugin_dcpmm_spec.rb @@ -0,0 +1,120 @@ +require 'spec_helper' + +describe 'collectd::plugin::dcpmm', type: :class do + on_supported_os(baseline_os_hash).each do |os, facts| + context "on #{os} " do + let :facts do + facts + end + + options = os_specific_options(facts) + + context ':ensure => present, default params' do + content = < + Globals false + + + + Interval 10.0 + CollectHealth false + CollectPerfMetrics true + EnableDispatchAll false + + +EOS + + it "Will create #{options[:plugin_conf_dir]}/10-dcpmm.conf" do + is_expected.to compile.with_all_deps + is_expected.to contain_file('dcpmm.load').with( + ensure: 'present', + path: "#{options[:plugin_conf_dir]}/10-dcpmm.conf", + content: content + ) + end + end + + context ':ensure => absent' do + let :params do + { ensure: 'absent' } + end + + it "Will not create #{options[:plugin_conf_dir]}/10-dcpmm.conf" do + is_expected.to compile.with_all_deps + is_expected.to contain_file('dcpmm.load').with( + ensure: 'absent', + path: "#{options[:plugin_conf_dir]}/10-dcpmm.conf" + ) + end + end + + context ':ensure => present and :interval => 3.14' do + let :params do + { interval: 3.14 } + end + + it "Will create #{options[:plugin_conf_dir]}/10-dcpmm.conf" do + is_expected.to compile.with_all_deps + is_expected.to contain_file('dcpmm.load').with( + ensure: 'present', + path: "#{options[:plugin_conf_dir]}/10-dcpmm.conf", + content: %r{Interval 3.14}m + ) + end + end + + context ':ensure => present, :collect_health => true and :collect_perf_metrics => false' do + let :params do + { collect_health: true, + collect_perf_metrics: false } + end + + it "Will create #{options[:plugin_conf_dir]}/10-dcpmm.conf" do + is_expected.to compile.with_all_deps + is_expected.to contain_file('dcpmm.load').with( + ensure: 'present', + path: "#{options[:plugin_conf_dir]}/10-dcpmm.conf", + content: %r{CollectHealth true}m + ) + end + end + + context ':ensure => present and :collect_perf_metrics => false' do + let :params do + { collect_perf_metrics: false } + end + + it "Will create #{options[:plugin_conf_dir]}/10-dcpmm.conf" do + is_expected.to compile.with_all_deps + is_expected.to contain_file('dcpmm.load').with( + ensure: 'present', + path: "#{options[:plugin_conf_dir]}/10-dcpmm.conf", + content: %r{CollectPerfMetrics false}m + ) + end + end + + context ':ensure => present, :collect_health => false and :collect_perf_metrics => true' do + let :params do + { collect_health: true, + collect_perf_metrics: true } + end + + it 'Will raise error' do + is_expected.to compile.and_raise_error(%r{collect_health and collect_perf_metrics cannot be true at the same time.}) + end + end + + context ':ensure => present and :enable_dispatch_all => true' do + let :params do + { enable_dispatch_all: true } + end + + it 'Will raise error' do + is_expected.to compile.and_raise_error(%r{enable_dispatch_all is unused at the moment and must always be false.}) + end + end + end + end +end diff --git a/templates/plugin/dcpmm.conf.epp b/templates/plugin/dcpmm.conf.epp new file mode 100644 index 000000000..af6859329 --- /dev/null +++ b/templates/plugin/dcpmm.conf.epp @@ -0,0 +1,14 @@ + +<% if $collectd::plugin::dcpmm::interval { -%> + Interval <%= $collectd::plugin::dcpmm::interval %> +<% } -%> +<% unless $collectd::plugin::dcpmm::collect_health =~ Undef { -%> + CollectHealth <%= $collectd::plugin::dcpmm::collect_health %> +<% } -%> +<% unless $collectd::plugin::dcpmm::collect_perf_metrics =~ Undef { -%> + CollectPerfMetrics <%= $collectd::plugin::dcpmm::collect_perf_metrics %> +<% } -%> +<% unless $collectd::plugin::dcpmm::enable_dispatch_all =~ Undef { -%> + EnableDispatchAll <%= $collectd::plugin::dcpmm::enable_dispatch_all %> +<% } -%> + From 478af932b835a3f3033cb5e433ef863fe550f169 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Mon, 24 Feb 2020 23:02:32 +0100 Subject: [PATCH 15/37] modulesync 2.12.0 --- .msync.yml | 2 +- Gemfile | 24 +++----------------- Rakefile | 33 +--------------------------- spec/spec_helper.rb | 53 +++++---------------------------------------- 4 files changed, 10 insertions(+), 102 deletions(-) diff --git a/.msync.yml b/.msync.yml index e8e870383..8864fc092 100644 --- a/.msync.yml +++ b/.msync.yml @@ -1 +1 @@ -modulesync_config_version: '2.10.1' +modulesync_config_version: '2.12.0' diff --git a/Gemfile b/Gemfile index 8b4adb5c6..4d187ccc8 100644 --- a/Gemfile +++ b/Gemfile @@ -11,27 +11,9 @@ def location_for(place, fake_version = nil) end group :test do - gem 'puppetlabs_spec_helper', '>= 2.14.0', :require => false - gem 'rspec-puppet-facts', '>= 1.9.5', :require => false - gem 'rspec-puppet-utils', :require => false - gem 'puppet-lint-leading_zero-check', :require => false - gem 'puppet-lint-trailing_comma-check', :require => false - gem 'puppet-lint-version_comparison-check', :require => false - gem 'puppet-lint-classes_and_types_beginning_with_digits-check', :require => false - gem 'puppet-lint-unquoted_string-check', :require => false - gem 'puppet-lint-variable_contains_upcase', :require => false - gem 'puppet-lint-absolute_classname-check', '>= 2.0.0', :require => false - gem 'puppet-lint-topscope-variable-check', :require => false - gem 'puppet-lint-legacy_facts-check', :require => false - gem 'puppet-lint-anchor-check', :require => false - gem 'metadata-json-lint', :require => false - gem 'redcarpet', :require => false - gem 'rubocop', '~> 0.49.1', :require => false - gem 'rubocop-rspec', '~> 1.15.0', :require => false - gem 'mocha', '~> 1.4.0', :require => false - gem 'coveralls', :require => false - gem 'simplecov-console', :require => false - gem 'parallel_tests', :require => false + gem 'voxpupuli-test', :require => false + gem 'coveralls', :require => false + gem 'simplecov-console', :require => false end group :development do diff --git a/Rakefile b/Rakefile index c0f2d37da..b450fe7b0 100644 --- a/Rakefile +++ b/Rakefile @@ -1,4 +1,4 @@ -require 'puppetlabs_spec_helper/rake_tasks' +require 'voxpupuli/test/rake' # load optional tasks for releases # only available if gem group releases is installed @@ -7,37 +7,6 @@ begin rescue LoadError end -PuppetLint.configuration.log_format = '%{path}:%{line}:%{check}:%{KIND}:%{message}' - -desc 'Auto-correct puppet-lint offenses' -task 'lint:auto_correct' do - Rake::Task[:lint_fix].invoke -end - -desc 'Run acceptance tests' -RSpec::Core::RakeTask.new(:acceptance) do |t| - t.pattern = 'spec/acceptance' -end - -desc 'Run tests' -task test: [:release_checks] - -namespace :check do - desc 'Check for trailing whitespace' - task :trailing_whitespace do - Dir.glob('**/*.md', File::FNM_DOTMATCH).sort.each do |filename| - next if filename =~ %r{^((modules|acceptance|\.?vendor|spec/fixtures|pkg)/|REFERENCE.md)} - File.foreach(filename).each_with_index do |line, index| - if line =~ %r{\s\n$} - puts "#{filename} has trailing whitespace on line #{index + 1}" - exit 1 - end - end - end - end -end -Rake::Task[:release_checks].enhance ['check:trailing_whitespace'] - desc "Run main 'test' task and report merged results to coveralls" task test_with_coveralls: [:test] do if Dir.exist?(File.expand_path('../lib', __FILE__)) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 4edd47e5f..62360e7d4 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,19 +1,16 @@ # This file is managed via modulesync # https://github.com/voxpupuli/modulesync # https://github.com/voxpupuli/modulesync_config + RSpec.configure do |c| c.mock_with :mocha end -require 'puppetlabs_spec_helper/module_spec_helper' -require 'rspec-puppet-facts' -require 'bundler' -include RspecPuppetFacts +# puppetlabs_spec_helper will set up coverage if the env variable is set. +# We want to do this if lib exists and it hasn't been explicitly set. +ENV['COVERAGE'] ||= 'yes' if Dir.exist?(File.expand_path('../../lib', __FILE__)) -if ENV['DEBUG'] - Puppet::Util::Log.level = :debug - Puppet::Util::Log.newdestination(:console) -end +require 'voxpupuli/test/spec_helper' if File.exist?(File.join(__dir__, 'default_module_facts.yml')) facts = YAML.load(File.read(File.join(__dir__, 'default_module_facts.yml'))) @@ -24,44 +21,4 @@ end end -if Dir.exist?(File.expand_path('../../lib', __FILE__)) - require 'coveralls' - require 'simplecov' - require 'simplecov-console' - SimpleCov.formatters = [ - SimpleCov::Formatter::HTMLFormatter, - SimpleCov::Formatter::Console - ] - SimpleCov.start do - track_files 'lib/**/*.rb' - add_filter '/spec' - add_filter '/vendor' - add_filter '/.vendor' - add_filter Bundler.configured_bundle_path.path - end -end - -RSpec.configure do |c| - # getting the correct facter version is tricky. We use facterdb as a source to mock facts - # see https://github.com/camptocamp/facterdb - # people might provide a specific facter version. In that case we use it. - # Otherwise we need to match the correct facter version to the used puppet version. - # as of 2019-10-31, puppet 5 ships facter 3.11 and puppet 6 ships facter 3.14 - # https://puppet.com/docs/puppet/5.5/about_agent.html - # - # The environment variable `PUPPET_VERSION` is available in our travis environment, but we cannot rely on it - # if somebody runs the tests locally. For that case we should fallback the the puppet gem version. - c.default_facter_version = if ENV['FACTERDB_FACTS_VERSION'] - ENV['FACTERDB_FACTS_VERSION'] - else - puppet_version = ENV['PUPPET_VERSION'] ? ENV['PUPPET_VERSION'] : Gem.loaded_specs['puppet'].version.to_s - Gem::Dependency.new('', puppet_version).match?('', '5') ? '3.11.0' : '3.14.0' - end - - # Coverage generation - c.after(:suite) do - RSpec::Puppet::Coverage.report! - end -end - require 'spec_helper_methods' From 9f613241ca7bee2fafa19771a3deb588a63a6cd5 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Mon, 24 Feb 2020 23:17:08 +0100 Subject: [PATCH 16/37] release 11.2.0 --- CHANGELOG.md | 14 ++++++++++++++ metadata.json | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 59beca208..fde6e3067 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,20 @@ All notable changes to this project will be documented in this file. Each new release typically also includes the latest modulesync defaults. These should not affect the functionality of the module. +## [v11.2.0](https://github.com/voxpupuli/puppet-collectd/tree/v11.2.0) (2020-02-24) + +[Full Changelog](https://github.com/voxpupuli/puppet-collectd/compare/v11.1.0...v11.2.0) + +**Implemented enhancements:** + +- Add dcpmm plugin [\#914](https://github.com/voxpupuli/puppet-collectd/pull/914) ([prabiegx](https://github.com/prabiegx)) +- Add pcie\_errors plugin [\#911](https://github.com/voxpupuli/puppet-collectd/pull/911) ([prabiegx](https://github.com/prabiegx)) +- Add SNMP agent plugin [\#910](https://github.com/voxpupuli/puppet-collectd/pull/910) ([MichalRebisz](https://github.com/MichalRebisz)) + +**Merged pull requests:** + +- Plugin Mcelog default config [\#909](https://github.com/voxpupuli/puppet-collectd/pull/909) ([MichalRebisz](https://github.com/MichalRebisz)) + ## [v11.1.0](https://github.com/voxpupuli/puppet-collectd/tree/v11.1.0) (2020-02-08) [Full Changelog](https://github.com/voxpupuli/puppet-collectd/compare/v11.0.0...v11.1.0) diff --git a/metadata.json b/metadata.json index 1ee50b568..3f729f103 100644 --- a/metadata.json +++ b/metadata.json @@ -58,7 +58,7 @@ } ], "name": "puppet-collectd", - "version": "11.1.1-rc0", + "version": "11.2.0", "source": "https://github.com/voxpupuli/puppet-collectd", "author": "Vox Pupuli", "license": "Apache-2.0", From 51ea4a1e22e23c83f16b578cdd2030185ee1e5c6 Mon Sep 17 00:00:00 2001 From: Piotr Rabiega Date: Fri, 7 Feb 2020 13:51:16 +0100 Subject: [PATCH 17/37] Add dpdk_telemetry plugin --- README.md | 10 +++ manifests/plugin/dpdk_telemetry.pp | 28 +++++++ .../collectd_plugin_dpdk_telemetry_spec.rb | 81 +++++++++++++++++++ templates/plugin/dpdk_telemetry.conf.epp | 8 ++ 4 files changed, 127 insertions(+) create mode 100644 manifests/plugin/dpdk_telemetry.pp create mode 100644 spec/classes/collectd_plugin_dpdk_telemetry_spec.rb create mode 100644 templates/plugin/dpdk_telemetry.conf.epp diff --git a/README.md b/README.md index 6b5889db3..4cade6381 100644 --- a/README.md +++ b/README.md @@ -121,6 +121,7 @@ documentation for each plugin for configurable attributes. * `disk` (see [collectd::plugin::disk](#class-collectdplugindisk) below) * `dns` (see [collectd::plugin::dns](#class-collectdplugindns) below) * `dcpmm` (see [collectd::plugin::dcpmm](#class-collectdplugindcpmm) below) +* `dpdk_telemetry` (see [collectd::plugin::dpdk_telemetry](#class-collectdplugindpdk_telemetry) below) * `entropy` (see [collectd::plugin::entropy](#class-collectdpluginentropy) below) * `exec` (see [collectd::plugin::exec](#class-collectdpluginexec) below) * `ethstat` (see [collectd::plugin::ethstat](#class-collectdpluginethstat) below) @@ -585,6 +586,15 @@ Boolean for SelectNumericQueryTypes configuration option. - *Default*: true +#### Class: `collectd::plugin::dpdk_telemetry` + +```puppet +class { 'collectd::plugin::dpdk_telemetry': + client_socket_path => '/var/run/.client', + dpdk_socket_path => '/var/run/dpdk/rte/telemetry', +} +``` + #### Class: `collectd::plugin::dcpmm` ```puppet diff --git a/manifests/plugin/dpdk_telemetry.pp b/manifests/plugin/dpdk_telemetry.pp new file mode 100644 index 000000000..9232b3279 --- /dev/null +++ b/manifests/plugin/dpdk_telemetry.pp @@ -0,0 +1,28 @@ +# Class to manage dpdk_telemetry plugin for collectd. +# +# The dpdk_telemetry plugin collects DPDK ethernet device metrics via +# dpdk_telemetry library. +# +# Plugin retrieves metrics from a DPDK packet forwarding application +# by sending the JSON formatted message via a UNIX domain socket. +# DPDK telemetry component will respond with a JSON formatted reply +# delivering the requested metrics. Plugin parses the JSON data +# and publishes the metric values to collectd for further use. +# +# @param ensure Ensure param for collectd::plugin type. +# @param client_socket_path UNIX domain client socket to receive messages from DPDK telemetry library. +# @param dpdk_socket_path UNIX domain DPDK telemetry socket to be connected to send messages. +# +class collectd::plugin::dpdk_telemetry ( + Enum['present', 'absent'] $ensure = 'present', + Stdlib::Absolutepath $client_socket_path = '/var/run/.client', + Stdlib::Absolutepath $dpdk_socket_path = '/var/run/dpdk/rte/telemetry', +) { + + include collectd + + collectd::plugin { 'dpdk_telemetry': + ensure => $ensure, + content => epp('collectd/plugin/dpdk_telemetry.conf.epp'), + } +} diff --git a/spec/classes/collectd_plugin_dpdk_telemetry_spec.rb b/spec/classes/collectd_plugin_dpdk_telemetry_spec.rb new file mode 100644 index 000000000..98ad85ffb --- /dev/null +++ b/spec/classes/collectd_plugin_dpdk_telemetry_spec.rb @@ -0,0 +1,81 @@ +require 'spec_helper' + +describe 'collectd::plugin::dpdk_telemetry', type: :class do + on_supported_os(baseline_os_hash).each do |os, facts| + context "on #{os} " do + let :facts do + facts + end + + options = os_specific_options(facts) + + context ':ensure => present, default params' do + content = < + Globals false + + + + ClientSocketPath "/var/run/.client" + DpdkSocketPath "/var/run/dpdk/rte/telemetry" + + +EOS + + it "Will create #{options[:plugin_conf_dir]}/10-dpdk_telemetry.conf" do + is_expected.to compile.with_all_deps + is_expected.to contain_file('dpdk_telemetry.load').with( + ensure: 'present', + path: "#{options[:plugin_conf_dir]}/10-dpdk_telemetry.conf", + content: content + ) + end + end + + context ':ensure => absent' do + let :params do + { ensure: 'absent' } + end + + it "Will not create #{options[:plugin_conf_dir]}/10-dpdk_telemetry.conf" do + is_expected.to compile.with_all_deps + is_expected.to contain_file('dpdk_telemetry.load').with( + ensure: 'absent', + path: "#{options[:plugin_conf_dir]}/10-dpdk_telemetry.conf" + ) + end + end + + context ':ensure => present and :client_socket_path => /test/path/.client' do + let :params do + { client_socket_path: '/test/path/.client' } + end + + it "Will create #{options[:plugin_conf_dir]}/10-dpdk_telemetry.conf" do + is_expected.to compile.with_all_deps + is_expected.to contain_file('dpdk_telemetry.load').with( + ensure: 'present', + path: "#{options[:plugin_conf_dir]}/10-dpdk_telemetry.conf", + content: %r{ClientSocketPath "/test/path/.client"}m + ) + end + end + + context ':ensure => present and :dpdk_socket_path => /test/path/telemetry' do + let :params do + { dpdk_socket_path: '/test/path/telemetry' } + end + + it "Will create #{options[:plugin_conf_dir]}/10-dpdk_telemetry.conf" do + is_expected.to compile.with_all_deps + is_expected.to contain_file('dpdk_telemetry.load').with( + ensure: 'present', + path: "#{options[:plugin_conf_dir]}/10-dpdk_telemetry.conf", + content: %r{DpdkSocketPath "/test/path/telemetry"}m + ) + end + end + end + end +end diff --git a/templates/plugin/dpdk_telemetry.conf.epp b/templates/plugin/dpdk_telemetry.conf.epp new file mode 100644 index 000000000..7d9c52875 --- /dev/null +++ b/templates/plugin/dpdk_telemetry.conf.epp @@ -0,0 +1,8 @@ + +<% if $collectd::plugin::dpdk_telemetry::client_socket_path { -%> + ClientSocketPath "<%= $collectd::plugin::dpdk_telemetry::client_socket_path %>" +<% } -%> +<% if $collectd::plugin::dpdk_telemetry::dpdk_socket_path { -%> + DpdkSocketPath "<%= $collectd::plugin::dpdk_telemetry::dpdk_socket_path %>" +<% } -%> + From 35b7811b41e6e19f1fe64b2da6073e4510127189 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Tue, 25 Feb 2020 09:46:41 +0100 Subject: [PATCH 18/37] [blacksmith] Bump version to 11.2.1-rc0 --- metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.json b/metadata.json index 3f729f103..891d4a991 100644 --- a/metadata.json +++ b/metadata.json @@ -58,7 +58,7 @@ } ], "name": "puppet-collectd", - "version": "11.2.0", + "version": "11.2.1-rc0", "source": "https://github.com/voxpupuli/puppet-collectd", "author": "Vox Pupuli", "license": "Apache-2.0", From 3f479c1695c86a144674fb1d153feff736c9dea4 Mon Sep 17 00:00:00 2001 From: MichalRebisz Date: Fri, 6 Mar 2020 00:23:32 +0100 Subject: [PATCH 19/37] Added test for checking file is correct --- .../collectd_plugin_log_parser_spec.rb | 36 ++--------- spec/fixtures/plugins/logparser.conf.default | 64 +++++++++++++++++++ templates/plugin/log_parser.conf.epp | 38 +++++------ 3 files changed, 87 insertions(+), 51 deletions(-) create mode 100644 spec/fixtures/plugins/logparser.conf.default diff --git a/spec/classes/collectd_plugin_log_parser_spec.rb b/spec/classes/collectd_plugin_log_parser_spec.rb index db734f2c5..96a0a85b3 100644 --- a/spec/classes/collectd_plugin_log_parser_spec.rb +++ b/spec/classes/collectd_plugin_log_parser_spec.rb @@ -19,41 +19,13 @@ end end - context ':ensure => log parser created with logfile' do - let :params do - { - logfile: [ - 'file01.log' => { - 'message' => [ - 'msg_1' => { - 'defaultplugininstance' => 'plugin_instance', - 'defaulttype' => 'type', - 'defaulttypeinstance' => 'type_instance', - 'defaultseverity' => 'ok', - 'match' => [ - 'sample_error' => { - 'regex' => 'regex', - 'submatchidx' => 0, - 'excluderegex' => 'exclude', - 'ismandatory' => false, - 'severity' => 'severity', - 'plugininstance' => 'plugin_instance', - 'type' => 'type', - 'typeinstance' => 'type_instance' - } - ] - } - ], - 'firstfullread' => false - } - ] - } - end - + context ':ensure => log parser created with default values' do + default_fixture = File.read(fixtures('plugins/logparser.conf.default')) it "Will create #{options[:plugin_conf_dir]}/06-log_parser.conf" do is_expected.to contain_file('log_parser.load').with( ensure: 'present', - path: "#{options[:plugin_conf_dir]}/06-log_parser.conf" + path: "#{options[:plugin_conf_dir]}/06-log_parser.conf", + content: default_fixture ) end end diff --git a/spec/fixtures/plugins/logparser.conf.default b/spec/fixtures/plugins/logparser.conf.default new file mode 100644 index 000000000..5e89d5a66 --- /dev/null +++ b/spec/fixtures/plugins/logparser.conf.default @@ -0,0 +1,64 @@ +# Generated by Puppet + + Globals false + + + + + FirstFullRead "false" + + DefaultType "warning" + DefaultTypeInstance "pcie_error" + + Regex "AER:.*error received" + SubmatchIdx "-1" + + + IsMandatory "false" + Regex "severity=Corrected" + TypeInstance "correctable" + + + IsMandatory "false" + PluginInstance "true" + Regex " ([0-9a-fA-F:\.]*): PCIe Bus Error" + SubmatchIdx "1" + + + IsMandatory "false" + Regex "type=(.*)," + SubmatchIdx "1" + + + IsMandatory "false" + Regex "severity=.*\([fF]atal" + Severity "failure" + TypeInstance "fatal" + + + Regex ", id=(.*)" + SubmatchIdx "1" + + + IsMandatory "false" + Regex "(... .. ..:..:..) .* pcieport.*AER" + SubmatchIdx "1" + + + IsMandatory "false" + Regex "severity=.*\([nN]on-[fF]atal" + TypeInstance "non_fatal" + + + IsMandatory "true" + Regex "pcieport (.*): AER:" + SubmatchIdx "1" + + + Regex "severity=" + SubmatchIdx "1" + + + + + diff --git a/templates/plugin/log_parser.conf.epp b/templates/plugin/log_parser.conf.epp index 7989bbaf2..bf7c04a85 100644 --- a/templates/plugin/log_parser.conf.epp +++ b/templates/plugin/log_parser.conf.epp @@ -2,69 +2,69 @@ <% $logfile.each |$file| { -%> <% $file.keys.sort.each |$key| { -%> -"> + "> <% $file[$key].keys.sort.each |$value| { -%> <% if $value == 'firstfullread' { -%> -FirstFullRead "<%= $file[$key][$value] %>" + FirstFullRead "<%= $file[$key][$value] %>" <% } -%> <% if $value == 'message' { -%> <% $file[$key][$value].each |$message| { -%> <% $message.keys.sort.each |$messagekey| { -%> -"> + "> <% $message[$messagekey].keys.sort.each |$messagevalue| { -%> <% if $messagevalue == 'defaultplugininstance' { -%> -DefaultPluginInstance "<%= $message[$messagekey][$messagevalue] %>" + DefaultPluginInstance "<%= $message[$messagekey][$messagevalue] %>" <% } -%> <% if $messagevalue == 'defaultseverity' { -%> -DefaultType "<%= $message[$messagekey][$messagevalue] %>" + DefaultType "<%= $message[$messagekey][$messagevalue] %>" <% } -%> <% if $messagevalue == 'defaulttype' { -%> -DefaultTypeInstance "<%= $message[$messagekey][$messagevalue] %>" + DefaultTypeInstance "<%= $message[$messagekey][$messagevalue] %>" <% } -%> <% if $messagevalue == 'defaulttypeinstance' { -%> -DefaultSeverity "<%= $message[$messagekey][$messagevalue] %>" + DefaultSeverity "<%= $message[$messagekey][$messagevalue] %>" <% } -%> <% if $messagevalue == 'match' { -%> <% $message[$messagekey][$messagevalue].each |$match| { -%> <% $match.keys.sort.each |$matchkey| { -%> -"> + "> <% $match[$matchkey].keys.sort.each |$matchvalue| { -%> <% if $matchvalue == 'regex' { -%> -Regex "<%= $match[$matchkey][$matchvalue] %>" + Regex "<%= $match[$matchkey][$matchvalue] %>" <% } -%> <% if $matchvalue == 'submatchidx' { -%> -SubmatchIdx "<%= $match[$matchkey][$matchvalue] %>" + SubmatchIdx "<%= $match[$matchkey][$matchvalue] %>" <% } -%> <% if $matchvalue == 'excluderegex' { -%> -ExcludeRegex "<%= $match[$matchkey][$matchvalue] %>" + ExcludeRegex "<%= $match[$matchkey][$matchvalue] %>" <% } -%> <% if $matchvalue == 'ismandatory' { -%> -IsMandatory "<%= $match[$matchkey][$matchvalue] %>" + IsMandatory "<%= $match[$matchkey][$matchvalue] %>" <% } -%> <% if $matchvalue == 'severity' { -%> -Severity "<%= $match[$matchkey][$matchvalue] %>" + Severity "<%= $match[$matchkey][$matchvalue] %>" <% } -%> <% if $matchvalue == 'plugininstance' { -%> -PluginInstance "<%= $match[$matchkey][$matchvalue] %>" + PluginInstance "<%= $match[$matchkey][$matchvalue] %>" <% } -%> <% if $matchvalue == 'type' { -%> -Type "<%= $match[$matchkey][$matchvalue] %>" + Type "<%= $match[$matchkey][$matchvalue] %>" <% } -%> <% if $matchvalue == 'typeinstance' { -%> -TypeInstance "<%= $match[$matchkey][$matchvalue] %>" + TypeInstance "<%= $match[$matchkey][$matchvalue] %>" <% } -%> <% } -%> - + <% } -%> <% } -%> <% } -%> <% } -%> - + <% } -%> <% } -%> <% } -%> <% } -%> - + <% } -%> <% } -%> From 63f9ea2d5651959b8677742f7cefd879332cdfb2 Mon Sep 17 00:00:00 2001 From: Steve Traylen Date: Mon, 9 Mar 2020 13:38:26 +0100 Subject: [PATCH 20/37] Require puppet-epel over stahnma-epel stahnma-epel has now migrated to VoxPupuli name space. Also in particular the `puppet-epel` version is requirment to work with CentOS 8. --- .fixtures.yml | 2 +- metadata.json | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.fixtures.yml b/.fixtures.yml index 825553221..641e0a835 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -3,7 +3,7 @@ fixtures: apt: https://github.com/puppetlabs/puppetlabs-apt.git stdlib: https://github.com/puppetlabs/puppetlabs-stdlib.git concat: https://github.com/puppetlabs/puppetlabs-concat.git - epel: https://github.com/stahnma/puppet-module-epel.git + epel: https://github.com/voxpupuli/puppet-epel.git yumrepo_core: repo: https://github.com/puppetlabs/puppetlabs-yumrepo_core.git puppet_version: ">= 6.0.0" diff --git a/metadata.json b/metadata.json index 891d4a991..b9d33f843 100644 --- a/metadata.json +++ b/metadata.json @@ -84,8 +84,8 @@ "version_requirement": ">= 4.25.0 < 7.0.0" }, { - "name": "stahnma-epel", - "version_requirement": ">= 1.2.2 < 2.0.0" + "name": "puppet-epel", + "version_requirement": ">= 3.0.0 < 4.0.0" }, { "name": "puppetlabs-python_task_helper", From 672452018abefde44f18de9cb75a3102e0745f61 Mon Sep 17 00:00:00 2001 From: Steve Traylen Date: Fri, 6 Mar 2020 09:31:23 +0100 Subject: [PATCH 21/37] Add CentOS 8 support The main differences for CentOS 8 are: * There is now a new collectd-utils package containing collectdctl * collectd-python is now a seperate sub package * python is python3. * pip command is now pip3 * The rabbitmq plugin no longer works due to lack of python3 support The python_dir fact will fall back to `/usr/libexec/platform-python` if `python3` does not exist on the path. This is the python that collectd is built against and significantly requires. Note that setting `collectd::ci_package_repo` true will currently result in yum being configured with a non existant repo since https://pkg.ci.collectd.org/rpm/ does not exist for 8. https://github.com/collectd/collectd-ci/issues/35 --- .sync.yml | 1 + .travis.yml | 8 ++ README.md | 2 + lib/facter/python_dir.rb | 2 + manifests/params.pp | 5 +- manifests/plugin/cuda.pp | 31 ++++- manifests/plugin/iscdhcp.pp | 32 ++++- manifests/plugin/python.pp | 8 +- manifests/plugin/rabbitmq.pp | 4 + metadata.json | 9 +- spec/acceptance/class_plugin_python_spec.rb | 87 ++++++++---- spec/acceptance/class_spec.rb | 10 +- spec/acceptance/curl_json_spec.rb | 3 + spec/classes/collectd_plugin_rabbitmq_spec.rb | 125 +++++++++++------- spec/spec_helper_acceptance.rb | 5 - spec/spec_helper_methods.rb | 6 +- 16 files changed, 235 insertions(+), 103 deletions(-) diff --git a/.sync.yml b/.sync.yml index 12215f5ca..ff751c806 100644 --- a/.sync.yml +++ b/.sync.yml @@ -4,6 +4,7 @@ - set: ubuntu1604-64 - set: ubuntu1804-64 - set: centos7-64 + - set: centos8-64 - set: debian8-64 secure: "FAK3Izs5bSZyblGvcFnGWm0exZV5+v9pbwfRDD2oihWxX3U3pArGW+3XcwcJfLQgrUYBsOTmHC8yPjlgTBYeIt/5pvg9X+3jwNgeto6kozpI/nvAq4NtcHhzxRejuPELhFYeXZ3hEw0w+v/ZRo2cNLwI0LLpiWEDvCMZN1CJ2RY=" spec/spec_helper.rb: diff --git a/.travis.yml b/.travis.yml index 391701cc4..a1c8dec16 100644 --- a/.travis.yml +++ b/.travis.yml @@ -46,6 +46,14 @@ matrix: bundler_args: --without development release env: PUPPET_INSTALL_TYPE=agent BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_debug=true BEAKER_setfile=centos7-64 BEAKER_HYPERVISOR=docker CHECK=beaker services: docker + - rvm: 2.5.3 + bundler_args: --without development release + env: PUPPET_INSTALL_TYPE=agent BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_debug=true BEAKER_setfile=centos8-64 BEAKER_HYPERVISOR=docker CHECK=beaker + services: docker + - rvm: 2.5.3 + bundler_args: --without development release + env: PUPPET_INSTALL_TYPE=agent BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_debug=true BEAKER_setfile=centos8-64 BEAKER_HYPERVISOR=docker CHECK=beaker + services: docker - rvm: 2.5.3 bundler_args: --without development release env: PUPPET_INSTALL_TYPE=agent BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_debug=true BEAKER_setfile=debian8-64 BEAKER_HYPERVISOR=docker CHECK=beaker diff --git a/README.md b/README.md index 4cade6381..c78dcafb2 100644 --- a/README.md +++ b/README.md @@ -1622,6 +1622,8 @@ You will need to add this to [collectd::config::typesdb](https://github.com/voxp via hiera or in a manifest. Failure to set the types.db.custom content will result in *no* metrics from the rabbitmq plugin. +The rabbitmq plugin has not been ported to python3 and will fail on CentOS 8 [#75](https://github.com/nytimes/collectd-rabbitmq/issues/75) + set typesdb to include the collectd-rabbitmq types.db.custom ```yaml diff --git a/lib/facter/python_dir.rb b/lib/facter/python_dir.rb index c6beaf66b..1101513ac 100644 --- a/lib/facter/python_dir.rb +++ b/lib/facter/python_dir.rb @@ -16,6 +16,8 @@ else Facter::Util::Resolution.exec('python3 -c "import site; print(site.getsitepackages()[0])"') end + elsif File.exist?('/usr/libexec/platform-python') + Facter::Util::Resolution.exec('/usr/libexec/platform-python -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())"') else '' end diff --git a/manifests/params.pp b/manifests/params.pp index a97a83d38..8e3fc53a1 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -71,7 +71,10 @@ $config_file = '/etc/collectd.conf' $config_group = 'root' $java_dir = '/usr/share/collectd/java' - $default_python_dir = '/usr/lib/python2.7/site-packages' + $default_python_dir = $facts['os']['release']['major'] ? { + '7' => '/usr/lib/python2.7/site-packages', + default => '/usr/lib/python3.6/site-packages', + } $manage_repo = true $package_configs = { ovs_events => 'ovs-events.conf', diff --git a/manifests/plugin/cuda.pp b/manifests/plugin/cuda.pp index 6d7ad9a9e..6ffc0e5ee 100644 --- a/manifests/plugin/cuda.pp +++ b/manifests/plugin/cuda.pp @@ -12,28 +12,45 @@ # @param provider_proxy Optional[String] Proxy for provider. Default: undef class collectd::plugin::cuda ( Optional[String] $ensure = 'present', - Optional[Boolean] $manage_package = undef, + Optional[Boolean] $manage_package = undef, Optional[String] $package_name = 'collectd-cuda', - Optional[String] $package_provider = 'pip', + Optional[String] $package_provider = undef, Optional[String] $provider_proxy = undef, ) { include collectd $_manage_package = pick($manage_package, $collectd::manage_package) + if $facts['os']['family'] == 'RedHat' and $facts['os']['release']['major'] == '8' { + $_python_pip_package = 'python3-pip' + if $package_provider =~ Undef { + $_package_provider = 'pip3' + } + else { + $_package_provider = $package_provider + } + } else { + $_python_pip_package = 'python-pip' + if $package_provider =~ Undef { + $_package_provider = 'pip' + } + else { + $_package_provider = $package_provider + } + } if ($_manage_package) { - if (!defined(Package['python-pip'])) { - package { 'python-pip': ensure => 'present', } + if (!defined(Package[$_python_pip_package])) { + package { $_python_pip_package: ensure => 'present', } Package[$package_name] { - require => Package['python-pip'], + require => Package[$_python_pip_package], } if $facts['os']['family'] == 'RedHat' { # Epel is installed in install.pp if manage_repo is true # python-pip doesn't exist in base for RedHat. Need epel installed first if (defined(Class['::epel'])) { - Package['python-pip'] { + Package[$_python_pip_package] { require => Class['::epel'], } } @@ -49,7 +66,7 @@ package { $package_name: ensure => $ensure, - provider => $package_provider, + provider => $_package_provider, install_options => $install_options, } diff --git a/manifests/plugin/iscdhcp.pp b/manifests/plugin/iscdhcp.pp index 78eafbbb1..626842dde 100644 --- a/manifests/plugin/iscdhcp.pp +++ b/manifests/plugin/iscdhcp.pp @@ -11,28 +11,46 @@ # @param provider_proxy Optional[String] Proxy for provider. Default: undef class collectd::plugin::iscdhcp ( Optional[String] $ensure = 'present', - Optional[Boolean] $manage_package = undef, + Optional[Boolean] $manage_package = undef, Optional[String] $package_name = 'collectd-iscdhcp', - Optional[String] $package_provider = 'pip', + Optional[String] $package_provider = undef, Optional[String] $provider_proxy = undef, ) { include collectd $_manage_package = pick($manage_package, $collectd::manage_package) + if $facts['os']['family'] == 'RedHat' and $facts['os']['release']['major'] == '8' { + $_python_pip_package = 'python3-pip' + if $package_provider =~ Undef { + $_package_provider = 'pip3' + } + else { + $_package_provider = $package_provider + } + } else { + $_python_pip_package = 'python-pip' + if $package_provider =~ Undef { + $_package_provider = 'pip' + } + else { + $_package_provider = $package_provider + } + } + if ($_manage_package) { - if (!defined(Package['python-pip'])) { - package { 'python-pip': ensure => 'present', } + if (!defined(Package[$_python_pip_package])) { + package { $_python_pip_package: ensure => 'present', } Package[$package_name] { - require => Package['python-pip'], + require => Package[$_python_pip_package], } if $facts['os']['family'] == 'RedHat' { # Epel is installed in install.pp if manage_repo is true # python-pip doesn't exist in base for RedHat. Need epel installed first if (defined(Class['::epel'])) { - Package['python-pip'] { + Package[$_python_pip_package] { require => Class['::epel'], } } @@ -48,7 +66,7 @@ package { $package_name: ensure => $ensure, - provider => $package_provider, + provider => $_package_provider, install_options => $install_options, } diff --git a/manifests/plugin/python.pp b/manifests/plugin/python.pp index 4487dd590..9019b02ec 100644 --- a/manifests/plugin/python.pp +++ b/manifests/plugin/python.pp @@ -32,11 +32,17 @@ $ensure_real = 'absent' } - if $facts['os']['name'] == 'Fedora' or $facts['os']['name'] == 'Amazon' { + if $facts['os']['name'] == 'Amazon' or + ($facts['os']['family'] == 'RedHat' and versioncmp($facts['os']['release']['major'],'8') >= 0) { if $_manage_package { package { 'collectd-python': ensure => $ensure_real, } + if (defined(Class['::epel'])) { + Package['collectd-python'] { + require => Class['::epel'], + } + } } } diff --git a/manifests/plugin/rabbitmq.pp b/manifests/plugin/rabbitmq.pp index 368176cfc..7e4252872 100644 --- a/manifests/plugin/rabbitmq.pp +++ b/manifests/plugin/rabbitmq.pp @@ -61,6 +61,10 @@ ) { include collectd + if $facts['os']['family'] == 'RedHat' and versioncmp($facts['os']['release']['major'],'8') >= 0 { + fail('https://pypi.org/project/collectd-rabbitmq/ does not support Python 3') + } + case $facts['os']['family'] { 'RedHat': { $_custom_types_db = '/usr/share/collectd-rabbitmq/types.db.custom' diff --git a/metadata.json b/metadata.json index b9d33f843..02ea1518f 100644 --- a/metadata.json +++ b/metadata.json @@ -3,19 +3,22 @@ { "operatingsystem": "RedHat", "operatingsystemrelease": [ - "7" + "7", + "8" ] }, { "operatingsystem": "CentOS", "operatingsystemrelease": [ - "7" + "7", + "8" ] }, { "operatingsystem": "OracleLinux", "operatingsystemrelease": [ - "7" + "7", + "8" ] }, { diff --git a/spec/acceptance/class_plugin_python_spec.rb b/spec/acceptance/class_plugin_python_spec.rb index 5d486440b..e2b2afb34 100644 --- a/spec/acceptance/class_plugin_python_spec.rb +++ b/spec/acceptance/class_plugin_python_spec.rb @@ -7,6 +7,8 @@ pp = <<-EOS class{'collectd::plugin::python': } + # Enable one write plugin to make logs quieter + class { 'collectd::plugin::csv':} EOS # Run 3 times since the collectd_version # fact is impossible until collectd is @@ -22,39 +24,48 @@ end end - context 'trivial module' do + context 'trivial pip module connect-time' do it 'works idempotently with no errors' do pp = <<-EOS - if $facts['os']['family'] == 'Debian' { + if $facts['os']['family'] == 'Debian' or ( $facts['os']['family'] == 'RedHat' and $facts['os']['release']['major'] == '8' ) { # for collectdctl command package{'collectd-utils': - ensure => present, + ensure => present, } } - package{'python-pip': + if $facts['os']['family'] == 'RedHat' and $facts['os']['release']['major'] == '8' { + $_python_pip_package = 'python3-pip' + $_pip_provider = 'pip3' + } else { + $_python_pip_package = 'python-pip' + $_pip_provider = 'pip' + } + package{$_python_pip_package: ensure => present, } package{['collectd-connect-time']: - ensure => 'present', - provider => 'pip', - require => Package['python-pip'], - before => Service['collectd'], + ensure => 'present', + provider => $_pip_provider, + require => Package[$_python_pip_package], + before => Service['collectd'], } class{'collectd::plugin::python': - logtraces => true, - interactive => false, + logtraces => true, + interactive => false, modules => { 'collectd_connect_time' => { - config => [{'target' => 'google.de'}], - }, - }, + config => [{'target' => 'google.de'}], + }, + }, } class{'collectd::plugin::unixsock': - socketfile => '/var/run/collectd-sock', + socketfile => '/var/run/collectd-sock', + socketgroup => 'root', } EOS - # Run it twice and test for idempotency + # Run it twice or thrice and test for idempotency + apply_manifest(pp, catch_failures: true) apply_manifest(pp, catch_failures: true) apply_manifest(pp, catch_changes: true) shell('sleep 10') @@ -75,39 +86,57 @@ if $facts['os']['family'] == 'Debian' { # for collectdctl command package{['collectd-utils','python-dbus']: - ensure => present, + ensure => present, } } - package{['git','python-pip']: + if $facts['os']['family'] == 'RedHat' and $facts['os']['release']['major'] == '8' { + $_python_pip_package = 'python3-pip' + $_pip_provider = 'pip3' + } else { + $_python_pip_package = 'python-pip' + $_pip_provider = 'pip' + } + + package{['git',$_python_pip_package]: ensure => present, - before => Package['collectd-systemd'], + before => Package['collectd-systemd'], + } + # Dependency on dbus for collectd-systemd installed with pip. + # https://github.com/mbachry/collectd-systemd/issues/11 + if $facts['os']['family'] == 'RedHat' and $facts['os']['release']['major'] == '8' { + package{'python3-dbus': + ensure => present, + } } + package{'collectd-systemd': - ensure => 'present', - provider => 'pip', - source => 'git+https://github.com/mbachry/collectd-systemd.git', - before => Service['collectd'], + ensure => 'present', + provider => $_pip_provider, + source => 'git+https://github.com/mbachry/collectd-systemd.git', + before => Service['collectd'], } class{'collectd': typesdb => ['/usr/share/collectd/types.db'], } class{'collectd::plugin::python': - logtraces => true, - interactive => false, + logtraces => true, + interactive => false, modules => { 'instanceA' => { - module => 'collectd_systemd', - config => [{'Service' => 'collectd'}], - }, + module => 'collectd_systemd', + config => [{'Service' => 'collectd'}], + }, 'instanceB' => { module => 'collectd_systemd', config => [{'Service' => 'sshd'}], - }, - }, + }, + }, } class{'collectd::plugin::unixsock': socketfile => '/var/run/collectd-sock', + socketgroup => 'root', } + class { 'collectd::plugin::csv':} EOS # Run it twice and test for idempotency diff --git a/spec/acceptance/class_spec.rb b/spec/acceptance/class_spec.rb index e4482ddba..5e36bf298 100644 --- a/spec/acceptance/class_spec.rb +++ b/spec/acceptance/class_spec.rb @@ -6,6 +6,8 @@ it 'works idempotently with no errors' do pp = <<-EOS class { 'collectd': } + # Enable one write plugin to make logs quieter + class { 'collectd::plugin::csv':} EOS # Run it twice and test for idempotency @@ -29,7 +31,11 @@ class { '::collectd': } class { '::collectd::plugin::memory': } - class { '::collectd::plugin::rabbitmq': } + # rabbitmq plugin not ported to Python3 + unless $facts['os']['family'] == 'RedHat' and $facts['os']['release']['major'] == '8' { + class { '::collectd::plugin::rabbitmq': } + } + class { 'collectd::plugin::csv':} EOS # Run it twice and test for idempotency @@ -44,7 +50,7 @@ class { '::collectd::plugin::rabbitmq': } end end - if fact('osfamily') == 'RedHat' + if fact('osfamily') == 'RedHat' && fact('os.release.major') == '7' describe file('/etc/collectd.d/10-rabbitmq.conf') do it { is_expected.to be_file } it { is_expected.to contain 'TypesDB "/usr/share/collectd-rabbitmq/types.db.custom"' } diff --git a/spec/acceptance/curl_json_spec.rb b/spec/acceptance/curl_json_spec.rb index 247f1f3af..4b20aece0 100644 --- a/spec/acceptance/curl_json_spec.rb +++ b/spec/acceptance/curl_json_spec.rb @@ -17,6 +17,9 @@ }, } } + # Adding one write plugin removes a lot + # of confusing/misleading warnings in collectd logs + class { 'collectd::plugin::csv':} EOS # Run it twice and test for idempotency diff --git a/spec/classes/collectd_plugin_rabbitmq_spec.rb b/spec/classes/collectd_plugin_rabbitmq_spec.rb index 9ce97265f..69a8f3b79 100644 --- a/spec/classes/collectd_plugin_rabbitmq_spec.rb +++ b/spec/classes/collectd_plugin_rabbitmq_spec.rb @@ -23,36 +23,41 @@ } end - it 'import collectd_rabbitmq.collectd_plugin in python-config' do - is_expected.to contain_concat_fragment('collectd_plugin_python_conf_collectd_rabbitmq.collectd_plugin_header').with_content(%r{Import "collectd_rabbitmq.collectd_plugin"}) - end - - it 'Load collectd_rabbitmq in python-config' do - is_expected.to contain_concat_fragment('collectd_plugin_python_conf_collectd_rabbitmq.collectd_plugin_config').with_content(%r{Module "collectd_rabbitmq.collectd_plugin"}) - end - - it 'default to Username guest in python-config' do - is_expected.to contain_concat_fragment('collectd_plugin_python_conf_collectd_rabbitmq.collectd_plugin_config').with_content(%r{Username "guest"}) - end - - it 'default to Password guest in python-config' do - is_expected.to contain_concat_fragment('collectd_plugin_python_conf_collectd_rabbitmq.collectd_plugin_config').with_content(%r{Password "guest"}) - end - - it 'default to Port 15672 in python-config' do - is_expected.to contain_concat_fragment('collectd_plugin_python_conf_collectd_rabbitmq.collectd_plugin_config').with_content(%r{Port "15672"}) - end - - it 'default to Scheme http in python-config' do - is_expected.to contain_concat_fragment('collectd_plugin_python_conf_collectd_rabbitmq.collectd_plugin_config').with_content(%r{Scheme "http"}) - end - - it 'Host should be set to $::fqdn python-config' do - is_expected.to contain_concat_fragment('collectd_plugin_python_conf_collectd_rabbitmq.collectd_plugin_config').with_content(%r{Host "testhost.example.com"}) - end - - it 'Realm set to "RabbitMQ Management"' do - is_expected.to contain_concat_fragment('collectd_plugin_python_conf_collectd_rabbitmq.collectd_plugin_config').with_content(%r{Realm "RabbitMQ Management"}) + case [facts[:os]['family'], facts[:os]['release']['major']] + when %w[RedHat 8] + it { is_expected.to raise_error(%r{does not support Python 3}) } + else + it 'import collectd_rabbitmq.collectd_plugin in python-config' do + is_expected.to contain_concat_fragment('collectd_plugin_python_conf_collectd_rabbitmq.collectd_plugin_header').with_content(%r{Import "collectd_rabbitmq.collectd_plugin"}) + end + + it 'Load collectd_rabbitmq in python-config' do + is_expected.to contain_concat_fragment('collectd_plugin_python_conf_collectd_rabbitmq.collectd_plugin_config').with_content(%r{Module "collectd_rabbitmq.collectd_plugin"}) + end + + it 'default to Username guest in python-config' do + is_expected.to contain_concat_fragment('collectd_plugin_python_conf_collectd_rabbitmq.collectd_plugin_config').with_content(%r{Username "guest"}) + end + + it 'default to Password guest in python-config' do + is_expected.to contain_concat_fragment('collectd_plugin_python_conf_collectd_rabbitmq.collectd_plugin_config').with_content(%r{Password "guest"}) + end + + it 'default to Port 15672 in python-config' do + is_expected.to contain_concat_fragment('collectd_plugin_python_conf_collectd_rabbitmq.collectd_plugin_config').with_content(%r{Port "15672"}) + end + + it 'default to Scheme http in python-config' do + is_expected.to contain_concat_fragment('collectd_plugin_python_conf_collectd_rabbitmq.collectd_plugin_config').with_content(%r{Scheme "http"}) + end + + it 'Host should be set to $::fqdn python-config' do + is_expected.to contain_concat_fragment('collectd_plugin_python_conf_collectd_rabbitmq.collectd_plugin_config').with_content(%r{Host "testhost.example.com"}) + end + + it 'Realm set to "RabbitMQ Management"' do + is_expected.to contain_concat_fragment('collectd_plugin_python_conf_collectd_rabbitmq.collectd_plugin_config').with_content(%r{Realm "RabbitMQ Management"}) + end end end @@ -61,8 +66,13 @@ { custom_types_db: '/var/custom/types.db' } end - it 'override custom TypesDB' do - is_expected.to contain_file('rabbitmq.load').with_content(%r{TypesDB "/var/custom/types.db"}) + case [facts[:os]['family'], facts[:os]['release']['major']] + when %w[RedHat 8] + it { is_expected.to raise_error(%r{does not support Python 3}) } + else + it 'override custom TypesDB' do + is_expected.to contain_file('rabbitmq.load').with_content(%r{TypesDB "/var/custom/types.db"}) + end end end @@ -71,8 +81,13 @@ { config: { 'Username' => 'foo' } } end - it 'override Username to foo in python-config' do - is_expected.to contain_concat_fragment('collectd_plugin_python_conf_collectd_rabbitmq.collectd_plugin_config').with_content(%r{Username "foo"}) + case [facts[:os]['family'], facts[:os]['release']['major']] + when %w[RedHat 8] + it { is_expected.to raise_error(%r{does not support Python 3}) } + else + it 'override Username to foo in python-config' do + is_expected.to contain_concat_fragment('collectd_plugin_python_conf_collectd_rabbitmq.collectd_plugin_config').with_content(%r{Username "foo"}) + end end end @@ -81,8 +96,13 @@ { config: { 'Password' => 'foo' } } end - it 'override Username to foo in python-config' do - is_expected.to contain_concat_fragment('collectd_plugin_python_conf_collectd_rabbitmq.collectd_plugin_config').with_content(%r{Password "foo"}) + case [facts[:os]['family'], facts[:os]['release']['major']] + when %w[RedHat 8] + it { is_expected.to raise_error(%r{does not support Python 3}) } + else + it 'override Username to foo in python-config' do + is_expected.to contain_concat_fragment('collectd_plugin_python_conf_collectd_rabbitmq.collectd_plugin_config').with_content(%r{Password "foo"}) + end end end @@ -91,8 +111,13 @@ { config: { 'Scheme' => 'https' } } end - it 'override Username to foo in python-config' do - is_expected.to contain_concat_fragment('collectd_plugin_python_conf_collectd_rabbitmq.collectd_plugin_config').with_content(%r{Scheme "https"}) + case [facts[:os]['family'], facts[:os]['release']['major']] + when %w[RedHat 8] + it { is_expected.to raise_error(%r{does not support Python 3}) } + else + it 'override Username to foo in python-config' do + is_expected.to contain_concat_fragment('collectd_plugin_python_conf_collectd_rabbitmq.collectd_plugin_config').with_content(%r{Scheme "https"}) + end end end end @@ -102,8 +127,13 @@ { ensure: 'absent' } end - it 'Will remove python-config' do - is_expected.not_to contain_concat__fragment('collectd_plugin_python_conf_collectd_rabbitmq.collectd_plugin_config').with(ensure: 'present') + case [facts[:os]['family'], facts[:os]['release']['major']] + when %w[RedHat 8] + it { is_expected.to raise_error(%r{does not support Python 3}) } + else + it 'Will remove python-config' do + is_expected.not_to contain_concat__fragment('collectd_plugin_python_conf_collectd_rabbitmq.collectd_plugin_config').with(ensure: 'present') + end end end @@ -124,11 +154,16 @@ } end - it do - is_expected.to contain_package(packagename).with( - 'ensure' => ensure_value, - 'provider' => provider - ) + case [facts[:os]['family'], facts[:os]['release']['major']] + when %w[RedHat 8] + it { is_expected.to raise_error(%r{does not support Python 3}) } + else + it do + is_expected.to contain_package(packagename).with( + 'ensure' => ensure_value, + 'provider' => provider + ) + end end end # packagename end # ensure set diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index fe6f8a8c0..761062375 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -13,10 +13,5 @@ c.before :suite do install_module install_module_dependencies - - hosts.each do |host| - # python is pre-requisite to the python_path fact. - host.install_package('python') - end end end diff --git a/spec/spec_helper_methods.rb b/spec/spec_helper_methods.rb index ffbb578b9..b078aec87 100644 --- a/spec/spec_helper_methods.rb +++ b/spec/spec_helper_methods.rb @@ -24,11 +24,11 @@ def all_supported_os_hash }, { 'operatingsystem' => 'CentOS', - 'operatingsystemrelease' => ['7'] + 'operatingsystemrelease' => %w[7 8] }, { 'operatingsystem' => 'Ubuntu', - 'operatingsystemrelease' => ['16.04', '18.04'] + 'operatingsystemrelease' => %w[16.04 18.04] }, { 'operatingsystem' => 'FreeBSD', @@ -46,7 +46,7 @@ def baseline_os_hash supported_os: [ { 'operatingsystem' => 'CentOS', - 'operatingsystemrelease' => ['7'] + 'operatingsystemrelease' => %w[7 8] } ] } From d4d70dd2f8190d81af820fd2a89fa323d029d784 Mon Sep 17 00:00:00 2001 From: Steve Traylen Date: Tue, 10 Mar 2020 09:41:57 +0100 Subject: [PATCH 22/37] New utils parameter to install collectdctl On some operating systems `collectdctl`, `collectd-nagios` is contained in a seperate sub package, typically `collectd-utils` Setting `utils` to `true` will install this sub package if it exists for an operating system. --- manifests/init.pp | 7 +++++++ manifests/install.pp | 11 ++++++++++- manifests/params.pp | 1 + spec/acceptance/class_plugin_python_spec.rb | 13 +++++-------- spec/classes/collectd_init_spec.rb | 17 +++++++++++++++++ 5 files changed, 40 insertions(+), 9 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 0bab5ac94..f22f1964b 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -1,4 +1,10 @@ +# @summary installs and configures collectd +# @example Install collectd utilities +# class{'collectd': +# utils => true, +# } # +# @param utils Install collectd utilities package containing collectdctl, collectd-nagios class collectd ( Boolean $autoloadplugin = $collectd::params::autoloadplugin, String $collectd_hostname = $collectd::params::collectd_hostname, @@ -36,6 +42,7 @@ Optional[Integer] $write_queue_limit_high = $collectd::params::write_queue_limit_high, Optional[Integer] $write_queue_limit_low = $collectd::params::write_queue_limit_low, Integer[1] $write_threads = $collectd::params::write_threads, + Boolean $utils = $collectd::params::utils, ) inherits collectd::params { $collectd_version_real = pick_default($facts['collectd_version'], $minimum_version) diff --git a/manifests/install.pp b/manifests/install.pp index ed3522fd4..8efec4cef 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -1,4 +1,5 @@ -# +# @summary installs collectd +# @api private class collectd::install { assert_private() @@ -10,4 +11,12 @@ install_options => $collectd::package_install_options, } } + + if $collectd::utils and ( $facts['os']['family'] == 'Debian' or + ( $facts['os']['family'] == 'RedHat' and versioncmp($facts['os']['release']['major'],'8') >= 0 )) { + package{'collectd-utils': + ensure => $collectd::package_ensure, + } + } + } diff --git a/manifests/params.pp b/manifests/params.pp index 8e3fc53a1..0cb76bef8 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -29,6 +29,7 @@ $plugin_conf_dir_mode = '0750' $ci_package_repo = undef $package_keyserver = 'keyserver.ubuntu.com' + $utils = false case $facts['kernel'] { 'OpenBSD': { $has_wordexp = false } diff --git a/spec/acceptance/class_plugin_python_spec.rb b/spec/acceptance/class_plugin_python_spec.rb index e2b2afb34..9fa857d91 100644 --- a/spec/acceptance/class_plugin_python_spec.rb +++ b/spec/acceptance/class_plugin_python_spec.rb @@ -27,12 +27,6 @@ class { 'collectd::plugin::csv':} context 'trivial pip module connect-time' do it 'works idempotently with no errors' do pp = <<-EOS - if $facts['os']['family'] == 'Debian' or ( $facts['os']['family'] == 'RedHat' and $facts['os']['release']['major'] == '8' ) { - # for collectdctl command - package{'collectd-utils': - ensure => present, - } - } if $facts['os']['family'] == 'RedHat' and $facts['os']['release']['major'] == '8' { $_python_pip_package = 'python3-pip' $_pip_provider = 'pip3' @@ -49,6 +43,9 @@ class { 'collectd::plugin::csv':} require => Package[$_python_pip_package], before => Service['collectd'], } + class{'collectd': + utils => true, + } class{'collectd::plugin::python': logtraces => true, interactive => false, @@ -84,8 +81,7 @@ class { 'collectd::plugin::csv':} it 'works idempotently with no errors' do pp = <<-EOS if $facts['os']['family'] == 'Debian' { - # for collectdctl command - package{['collectd-utils','python-dbus']: + package{'python-dbus': ensure => present, } } @@ -116,6 +112,7 @@ class { 'collectd::plugin::csv':} before => Service['collectd'], } class{'collectd': + utils => true, typesdb => ['/usr/share/collectd/types.db'], } class{'collectd::plugin::python': diff --git a/spec/classes/collectd_init_spec.rb b/spec/classes/collectd_init_spec.rb index 17c067d26..692fb98dc 100644 --- a/spec/classes/collectd_init_spec.rb +++ b/spec/classes/collectd_init_spec.rb @@ -37,6 +37,23 @@ end end + context 'when utils false' do + let(:params) { { utils: false } } + + it { is_expected.not_to contain_package('collectd-utils') } + end + + context 'when utils true' do + let(:params) { { utils: true } } + + case "#{facts[:os]['family']}-#{facts[:os]['release']['major']}" + when %r{^Debian-.+}, 'RedHat-8' + it { is_expected.to contain_package('collectd-utils') } + else + it { is_expected.not_to contain_package('collectd-utils') } + end + end + context 'when purge_config is enabled' do let(:params) { { purge_config: true } } From 3405355d5f3a7a22f5350b7557ee31beb90cdcb7 Mon Sep 17 00:00:00 2001 From: Steve Traylen Date: Tue, 10 Mar 2020 14:59:04 +0100 Subject: [PATCH 23/37] write_http expected to be own package on CentOS 8 As of CentOS 8 the write_http is in its own subpackage so must be installed on CentOS 8. --- manifests/plugin/disk.pp | 2 +- manifests/plugin/write_http.pp | 25 +++++++++- spec/acceptance/class_plugin_disk_spec.rb | 46 +++++++++++++++++++ .../class_plugin_write_http_spec.rb | 30 ++++++++++++ spec/classes/collectd_plugin_disk_spec.rb | 4 +- .../collectd_plugin_write_http_spec.rb | 6 +++ 6 files changed, 108 insertions(+), 5 deletions(-) create mode 100644 spec/acceptance/class_plugin_disk_spec.rb create mode 100644 spec/acceptance/class_plugin_write_http_spec.rb diff --git a/manifests/plugin/disk.pp b/manifests/plugin/disk.pp index 9fadec6ab..7aae1fec1 100644 --- a/manifests/plugin/disk.pp +++ b/manifests/plugin/disk.pp @@ -12,7 +12,7 @@ include collectd - if $facts['os']['family'] == 'RedHat' { + if $facts['os']['family'] == 'RedHat' and versioncmp($facts['os']['release']['major'],'8') >= 0 { if $manage_package != undef { $_manage_package = $manage_package } else { diff --git a/manifests/plugin/write_http.pp b/manifests/plugin/write_http.pp index 49a6d4bea..2057cfd73 100644 --- a/manifests/plugin/write_http.pp +++ b/manifests/plugin/write_http.pp @@ -1,8 +1,14 @@ -# https://collectd.org/wiki/index.php/Plugin:Write_HTTP +# @summary Enable write_http plugin +# +# @see https://collectd.org/wiki/index.php/Plugin:Write_HTTP +# +# @parameter Manage a collectd-write_http package? If undef a suitable value per OS will be chosen. +# class collectd::plugin::write_http ( Enum['present', 'absent'] $ensure = 'present', Hash[String, Hash[String, Scalar]] $nodes = {}, - Hash[String, Hash[String, Scalar]] $urls = {} + Hash[String, Hash[String, Scalar]] $urls = {}, + Optional[Boolean] $manage_package = undef, ) { include collectd @@ -11,6 +17,21 @@ fail('Only one of nodes or urls is supposed to be defined') } + if $manage_package !~ Undef { + $_manage_package = $manage_package + } else { + if $facts['os']['family'] == 'RedHat' and versioncmp($facts['os']['release']['major'],'8') >= 0 { + $_manage_package = true + } else { + $_manage_package = false + } + } + if $_manage_package { + package{'collectd-write_http': + ensure => $ensure, + } + } + $endpoints = merge($nodes, $urls) collectd::plugin { 'write_http': ensure => $ensure, diff --git a/spec/acceptance/class_plugin_disk_spec.rb b/spec/acceptance/class_plugin_disk_spec.rb new file mode 100644 index 000000000..60f16ecfc --- /dev/null +++ b/spec/acceptance/class_plugin_disk_spec.rb @@ -0,0 +1,46 @@ +require 'spec_helper_acceptance' + +describe 'collectd::plugin::disk class' do + context 'basic parameters' do + # Using puppet_apply as a helper + it 'works idempotently with no errors' do + pp = <<-EOS + class{'collectd': + utils => true, + } + class{'collectd::plugin::disk': } + # Add one write plugin to keep logs quiet + class{'collectd::plugin::csv':} + # Create a socket to query + class{'collectd::plugin::unixsock': + socketfile => '/var/run/collectd-sock', + socketgroup => 'root', + } + + EOS + # Run 3 times since the collectd_version + # fact is impossible until collectd is + # installed. + apply_manifest(pp, catch_failures: false) + apply_manifest(pp, catch_failures: true) + apply_manifest(pp, catch_changes: true) + # Wait to get some data + shell('sleep 10') + end + + describe service('collectd') do + it { is_expected.to be_running } + end + + describe command('collectdctl -s /var/run/collectd-sock listval') do + its(:exit_status) { is_expected.to eq 0 } + # the reason debian does not report disk metrics on docker images despite the + # module being loaded is an exercise for the reader. + # For CentOS 7 it works on my laptop but not in travis. + # disk plugin is probably very sensitive to environment. + if fact('os.family') == 'Redhat' && fact('os.release.major') == '8' + its(:stdout) { is_expected.to match %r{disk_time} } + end + end + end +end diff --git a/spec/acceptance/class_plugin_write_http_spec.rb b/spec/acceptance/class_plugin_write_http_spec.rb new file mode 100644 index 000000000..85c4ddd91 --- /dev/null +++ b/spec/acceptance/class_plugin_write_http_spec.rb @@ -0,0 +1,30 @@ +require 'spec_helper_acceptance' + +describe 'collectd::plugin::write_http class' do + context 'basic parameters' do + # Using puppet_apply as a helper + it 'works idempotently with no errors' do + pp = <<-EOS + class{'collectd':} + class { 'collectd::plugin::write_http': + nodes => { + 'collect1' => { 'url' => 'collect1.example.org', 'format' => 'JSON' }, + 'collect2' => { 'url' => 'collect2.example.org'}, + } + } + EOS + # Run 3 times since the collectd_version + # fact is impossible until collectd is + # installed. + apply_manifest(pp, catch_failures: false) + apply_manifest(pp, catch_failures: true) + apply_manifest(pp, catch_changes: true) + # Wait to get some data + shell('sleep 10') + end + + describe service('collectd') do + it { is_expected.to be_running } + end + end +end diff --git a/spec/classes/collectd_plugin_disk_spec.rb b/spec/classes/collectd_plugin_disk_spec.rb index 071abd88a..5e795f843 100644 --- a/spec/classes/collectd_plugin_disk_spec.rb +++ b/spec/classes/collectd_plugin_disk_spec.rb @@ -108,8 +108,8 @@ end end - case facts[:os]['family'] - when 'RedHat' + case [facts[:os]['family'], facts[:os]['release']['major']] + when %w[RedHat 8] context ':manage_package => undef with collectd 5.5 and up' do let :facts do facts.merge(collectd_version: '5.5') diff --git a/spec/classes/collectd_plugin_write_http_spec.rb b/spec/classes/collectd_plugin_write_http_spec.rb index ffad3768f..f8686a962 100644 --- a/spec/classes/collectd_plugin_write_http_spec.rb +++ b/spec/classes/collectd_plugin_write_http_spec.rb @@ -29,6 +29,12 @@ content: "#\ Generated by Puppet\n\n Globals false\n\n\n\n \n\n Format \"JSON\"\n \n\n\n\n" ) end + case [facts[:os]['family'], facts[:os]['release']['major']] + when %w[RedHat 8] + it { is_expected.to contain_package('collectd-write_http') } + else + it { is_expected.not_to contain_package('collectd-write_http') } + end end context ':ensure => present and :nodes => { \'collectd\' => { \'url\' => \'collectd.org.1\', \'format\' => \'JSON\'}}' do From 9a159ba79aee703081533e210f3d8118cd90b513 Mon Sep 17 00:00:00 2001 From: Steve Traylen Date: Thu, 19 Mar 2020 17:16:58 +0100 Subject: [PATCH 24/37] Release 11.3.0 * Addition of CentOS 8 support. * New utils parameter --- CHANGELOG.md | 21 ++++++++++++++++++++- metadata.json | 2 +- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fde6e3067..76a0b19b6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,26 @@ All notable changes to this project will be documented in this file. Each new release typically also includes the latest modulesync defaults. These should not affect the functionality of the module. -## [v11.2.0](https://github.com/voxpupuli/puppet-collectd/tree/v11.2.0) (2020-02-24) +## [v11.3.0](https://github.com/voxpupuli/puppet-collectd/tree/v11.3.0) (2020-03-19) + +[Full Changelog](https://github.com/voxpupuli/puppet-collectd/compare/v11.2.0...v11.3.0) + +**Implemented enhancements:** + +- New utils parameter to install collectdctl [\#919](https://github.com/voxpupuli/puppet-collectd/pull/919) ([traylenator](https://github.com/traylenator)) +- Require puppet-epel over stahnma-epel [\#918](https://github.com/voxpupuli/puppet-collectd/pull/918) ([traylenator](https://github.com/traylenator)) +- Add CentOS 8 support [\#917](https://github.com/voxpupuli/puppet-collectd/pull/917) ([traylenator](https://github.com/traylenator)) +- Add dpdk\_telemetry plugin [\#913](https://github.com/voxpupuli/puppet-collectd/pull/913) ([prabiegx](https://github.com/prabiegx)) + +**Fixed bugs:** + +- write\_http/disk is own sub package on CentOS 8 [\#920](https://github.com/voxpupuli/puppet-collectd/pull/920) ([traylenator](https://github.com/traylenator)) + +**Closed issues:** + +- Time for a new version ? [\#684](https://github.com/voxpupuli/puppet-collectd/issues/684) + +## [v11.2.0](https://github.com/voxpupuli/puppet-collectd/tree/v11.2.0) (2020-02-25) [Full Changelog](https://github.com/voxpupuli/puppet-collectd/compare/v11.1.0...v11.2.0) diff --git a/metadata.json b/metadata.json index 02ea1518f..33270eb14 100644 --- a/metadata.json +++ b/metadata.json @@ -61,7 +61,7 @@ } ], "name": "puppet-collectd", - "version": "11.2.1-rc0", + "version": "11.3.0", "source": "https://github.com/voxpupuli/puppet-collectd", "author": "Vox Pupuli", "license": "Apache-2.0", From 26e4cb2abf54a2ce1fa8354f87bbfa86b8cb172d Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Thu, 19 Mar 2020 21:58:16 +0100 Subject: [PATCH 25/37] [blacksmith] Bump version to 11.3.1-rc0 --- metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.json b/metadata.json index 33270eb14..2fada1ddd 100644 --- a/metadata.json +++ b/metadata.json @@ -61,7 +61,7 @@ } ], "name": "puppet-collectd", - "version": "11.3.0", + "version": "11.3.1-rc0", "source": "https://github.com/voxpupuli/puppet-collectd", "author": "Vox Pupuli", "license": "Apache-2.0", From d45621c99019b46517ea92a367182c50c5cd00a2 Mon Sep 17 00:00:00 2001 From: Steve Traylen Date: Fri, 20 Mar 2020 12:17:20 +0100 Subject: [PATCH 26/37] Ignore more installed versions of python during tests The unit tests for python_dir fact were giving a false failure ``` 1) python_dir is empty string if python not installed Failure/Error: expect(Facter.fact(:python_dir).value).to eq('') expected: "" got: "/usr/lib/python2.7/site-packages" (compared using ==) ``` If they were executed on a system where `/usr/libexec/platform-python` was present - not the case (presumably) for Travis CI. --- spec/unit/python_dir_spec.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spec/unit/python_dir_spec.rb b/spec/unit/python_dir_spec.rb index b0deaf8da..188c3bc78 100644 --- a/spec/unit/python_dir_spec.rb +++ b/spec/unit/python_dir_spec.rb @@ -42,7 +42,9 @@ it 'is empty string if python not installed' do Facter::Util::Resolution.stubs(:which).with('python').returns(nil) + Facter::Util::Resolution.stubs(:which).with('python2').returns(nil) Facter::Util::Resolution.stubs(:which).with('python3').returns(nil) + File.stubs(:exist?).with('/usr/libexec/platform-python').returns(nil) expect(Facter.fact(:python_dir).value).to eq('') end end From bb889edea53c96a2f0a9667dedbe2d3664849d36 Mon Sep 17 00:00:00 2001 From: Steve Traylen Date: Fri, 20 Mar 2020 14:38:42 +0100 Subject: [PATCH 27/37] Skip Load:ReportRelative is problematic for collectd9 Refixes https://github.com/voxpupuli/puppet-collectd/issues/901 The bug was that a ReportRelative configuration to the load plugin for collectd 5.9.0 was causing a parse error. It has been fixed for 5.9.1 collectd module now skips this configuration for collectd for collectd == 5.9.0 Previously it was '!=' 5.9. * Upsteam bug for collectd: https://github.com/voxpupuli/puppet-collectd/issues/901 * Previous incorrect commit: https://github.com/voxpupuli/puppet-collectd/commit/8edc01430d03eeabe812a7bab065f6b25200fda3 --- spec/acceptance/class_plugin_load_spec.rb | 127 ++++++++++++++++++++++ templates/plugin/load.conf.erb | 5 +- 2 files changed, 131 insertions(+), 1 deletion(-) create mode 100644 spec/acceptance/class_plugin_load_spec.rb diff --git a/spec/acceptance/class_plugin_load_spec.rb b/spec/acceptance/class_plugin_load_spec.rb new file mode 100644 index 000000000..17db4e16c --- /dev/null +++ b/spec/acceptance/class_plugin_load_spec.rb @@ -0,0 +1,127 @@ +require 'spec_helper_acceptance' + +describe 'collectd::plugin::load class' do + context 'basic parameters' do + # Using puppet_apply as a helper + it 'works idempotently with no errors' do + pp = <<-EOS + class{'collectd': + utils => true, + } + class{'collectd::plugin::load': } + # Add one write plugin to keep logs quiet + class{'collectd::plugin::csv':} + # Create a socket to query + class{'collectd::plugin::unixsock': + socketfile => '/var/run/collectd-sock', + socketgroup => 'root', + } + + EOS + # Run 3 times since the collectd_version + # fact is impossible until collectd is + # installed. + apply_manifest(pp, catch_failures: false) + apply_manifest(pp, catch_failures: true) + apply_manifest(pp, catch_changes: true) + # Wait to get some data + shell('sleep 10') + end + + describe service('collectd') do + it { is_expected.to be_running } + end + + describe command('collectdctl -s /var/run/collectd-sock listval') do + its(:exit_status) { is_expected.to eq 0 } + its(:stdout) { is_expected.to match %r{load/load$} } + its(:stdout) { is_expected.not_to match %r{load/load-relative$} } + end + end + context 'report relative false' do + # Using puppet_apply as a helper + it 'works idempotently with no errors' do + pp = <<-EOS + class{'collectd': + utils => true, + } + class{'collectd::plugin::load': + report_relative => false, + } + # Add one write plugin to keep logs quiet + class{'collectd::plugin::csv':} + # Create a socket to query + class{'collectd::plugin::unixsock': + socketfile => '/var/run/collectd-sock', + socketgroup => 'root', + } + + EOS + # Run 3 times since the collectd_version + # fact is impossible until collectd is + # installed. + apply_manifest(pp, catch_failures: false) + apply_manifest(pp, catch_failures: true) + apply_manifest(pp, catch_changes: true) + # Wait to get some data + shell('sleep 10') + end + + describe service('collectd') do + it { is_expected.to be_running } + end + + describe command('collectdctl -s /var/run/collectd-sock listval') do + its(:exit_status) { is_expected.to eq 0 } + its(:stdout) { is_expected.to match %r{load/load$} } + its(:stdout) { is_expected.not_to match %r{load/load-relative$} } + end + end + context 'report relative true' do + # Using puppet_apply as a helper + it 'works idempotently with no errors' do + pp = <<-EOS + class{'collectd': + utils => true, + } + class{'collectd::plugin::load': + report_relative => true, + } + # Add one write plugin to keep logs quiet + class{'collectd::plugin::csv':} + # Create a socket to query + class{'collectd::plugin::unixsock': + socketfile => '/var/run/collectd-sock', + socketgroup => 'root', + } + + EOS + # Run 3 times since the collectd_version + # fact is impossible until collectd is + # installed. + apply_manifest(pp, catch_failures: false) + apply_manifest(pp, catch_failures: true) + apply_manifest(pp, catch_changes: true) + # Wait to get some data + shell('sleep 10') + end + + describe service('collectd') do + it { is_expected.to be_running } + end + + describe command('collectdctl -s /var/run/collectd-sock listval') do + its(:exit_status) { is_expected.to eq 0 } + # https://github.com/voxpupuli/puppet-collectd/issues/901 + # following will fail once 5.9.1 is released in EPEL8 + if fact('osfamily') == 'RedHat' && fact('os.release.major') == '8' || + fact('osfamily') == 'Debian' && fact('os.release.major') == '8' + its(:stdout) { is_expected.not_to match %r{load/load-relative$} } + its(:stdout) { is_expected.to match %r{load/load$} } + else + its(:stdout) { is_expected.to match %r{load/load-relative$} } + its(:stdout) { is_expected.not_to match %r{load/load$} } + end + end + end +end diff --git a/templates/plugin/load.conf.erb b/templates/plugin/load.conf.erb index 44b84d742..fa5f5b35a 100644 --- a/templates/plugin/load.conf.erb +++ b/templates/plugin/load.conf.erb @@ -1,6 +1,9 @@ <% if scope.lookupvar('collectd::collectd_version_real') and (scope.function_versioncmp([scope.lookupvar('collectd::collectd_version_real'), '5.5']) >= 0) -%> -<% if scope.lookupvar('collectd::collectd_version_real') and (scope.function_versioncmp([scope.lookupvar('collectd::collectd_version_real'), '5.9']) == 0) -%> +<% if scope.lookupvar('collectd::collectd_version_real') and (scope.function_versioncmp([scope.lookupvar('collectd::collectd_version_real'), '5.9.0']) == 0) -%> + # ReportRelative is broken with collectd 5.9.0 + # https://github.com/collectd/collectd/issues/3180 +<% else -%> ReportRelative <%= @report_relative %> <% end -%> From f1d7ee5c122d7b6168250639cdcd2459494c2b51 Mon Sep 17 00:00:00 2001 From: Steve Traylen Date: Mon, 23 Mar 2020 17:17:48 +0100 Subject: [PATCH 28/37] Create processess plugin type configuration on RedHat There was a name clash between: * Puppet created configuration file. * Package provided configuration file which was being purged. Since a864d0d58815d58c944277417dcf52df2d3c7572 the collectd module on RedHat purges the package provided file file `/etc/collectd.d/processes-config.conf` The module was also creating this file with a concat and result was no file on system. To avoid the clash puppet now creates the file `processes_config.conf`. Note the `-` vs `_`. There is probably a cleaner fix to move all of the processes plugin configuration into the per module file `/etc/collect.d/10-processses.conf` as that would be more consistant with other simpler modules using a single template rather than a concat. This would be a change for every module however with `collectd::plugin` itself changing. Fixes #926 --- manifests/plugin/processes.pp | 6 +-- manifests/plugin/processes/process.pp | 2 +- manifests/plugin/processes/processmatch.pp | 2 +- .../define_plugin_processes_process_spec.rb | 48 ++++++++++++++++++ ...fine_plugin_processes_processmatch_spec.rb | 50 +++++++++++++++++++ .../classes/collectd_plugin_processes_spec.rb | 34 +++++++------ 6 files changed, 122 insertions(+), 20 deletions(-) create mode 100644 spec/acceptance/define_plugin_processes_process_spec.rb create mode 100644 spec/acceptance/define_plugin_processes_processmatch_spec.rb diff --git a/manifests/plugin/processes.pp b/manifests/plugin/processes.pp index 23ff9df9e..33a1d9219 100644 --- a/manifests/plugin/processes.pp +++ b/manifests/plugin/processes.pp @@ -21,7 +21,7 @@ interval => $interval, } - concat { "${collectd::plugin_conf_dir}/processes-config.conf": + concat { "${collectd::plugin_conf_dir}/processes_config.conf": ensure => $ensure, mode => $collectd::config_mode, owner => $collectd::config_owner, @@ -32,13 +32,13 @@ concat::fragment { 'collectd_plugin_processes_conf_header': order => '00', content => epp('collectd/plugin/processes-header.conf.epp'), - target => "${collectd::plugin_conf_dir}/processes-config.conf", + target => "${collectd::plugin_conf_dir}/processes_config.conf", } concat::fragment { 'collectd_plugin_processes_conf_footer': order => '99', content => '', - target => "${collectd::plugin_conf_dir}/processes-config.conf", + target => "${collectd::plugin_conf_dir}/processes_config.conf", } if $processes { diff --git a/manifests/plugin/processes/process.pp b/manifests/plugin/processes/process.pp index 02c8d736e..2a8ea32de 100644 --- a/manifests/plugin/processes/process.pp +++ b/manifests/plugin/processes/process.pp @@ -17,7 +17,7 @@ 'collect_file_descriptor' => $collect_file_descriptor, 'collect_memory_maps' => $collect_memory_maps, }), - target => "${collectd::plugin_conf_dir}/processes-config.conf", + target => "${collectd::plugin_conf_dir}/processes_config.conf", } } diff --git a/manifests/plugin/processes/processmatch.pp b/manifests/plugin/processes/processmatch.pp index f0b07a524..57c786d16 100644 --- a/manifests/plugin/processes/processmatch.pp +++ b/manifests/plugin/processes/processmatch.pp @@ -19,6 +19,6 @@ 'collect_file_descriptor' => $collect_file_descriptor, 'collect_memory_maps' => $collect_memory_maps, }), - target => "${collectd::plugin_conf_dir}/processes-config.conf", + target => "${collectd::plugin_conf_dir}/processes_config.conf", } } diff --git a/spec/acceptance/define_plugin_processes_process_spec.rb b/spec/acceptance/define_plugin_processes_process_spec.rb new file mode 100644 index 000000000..64ff23801 --- /dev/null +++ b/spec/acceptance/define_plugin_processes_process_spec.rb @@ -0,0 +1,48 @@ +require 'spec_helper_acceptance' + +describe 'collectd::plugin::processes::process' do + context 'basic parameters' do + # Using puppet_apply as a helper + it 'works idempotently with no errors' do + pp = <<-EOS + class{'collectd': + utils => true, + purge => true, + recurse => true, + purge_config => true, + } + + collectd::plugin::processes::process{'bar': + collect_file_descriptor => true, + } + + # Configure one write plugin to keep logs quiet + class{'collectd::plugin::csv':} + # Create a socket to query + class{'collectd::plugin::unixsock': + socketfile => '/var/run/collectd-sock', + socketgroup => 'root', + deletesocket => true, + } + + EOS + # Run 3 times since the collectd_version + # fact is impossible until collectd is + # installed. + apply_manifest(pp, catch_failures: false) + apply_manifest(pp, catch_failures: true) + apply_manifest(pp, catch_changes: true) + # Wait to get some data + shell('sleep 10') + end + + describe service('collectd') do + it { is_expected.to be_running } + end + + describe command('collectdctl -s /var/run/collectd-sock listval') do + its(:exit_status) { is_expected.to eq 0 } + its(:stdout) { is_expected.to match %r{processes-bar/ps_count} } + end + end +end diff --git a/spec/acceptance/define_plugin_processes_processmatch_spec.rb b/spec/acceptance/define_plugin_processes_processmatch_spec.rb new file mode 100644 index 000000000..0e17fa66c --- /dev/null +++ b/spec/acceptance/define_plugin_processes_processmatch_spec.rb @@ -0,0 +1,50 @@ +require 'spec_helper_acceptance' + +describe 'collectd::plugin::processes::processmatchs' do + context 'basic parameters' do + # Using puppet_apply as a helper + it 'works idempotently with no errors' do + pp = <<-EOS + class{'collectd': + utils => true, + purge => true, + recurse => true, + purge_config => true, + + } + + # Configure one write plugin to keep logs quiet + collectd::plugin::processes::processmatch{'foo': + collect_file_descriptor => true, + regex => 'foo .*$', + } + + class{'collectd::plugin::csv':} + # Create a socket to query + class{'collectd::plugin::unixsock': + socketfile => '/var/run/collectd-sock', + socketgroup => 'root', + deletesocket => true, + } + + EOS + # Run 3 times since the collectd_version + # fact is impossible until collectd is + # installed. + apply_manifest(pp, catch_failures: false) + apply_manifest(pp, catch_failures: true) + apply_manifest(pp, catch_changes: true) + # Wait to get some data + shell('sleep 10') + end + + describe service('collectd') do + it { is_expected.to be_running } + end + + describe command('collectdctl -s /var/run/collectd-sock listval') do + its(:exit_status) { is_expected.to eq 0 } + its(:stdout) { is_expected.to match %r{processes-foo/ps_count} } + end + end +end diff --git a/spec/classes/collectd_plugin_processes_spec.rb b/spec/classes/collectd_plugin_processes_spec.rb index f16e38e91..cdec24937 100644 --- a/spec/classes/collectd_plugin_processes_spec.rb +++ b/spec/classes/collectd_plugin_processes_spec.rb @@ -18,19 +18,19 @@ ) end - it "Will create #{options[:plugin_conf_dir]}/processes-config.conf" do - is_expected.to contain_concat("#{options[:plugin_conf_dir]}/processes-config.conf").that_requires('File[collectd.d]') + it "Will create #{options[:plugin_conf_dir]}/processes_config.conf" do + is_expected.to contain_concat("#{options[:plugin_conf_dir]}/processes_config.conf").that_requires('File[collectd.d]') is_expected.to contain_concat__fragment('collectd_plugin_processes_conf_header').with( content: "\n", - target: "#{options[:plugin_conf_dir]}/processes-config.conf", + target: "#{options[:plugin_conf_dir]}/processes_config.conf", order: '00' ) end - it "Will create #{options[:plugin_conf_dir]}/processes-config.conf" do + it "Will create #{options[:plugin_conf_dir]}/processes_config.conf" do is_expected.to contain_concat__fragment('collectd_plugin_processes_conf_footer').with( content: %r{}, - target: "#{options[:plugin_conf_dir]}/processes-config.conf", + target: "#{options[:plugin_conf_dir]}/processes_config.conf", order: '99' ) end @@ -66,15 +66,15 @@ } end - it "Will create #{options[:plugin_conf_dir]}/processes-config.conf" do - is_expected.to contain_concat("#{options[:plugin_conf_dir]}/processes-config.conf").that_requires('File[collectd.d]') + it "Will create #{options[:plugin_conf_dir]}/processes_config.conf" do + is_expected.to contain_concat("#{options[:plugin_conf_dir]}/processes_config.conf").that_requires('File[collectd.d]') is_expected.to contain_concat__fragment('collectd_plugin_processes_conf_header').with( content: " CollectContextSwitch true CollectFileDescriptor false CollectMemoryMaps true ", - target: "#{options[:plugin_conf_dir]}/processes-config.conf", + target: "#{options[:plugin_conf_dir]}/processes_config.conf", order: '00' ) is_expected.to contain_concat__fragment('collectd_plugin_processes_conf_process_httpd').with( @@ -84,14 +84,14 @@ CollectMemoryMaps false ", - target: "#{options[:plugin_conf_dir]}/processes-config.conf", + target: "#{options[:plugin_conf_dir]}/processes_config.conf", order: '50' ) is_expected.to contain_concat__fragment('collectd_plugin_processes_conf_process_mysql').with( content: " ", - target: "#{options[:plugin_conf_dir]}/processes-config.conf", + target: "#{options[:plugin_conf_dir]}/processes_config.conf", order: '50' ) @@ -102,14 +102,14 @@ CollectMemoryMaps false ", - target: "#{options[:plugin_conf_dir]}/processes-config.conf", + target: "#{options[:plugin_conf_dir]}/processes_config.conf", order: '51' ) is_expected.to contain_concat__fragment('collectd_plugin_processes_conf_processmatch_dove').with( content: " ", - target: "#{options[:plugin_conf_dir]}/processes-config.conf", + target: "#{options[:plugin_conf_dir]}/processes_config.conf", order: '51' ) end @@ -122,19 +122,19 @@ } end - it "Will create #{options[:plugin_conf_dir]}/processes-config.conf" do + it "Will create #{options[:plugin_conf_dir]}/processes_config.conf" do is_expected.to contain_concat__fragment('collectd_plugin_processes_conf_process_process1').with( content: " ", - target: "#{options[:plugin_conf_dir]}/processes-config.conf", + target: "#{options[:plugin_conf_dir]}/processes_config.conf", order: '50' ) is_expected.to contain_concat__fragment('collectd_plugin_processes_conf_process_process2').with( content: " ", - target: "#{options[:plugin_conf_dir]}/processes-config.conf", + target: "#{options[:plugin_conf_dir]}/processes_config.conf", order: '50' ) end @@ -145,6 +145,10 @@ context 'on osfamily => RedHat' do it 'Will delete packaging config file' do is_expected.to contain_file('package_processes.load').with_ensure('absent') + is_expected.to contain_file('package_processes.load').with_path('/etc/collectd.d/processes-config.conf') + end + it 'Will not clash with package file' do + is_expected.not_to contain_concat('/etc/collectd.d/processes-config.conf') end end end From 92163589de307e79caa1f81ff6fb9898522729a5 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Sat, 28 Mar 2020 16:58:56 +0100 Subject: [PATCH 29/37] Release 11.4.0 --- CHANGELOG.md | 15 +++++++++++++++ metadata.json | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 76a0b19b6..5cddcb846 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,21 @@ All notable changes to this project will be documented in this file. Each new release typically also includes the latest modulesync defaults. These should not affect the functionality of the module. +## [v11.4.0](https://github.com/voxpupuli/puppet-collectd/tree/v11.4.0) (2020-03-28) + +[Full Changelog](https://github.com/voxpupuli/puppet-collectd/compare/v11.3.0...v11.4.0) + +**Implemented enhancements:** + +- Add Plugin Log parser [\#912](https://github.com/voxpupuli/puppet-collectd/pull/912) ([MichalRebisz](https://github.com/MichalRebisz)) + +**Fixed bugs:** + +- processes-config.conf file is not created [\#926](https://github.com/voxpupuli/puppet-collectd/issues/926) +- Create processes plugin configuration on RedHat [\#927](https://github.com/voxpupuli/puppet-collectd/pull/927) ([traylenator](https://github.com/traylenator)) +- Skip Load:ReportRelative as problematic for collectd 5.9.0 [\#924](https://github.com/voxpupuli/puppet-collectd/pull/924) ([traylenator](https://github.com/traylenator)) +- Ignore more installed versions of python during tests [\#923](https://github.com/voxpupuli/puppet-collectd/pull/923) ([traylenator](https://github.com/traylenator)) + ## [v11.3.0](https://github.com/voxpupuli/puppet-collectd/tree/v11.3.0) (2020-03-19) [Full Changelog](https://github.com/voxpupuli/puppet-collectd/compare/v11.2.0...v11.3.0) diff --git a/metadata.json b/metadata.json index 2fada1ddd..d79e0e571 100644 --- a/metadata.json +++ b/metadata.json @@ -61,7 +61,7 @@ } ], "name": "puppet-collectd", - "version": "11.3.1-rc0", + "version": "11.4.0", "source": "https://github.com/voxpupuli/puppet-collectd", "author": "Vox Pupuli", "license": "Apache-2.0", From b2f7e70fd8f54f62ecaa43dd43031c818fdc9465 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Sun, 29 Mar 2020 12:39:31 +0200 Subject: [PATCH 30/37] [blacksmith] Bump version to 11.4.1-rc0 --- metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.json b/metadata.json index d79e0e571..21a675870 100644 --- a/metadata.json +++ b/metadata.json @@ -61,7 +61,7 @@ } ], "name": "puppet-collectd", - "version": "11.4.0", + "version": "11.4.1-rc0", "source": "https://github.com/voxpupuli/puppet-collectd", "author": "Vox Pupuli", "license": "Apache-2.0", From ca6336a40843ad3d7761da35c777b5c596d02990 Mon Sep 17 00:00:00 2001 From: NikolayTsvetkov Date: Tue, 31 Mar 2020 12:20:06 +0200 Subject: [PATCH 31/37] Install disk package if required prior CentOS 8 This PR is a bug fix allowing to install the disk package in versions prior CentOS 8 in case `$manage_package` is configured by the user. --- manifests/plugin/disk.pp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/manifests/plugin/disk.pp b/manifests/plugin/disk.pp index 7aae1fec1..9cb773d53 100644 --- a/manifests/plugin/disk.pp +++ b/manifests/plugin/disk.pp @@ -12,11 +12,12 @@ include collectd - if $facts['os']['family'] == 'RedHat' and versioncmp($facts['os']['release']['major'],'8') >= 0 { + if $facts['os']['family'] == 'RedHat' { if $manage_package != undef { $_manage_package = $manage_package } else { - if versioncmp($collectd::collectd_version_real, '5.5') >= 0 { + if versioncmp($collectd::collectd_version_real, '5.5') >= 0 + and versioncmp($facts['os']['release']['major'],'8') >= 0 { $_manage_package = true } else { $_manage_package = false From f4a6fa8ca9b3c00e29d2ef09c88d364c4a6a757d Mon Sep 17 00:00:00 2001 From: NikolayTsvetkov Date: Wed, 1 Apr 2020 10:21:08 +0200 Subject: [PATCH 32/37] Remove trailing whitespace --- manifests/plugin/disk.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/plugin/disk.pp b/manifests/plugin/disk.pp index 9cb773d53..bc2282cb0 100644 --- a/manifests/plugin/disk.pp +++ b/manifests/plugin/disk.pp @@ -16,7 +16,7 @@ if $manage_package != undef { $_manage_package = $manage_package } else { - if versioncmp($collectd::collectd_version_real, '5.5') >= 0 + if versioncmp($collectd::collectd_version_real, '5.5') >= 0 and versioncmp($facts['os']['release']['major'],'8') >= 0 { $_manage_package = true } else { From b6f6b8c1ba68c45391e60c2b32b47da15e1bc4b3 Mon Sep 17 00:00:00 2001 From: Piotr Rabiega Date: Wed, 1 Apr 2020 17:24:22 +0200 Subject: [PATCH 33/37] rename log_parser to logparser --- manifests/plugin/{log_parser.pp => logparser.pp} | 8 ++++---- ...r_spec.rb => collectd_plugin_logparser_spec.rb} | 14 +++++++------- spec/fixtures/plugins/logparser.conf.default | 4 ++-- .../{log_parser.conf.epp => logparser.conf.epp} | 2 +- types/log_parser/logfile.pp | 5 ----- types/logparser/logfile.pp | 5 +++++ types/{log_parser => logparser}/match.pp | 2 +- types/{log_parser => logparser}/message.pp | 4 ++-- 8 files changed, 22 insertions(+), 22 deletions(-) rename manifests/plugin/{log_parser.pp => logparser.pp} (91%) rename spec/classes/{collectd_plugin_log_parser_spec.rb => collectd_plugin_logparser_spec.rb} (57%) rename templates/plugin/{log_parser.conf.epp => logparser.conf.epp} (99%) delete mode 100644 types/log_parser/logfile.pp create mode 100644 types/logparser/logfile.pp rename types/{log_parser => logparser}/match.pp (90%) rename types/{log_parser => logparser}/message.pp (66%) diff --git a/manifests/plugin/log_parser.pp b/manifests/plugin/logparser.pp similarity index 91% rename from manifests/plugin/log_parser.pp rename to manifests/plugin/logparser.pp index ed23ba25f..bd050ef7b 100644 --- a/manifests/plugin/log_parser.pp +++ b/manifests/plugin/logparser.pp @@ -1,7 +1,7 @@ #https://wiki.opnfv.org/display/fastpath/Logparser+plugin+HLD -class collectd::plugin::log_parser ( +class collectd::plugin::logparser ( $ensure = 'present', - Array[Hash[String[1],Collectd::LOG_PARSER::Logfile]] $logfile = [{ + Array[Hash[String[1],Collectd::LOGPARSER::Logfile]] $logfile = [{ '/var/log/syslog' => { 'firstfullread' => false, 'message' => [ @@ -66,9 +66,9 @@ ){ include collectd - collectd::plugin { 'log_parser': + collectd::plugin { 'logparser': ensure => $ensure, - content => epp('collectd/plugin/log_parser.conf.epp', { + content => epp('collectd/plugin/logparser.conf.epp', { 'logfile' => $logfile, }), order => '06', diff --git a/spec/classes/collectd_plugin_log_parser_spec.rb b/spec/classes/collectd_plugin_logparser_spec.rb similarity index 57% rename from spec/classes/collectd_plugin_log_parser_spec.rb rename to spec/classes/collectd_plugin_logparser_spec.rb index 96a0a85b3..0b7c5337f 100644 --- a/spec/classes/collectd_plugin_log_parser_spec.rb +++ b/spec/classes/collectd_plugin_logparser_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'collectd::plugin::log_parser', type: :class do +describe 'collectd::plugin::logparser', type: :class do on_supported_os(baseline_os_hash).each do |os, facts| context "on #{os} " do let :facts do @@ -11,20 +11,20 @@ options = os_specific_options(facts) context ':ensure => present, default params' do - it "Will create #{options[:plugin_conf_dir]}/06-log_parser.conf" do - is_expected.to contain_file('log_parser.load').with( + it "Will create #{options[:plugin_conf_dir]}/06-logparser.conf" do + is_expected.to contain_file('logparser.load').with( ensure: 'present', - path: "#{options[:plugin_conf_dir]}/06-log_parser.conf" + path: "#{options[:plugin_conf_dir]}/06-logparser.conf" ) end end context ':ensure => log parser created with default values' do default_fixture = File.read(fixtures('plugins/logparser.conf.default')) - it "Will create #{options[:plugin_conf_dir]}/06-log_parser.conf" do - is_expected.to contain_file('log_parser.load').with( + it "Will create #{options[:plugin_conf_dir]}/06-logparser.conf" do + is_expected.to contain_file('logparser.load').with( ensure: 'present', - path: "#{options[:plugin_conf_dir]}/06-log_parser.conf", + path: "#{options[:plugin_conf_dir]}/06-logparser.conf", content: default_fixture ) end diff --git a/spec/fixtures/plugins/logparser.conf.default b/spec/fixtures/plugins/logparser.conf.default index 5e89d5a66..f3470d8b7 100644 --- a/spec/fixtures/plugins/logparser.conf.default +++ b/spec/fixtures/plugins/logparser.conf.default @@ -1,9 +1,9 @@ # Generated by Puppet - + Globals false - + FirstFullRead "false" diff --git a/templates/plugin/log_parser.conf.epp b/templates/plugin/logparser.conf.epp similarity index 99% rename from templates/plugin/log_parser.conf.epp rename to templates/plugin/logparser.conf.epp index bf7c04a85..fc3a9d311 100644 --- a/templates/plugin/log_parser.conf.epp +++ b/templates/plugin/logparser.conf.epp @@ -1,5 +1,5 @@ <%- | Optional $logfile = undef | -%> - + <% $logfile.each |$file| { -%> <% $file.keys.sort.each |$key| { -%> "> diff --git a/types/log_parser/logfile.pp b/types/log_parser/logfile.pp deleted file mode 100644 index 26cfbc4b7..000000000 --- a/types/log_parser/logfile.pp +++ /dev/null @@ -1,5 +0,0 @@ -#https://wiki.opnfv.org/display/fastpath/Logparser+plugin+HLD -type Collectd::LOG_PARSER::Logfile = Struct[{ - 'firstfullread' => Boolean, - 'message' => Array[Hash[String[1],Collectd::LOG_PARSER::Message]] -}] diff --git a/types/logparser/logfile.pp b/types/logparser/logfile.pp new file mode 100644 index 000000000..2148f6700 --- /dev/null +++ b/types/logparser/logfile.pp @@ -0,0 +1,5 @@ +#https://wiki.opnfv.org/display/fastpath/Logparser+plugin+HLD +type Collectd::LOGPARSER::Logfile = Struct[{ + 'firstfullread' => Boolean, + 'message' => Array[Hash[String[1],Collectd::LOGPARSER::Message]] +}] diff --git a/types/log_parser/match.pp b/types/logparser/match.pp similarity index 90% rename from types/log_parser/match.pp rename to types/logparser/match.pp index 2b50b83ff..042823462 100644 --- a/types/log_parser/match.pp +++ b/types/logparser/match.pp @@ -1,5 +1,5 @@ #https://wiki.opnfv.org/display/fastpath/Logparser+plugin+HLD -type Collectd::LOG_PARSER::Match = Struct[{ +type Collectd::LOGPARSER::Match = Struct[{ 'regex' => String, Optional['submatchidx'] => Integer, Optional['excluderegex'] => String, diff --git a/types/log_parser/message.pp b/types/logparser/message.pp similarity index 66% rename from types/log_parser/message.pp rename to types/logparser/message.pp index 83a9f82e2..12efe2ed1 100644 --- a/types/log_parser/message.pp +++ b/types/logparser/message.pp @@ -1,8 +1,8 @@ #https://wiki.opnfv.org/display/fastpath/Logparser+plugin+HLD -type Collectd::LOG_PARSER::Message = Struct[{ +type Collectd::LOGPARSER::Message = Struct[{ Optional['defaultplugininstance'] => String, Optional['defaulttype'] => String, Optional['defaulttypeinstance'] => String, Optional['defaultseverity'] => String, - Optional['match'] => Array[Hash[String[1],Collectd::LOG_PARSER::Match]] + Optional['match'] => Array[Hash[String[1],Collectd::LOGPARSER::Match]] }] From 2db37aa864d2938cdc22a0602cea0e3cd77c7b21 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Sat, 4 Apr 2020 12:28:13 +0200 Subject: [PATCH 34/37] modulesync 2.12.0 --- Gemfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index 4d187ccc8..11c85584f 100644 --- a/Gemfile +++ b/Gemfile @@ -11,9 +11,9 @@ def location_for(place, fake_version = nil) end group :test do - gem 'voxpupuli-test', :require => false - gem 'coveralls', :require => false - gem 'simplecov-console', :require => false + gem 'voxpupuli-test', '>= 1.0.0', :require => false + gem 'coveralls', :require => false + gem 'simplecov-console', :require => false end group :development do From 913556f21ffcbeefa472e82c8299685aa65bef07 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Sat, 4 Apr 2020 13:08:12 +0200 Subject: [PATCH 35/37] release 12.0.0 --- CHANGELOG.md | 15 ++++++++++++++- metadata.json | 2 +- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5cddcb846..8c8617982 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,20 @@ All notable changes to this project will be documented in this file. Each new release typically also includes the latest modulesync defaults. These should not affect the functionality of the module. -## [v11.4.0](https://github.com/voxpupuli/puppet-collectd/tree/v11.4.0) (2020-03-28) +## [v12.0.0](https://github.com/voxpupuli/puppet-collectd/tree/v12.0.0) (2020-04-04) + +[Full Changelog](https://github.com/voxpupuli/puppet-collectd/compare/v11.4.0...v12.0.0) + +**Breaking changes:** + +- \[collectd\] rename log\_parser to logparser [\#930](https://github.com/voxpupuli/puppet-collectd/pull/930) ([prabiegx](https://github.com/prabiegx)) +- Change all `port` parameters to use `Stdlib::Port` [\#906](https://github.com/voxpupuli/puppet-collectd/pull/906) ([bastelfreak](https://github.com/bastelfreak)) + +**Fixed bugs:** + +- Install disk package if required prior CentOS 8 [\#929](https://github.com/voxpupuli/puppet-collectd/pull/929) ([NikolayTsvetkov](https://github.com/NikolayTsvetkov)) + +## [v11.4.0](https://github.com/voxpupuli/puppet-collectd/tree/v11.4.0) (2020-03-29) [Full Changelog](https://github.com/voxpupuli/puppet-collectd/compare/v11.3.0...v11.4.0) diff --git a/metadata.json b/metadata.json index 21a675870..108704e30 100644 --- a/metadata.json +++ b/metadata.json @@ -61,7 +61,7 @@ } ], "name": "puppet-collectd", - "version": "11.4.1-rc0", + "version": "12.0.0", "source": "https://github.com/voxpupuli/puppet-collectd", "author": "Vox Pupuli", "license": "Apache-2.0", From a556938fa41f1593ec2a57935406d6dfd7a55127 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Sat, 4 Apr 2020 14:00:54 +0200 Subject: [PATCH 36/37] [blacksmith] Bump version to 12.0.1-rc0 --- metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.json b/metadata.json index 108704e30..f4ad4d6f3 100644 --- a/metadata.json +++ b/metadata.json @@ -61,7 +61,7 @@ } ], "name": "puppet-collectd", - "version": "12.0.0", + "version": "12.0.1-rc0", "source": "https://github.com/voxpupuli/puppet-collectd", "author": "Vox Pupuli", "license": "Apache-2.0", From ea4927b61ade90f71e5e1b74fd4a20330e8effb0 Mon Sep 17 00:00:00 2001 From: Ewoud Kohl van Wijngaarden Date: Mon, 6 Apr 2020 23:10:24 +0200 Subject: [PATCH 37/37] Use voxpupuli-acceptance --- .sync.yml | 2 ++ .travis.yml | 20 ++++++++++---------- Gemfile | 22 +--------------------- spec/spec_helper_acceptance.rb | 18 ++---------------- 4 files changed, 15 insertions(+), 47 deletions(-) diff --git a/.sync.yml b/.sync.yml index ff751c806..df969003e 100644 --- a/.sync.yml +++ b/.sync.yml @@ -10,3 +10,5 @@ spec/spec_helper.rb: spec_overrides: "require 'spec_helper_methods'" mock_with: ':mocha' +spec/spec_helper_acceptance.rb: + unmanaged: false diff --git a/.travis.yml b/.travis.yml index a1c8dec16..0128dec15 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,43 +24,43 @@ matrix: env: PUPPET_VERSION="~> 5.0" CHECK=build DEPLOY_TO_FORGE=yes - rvm: 2.5.3 bundler_args: --without development release - env: PUPPET_INSTALL_TYPE=agent BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_debug=true BEAKER_setfile=ubuntu1604-64 BEAKER_HYPERVISOR=docker CHECK=beaker + env: BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_setfile=ubuntu1604-64 CHECK=beaker services: docker - rvm: 2.5.3 bundler_args: --without development release - env: PUPPET_INSTALL_TYPE=agent BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_debug=true BEAKER_setfile=ubuntu1604-64 BEAKER_HYPERVISOR=docker CHECK=beaker + env: BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_setfile=ubuntu1604-64 CHECK=beaker services: docker - rvm: 2.5.3 bundler_args: --without development release - env: PUPPET_INSTALL_TYPE=agent BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_debug=true BEAKER_setfile=ubuntu1804-64 BEAKER_HYPERVISOR=docker CHECK=beaker + env: BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_setfile=ubuntu1804-64 CHECK=beaker services: docker - rvm: 2.5.3 bundler_args: --without development release - env: PUPPET_INSTALL_TYPE=agent BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_debug=true BEAKER_setfile=ubuntu1804-64 BEAKER_HYPERVISOR=docker CHECK=beaker + env: BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_setfile=ubuntu1804-64 CHECK=beaker services: docker - rvm: 2.5.3 bundler_args: --without development release - env: PUPPET_INSTALL_TYPE=agent BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_debug=true BEAKER_setfile=centos7-64 BEAKER_HYPERVISOR=docker CHECK=beaker + env: BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_setfile=centos7-64 CHECK=beaker services: docker - rvm: 2.5.3 bundler_args: --without development release - env: PUPPET_INSTALL_TYPE=agent BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_debug=true BEAKER_setfile=centos7-64 BEAKER_HYPERVISOR=docker CHECK=beaker + env: BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_setfile=centos7-64 CHECK=beaker services: docker - rvm: 2.5.3 bundler_args: --without development release - env: PUPPET_INSTALL_TYPE=agent BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_debug=true BEAKER_setfile=centos8-64 BEAKER_HYPERVISOR=docker CHECK=beaker + env: BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_setfile=centos8-64 CHECK=beaker services: docker - rvm: 2.5.3 bundler_args: --without development release - env: PUPPET_INSTALL_TYPE=agent BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_debug=true BEAKER_setfile=centos8-64 BEAKER_HYPERVISOR=docker CHECK=beaker + env: BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_setfile=centos8-64 CHECK=beaker services: docker - rvm: 2.5.3 bundler_args: --without development release - env: PUPPET_INSTALL_TYPE=agent BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_debug=true BEAKER_setfile=debian8-64 BEAKER_HYPERVISOR=docker CHECK=beaker + env: BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_setfile=debian8-64 CHECK=beaker services: docker - rvm: 2.5.3 bundler_args: --without development release - env: PUPPET_INSTALL_TYPE=agent BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_debug=true BEAKER_setfile=debian8-64 BEAKER_HYPERVISOR=docker CHECK=beaker + env: BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_setfile=debian8-64 CHECK=beaker services: docker branches: only: diff --git a/Gemfile b/Gemfile index 11c85584f..32c311460 100644 --- a/Gemfile +++ b/Gemfile @@ -24,27 +24,7 @@ group :development do end group :system_tests do - gem 'winrm', :require => false - if beaker_version = ENV['BEAKER_VERSION'] - gem 'beaker', *location_for(beaker_version) - else - gem 'beaker', '>= 4.2.0', :require => false - end - if beaker_rspec_version = ENV['BEAKER_RSPEC_VERSION'] - gem 'beaker-rspec', *location_for(beaker_rspec_version) - else - gem 'beaker-rspec', :require => false - end - gem 'serverspec', :require => false - gem 'beaker-hostgenerator', '>= 1.1.22', :require => false - gem 'beaker-docker', :require => false - gem 'beaker-puppet', :require => false - gem 'beaker-puppet_install_helper', :require => false - gem 'beaker-module_install_helper', :require => false - gem 'rbnacl', '>= 4', :require => false - gem 'rbnacl-libsodium', :require => false - gem 'bcrypt_pbkdf', :require => false - gem 'ed25519', :require => false + gem 'voxpupuli-acceptance', :require => false end group :release do diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index 761062375..ffbdaf47d 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -1,17 +1,3 @@ -require 'beaker-rspec' -require 'beaker-puppet' -require 'beaker/puppet_install_helper' -require 'beaker/module_install_helper' +require 'voxpupuli/acceptance/spec_helper_acceptance' -run_puppet_install_helper unless ENV['BEAKER_provision'] == 'no' - -RSpec.configure do |c| - # Readable test descriptions - c.formatter = :documentation - - # Configure all nodes in nodeset - c.before :suite do - install_module - install_module_dependencies - end -end +configure_beaker