Skip to content

Commit

Permalink
Merge pull request voxpupuli#913 from prabiegx/collectd_dpdk_telemetry
Browse files Browse the repository at this point in the history
Add dpdk_telemetry plugin
  • Loading branch information
bastelfreak authored Mar 4, 2020
2 parents 35b7811 + 51ea4a1 commit 6d74352
Show file tree
Hide file tree
Showing 4 changed files with 127 additions and 0 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
28 changes: 28 additions & 0 deletions manifests/plugin/dpdk_telemetry.pp
Original file line number Diff line number Diff line change
@@ -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'),
}
}
81 changes: 81 additions & 0 deletions spec/classes/collectd_plugin_dpdk_telemetry_spec.rb
Original file line number Diff line number Diff line change
@@ -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 = <<EOS
# Generated by Puppet
<LoadPlugin dpdk_telemetry>
Globals false
</LoadPlugin>
<Plugin dpdk_telemetry>
ClientSocketPath "/var/run/.client"
DpdkSocketPath "/var/run/dpdk/rte/telemetry"
</Plugin>
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
8 changes: 8 additions & 0 deletions templates/plugin/dpdk_telemetry.conf.epp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Plugin dpdk_telemetry>
<% 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 %>"
<% } -%>
</Plugin>

0 comments on commit 6d74352

Please sign in to comment.