Skip to content

Commit

Permalink
Merge pull request #279 from throck/master
Browse files Browse the repository at this point in the history
add support for protocols plugin
  • Loading branch information
blkperl committed Jun 19, 2015
2 parents a6c102b + 67af5f9 commit a1901fb
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 0 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ documentation for each plugin for configurable attributes.
* `ping` (see [collectd::plugin::ping](#class-collectdpluginping) below)
* `postgresql` (see [collectd::plugin::postgresql](#class-collectdpluginpostgresql) below)
* `processes` (see [collectd::plugin:processes](#class-collectdpluginprocesses) below)
* `protocols` (see [collectd::plugin:protocols](#class-collectdpluginprotocols) below)
* `python` (see [collectd::plugin::python](#class-collectdpluginpython) below)
* `redis` (see [collectd::plugin::redis](#class-collectdpluginredis) below)
* `rrdcached` (see [collectd::plugin::rrdcached](#class-collectdpluginrrdcached) below)
Expand Down Expand Up @@ -656,6 +657,19 @@ class { 'collectd::plugin::processes':
],
}
```
####Class: `collectd::plugin::protocols`

* `values` is an array of `Protocol` names, `Protocol:ValueName` pairs, or a regex
* see `/proc/net/netstat` and `/proc/net/snmp` for a list of `Protocol` targets

See [collectd.conf documentation] (https://collectd.org/documentation/manpages/collectd.conf.5.shtml#plugin_protocols) for details

```puppet
class { 'collectd::plugin::protocols':
values => ['/^Tcp:*/', '/^Udp:*/', 'Icmp:InErrors' ],
ignoreselected => false,
}
```

####Class: `collectd::plugin::python`

Expand Down
19 changes: 19 additions & 0 deletions manifests/plugin/protocols.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# See http://collectd.org/documentation/manpages/collectd.conf.5.shtml#plugin_protocols
class collectd::plugin::protocols (
$ensure = present,
$ignoreselected = false,
$values = []
) {

validate_array(
$values,
)
validate_bool(
$ignoreselected,
)

collectd::plugin {'protocols':
ensure => $ensure,
content => template('collectd/plugin/protocols.conf.erb'),
}
}
46 changes: 46 additions & 0 deletions spec/classes/collectd_plugin_protocols_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
require 'spec_helper'

describe 'collectd::plugin::protocols', :type => :class do
let :facts do
{:osfamily => 'RedHat'}
end

context ':ensure => present, default params' do
it 'Will create /etc/collectd.d/10-protocols.conf' do
should contain_file('protocols.load').with({
:ensure => 'present',
:path => '/etc/collectd.d/10-protocols.conf',
:content => //,
})
end
end

context ':ensure => present, specific params' do
let :params do
{ :values => [ 'protocol1', 'protocol2' ],
}
end

it 'Will create /etc/collectd.d/10-protocols.conf' do
should contain_file('protocols.load').with({
:ensure => 'present',
:path => '/etc/collectd.d/10-protocols.conf',
:content => /<Plugin "protocols">\n\s*Value "protocol1"\n\s*Value "protocol2"\n<\/Plugin>/,
})
end
end

context ':ensure => absent' do
let :params do
{:ensure => 'absent'}
end

it 'Will not create /etc/collectd.d/10-protocols.conf' do
should contain_file('protocols.load').with({
:ensure => 'absent',
:path => '/etc/collectd.d/10-protocols.conf',
})
end
end
end

16 changes: 16 additions & 0 deletions templates/plugin/protocols.conf.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<% if @values -%>
<Plugin "protocols">
<%
if @values
@values.each do |value|
-%>
Value "<%= value %>"
<%
end
end
-%>
<% if @ignore_selected != nil -%>
IgnoreSelected <%= @ignore_selected %>
<% end -%>
</Plugin>
<% end -%>

0 comments on commit a1901fb

Please sign in to comment.