From 51ea4a1e22e23c83f16b578cdd2030185ee1e5c6 Mon Sep 17 00:00:00 2001 From: Piotr Rabiega Date: Fri, 7 Feb 2020 13:51:16 +0100 Subject: [PATCH] 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 %>" +<% } -%> +