Skip to content

Commit a1901fb

Browse files
committed
Merge pull request #279 from throck/master
add support for protocols plugin
2 parents a6c102b + 67af5f9 commit a1901fb

4 files changed

Lines changed: 95 additions & 0 deletions

File tree

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ documentation for each plugin for configurable attributes.
9090
* `ping` (see [collectd::plugin::ping](#class-collectdpluginping) below)
9191
* `postgresql` (see [collectd::plugin::postgresql](#class-collectdpluginpostgresql) below)
9292
* `processes` (see [collectd::plugin:processes](#class-collectdpluginprocesses) below)
93+
* `protocols` (see [collectd::plugin:protocols](#class-collectdpluginprotocols) below)
9394
* `python` (see [collectd::plugin::python](#class-collectdpluginpython) below)
9495
* `redis` (see [collectd::plugin::redis](#class-collectdpluginredis) below)
9596
* `rrdcached` (see [collectd::plugin::rrdcached](#class-collectdpluginrrdcached) below)
@@ -656,6 +657,19 @@ class { 'collectd::plugin::processes':
656657
],
657658
}
658659
```
660+
####Class: `collectd::plugin::protocols`
661+
662+
* `values` is an array of `Protocol` names, `Protocol:ValueName` pairs, or a regex
663+
* see `/proc/net/netstat` and `/proc/net/snmp` for a list of `Protocol` targets
664+
665+
See [collectd.conf documentation] (https://collectd.org/documentation/manpages/collectd.conf.5.shtml#plugin_protocols) for details
666+
667+
```puppet
668+
class { 'collectd::plugin::protocols':
669+
values => ['/^Tcp:*/', '/^Udp:*/', 'Icmp:InErrors' ],
670+
ignoreselected => false,
671+
}
672+
```
659673

660674
####Class: `collectd::plugin::python`
661675

manifests/plugin/protocols.pp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# See http://collectd.org/documentation/manpages/collectd.conf.5.shtml#plugin_protocols
2+
class collectd::plugin::protocols (
3+
$ensure = present,
4+
$ignoreselected = false,
5+
$values = []
6+
) {
7+
8+
validate_array(
9+
$values,
10+
)
11+
validate_bool(
12+
$ignoreselected,
13+
)
14+
15+
collectd::plugin {'protocols':
16+
ensure => $ensure,
17+
content => template('collectd/plugin/protocols.conf.erb'),
18+
}
19+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
require 'spec_helper'
2+
3+
describe 'collectd::plugin::protocols', :type => :class do
4+
let :facts do
5+
{:osfamily => 'RedHat'}
6+
end
7+
8+
context ':ensure => present, default params' do
9+
it 'Will create /etc/collectd.d/10-protocols.conf' do
10+
should contain_file('protocols.load').with({
11+
:ensure => 'present',
12+
:path => '/etc/collectd.d/10-protocols.conf',
13+
:content => //,
14+
})
15+
end
16+
end
17+
18+
context ':ensure => present, specific params' do
19+
let :params do
20+
{ :values => [ 'protocol1', 'protocol2' ],
21+
}
22+
end
23+
24+
it 'Will create /etc/collectd.d/10-protocols.conf' do
25+
should contain_file('protocols.load').with({
26+
:ensure => 'present',
27+
:path => '/etc/collectd.d/10-protocols.conf',
28+
:content => /<Plugin "protocols">\n\s*Value "protocol1"\n\s*Value "protocol2"\n<\/Plugin>/,
29+
})
30+
end
31+
end
32+
33+
context ':ensure => absent' do
34+
let :params do
35+
{:ensure => 'absent'}
36+
end
37+
38+
it 'Will not create /etc/collectd.d/10-protocols.conf' do
39+
should contain_file('protocols.load').with({
40+
:ensure => 'absent',
41+
:path => '/etc/collectd.d/10-protocols.conf',
42+
})
43+
end
44+
end
45+
end
46+
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<% if @values -%>
2+
<Plugin "protocols">
3+
<%
4+
if @values
5+
@values.each do |value|
6+
-%>
7+
Value "<%= value %>"
8+
<%
9+
end
10+
end
11+
-%>
12+
<% if @ignore_selected != nil -%>
13+
IgnoreSelected <%= @ignore_selected %>
14+
<% end -%>
15+
</Plugin>
16+
<% end -%>

0 commit comments

Comments
 (0)