Skip to content

Commit

Permalink
add support for aggregation plugin and chains
Browse files Browse the repository at this point in the history
  • Loading branch information
kurpipio committed Jul 12, 2015
1 parent 85e230c commit f3eaad2
Show file tree
Hide file tree
Showing 6 changed files with 208 additions and 0 deletions.
60 changes: 60 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,11 @@ Configurable Plugins
Parameters will vary widely between plugins. See the collectd
documentation for each plugin for configurable attributes.

* `aggregation` (see [collectd::plugin::aggregation](#class-collectdpluginaggregation) below)
* `amqp` (see [collectd::plugin::amqp](#class-collectdpluginamqp) below)
* `apache` (see [collectd::plugin::apache](#class-collectdpluginapache) below)
* `bind` (see [collectd::plugin::bind](#class-collectdpluginbind) below)
* `chain` (see [collectd::plugin::chain](#class-chain) below)
* `conntrack` (see [collectd::plugin::conntrack](#class-conntrack) below)
* `cpu` (see [collectd::plugin::cpu](#class-collectdplugincpu) below)
* `cpufreq` (see [collectd::plugin::cpufreq](#class-collectdplugincpufreq) below)
Expand Down Expand Up @@ -114,6 +116,33 @@ documentation for each plugin for configurable attributes.
* `write_riemann` (see [collectd::plugin::write_riemann](#class-collectdpluginwrite_riemann) below)
* `zfs_arc` (see [collectd::plugin::zfs_arc](#class-collectdpluginzfs_arc) below)

####Class: `collectd::plugin::aggregation`

```puppet
collectd::plugin::aggregation::aggregator {
cpu':
plugin => 'cpu',
type => 'cpu',
groupby => ["Host", "TypeInstance",],
calculateaverage => true,
}
```

You can as well configure this plugin with a parameterized class :

```puppet
class { 'collectd::plugin::aggregation':
aggregators => {
cpu' => {
plugin => 'cpu',
type => 'cpu',
groupby => ["Host", "TypeInstance",],
calculateaverage => true,
},
},
}
```

####Class: `collectd::plugin::amqp`

```puppet
Expand Down Expand Up @@ -148,6 +177,37 @@ class { 'collectd::plugin::bind':
}
```

####Class: `collectd::plugin::chain`

```puppet
class { 'collectd::plugin::chain':
chainname => "PostCache",
defaulttarget => "write",
rules => [
{
'match' => {
'type' => 'regex',
'matches' => {
'Plugin' => "^cpu$",
'PluginInstance' => "^[0-9]+$",
},
},
'targets' => [
{
'type' => "write",
'attributes' => {
"Plugin" => "aggregation",
},
},
{
'type' => "stop",
},
],
},
],
}
```

####Class: `collectd::plugin::conntrack`

```puppet
Expand Down
16 changes: 16 additions & 0 deletions manifests/plugin/aggregation.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#
class collectd::plugin::aggregation (
$ensure = present,
$interval = undef,
$aggregators = { },
) {

collectd::plugin {'aggregation':
ensure => $ensure,
interval => $interval,
}
$defaults = {
'ensure' => $ensure
}
create_resources(collectd::plugin::aggregation::aggregator, $aggregators, $defaults)
}
34 changes: 34 additions & 0 deletions manifests/plugin/aggregation/aggregator.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#
define collectd::plugin::aggregation::aggregator (
$ensure = 'present',
$host = undef,
$plugin = undef,
$plugininstance = undef,
$type = undef,
$typeinstance = undef,
$sethost = undef,
$setplugin = undef,
$setplugininstance = undef,
$settypeinstance = undef,
$groupby = [],
$calculatesum = undef,
$calculatenum = undef,
$calculateaverage = undef,
$calculateminimum = undef,
$calculatemaximum = undef,
$calculatestddev = undef,
) {
include collectd::params
include collectd::plugin::aggregation

$conf_dir = $collectd::params::plugin_conf_dir

file { "${conf_dir}/aggregator-${name}.conf":
ensure => $ensure,
mode => '0640',
owner => 'root',
group => $collectd::params::root_group,
content => template('collectd/plugin/aggregation-aggregator.conf.erb'),
notify => Service['collectd'],
}
}
20 changes: 20 additions & 0 deletions manifests/plugin/chain.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#
class collectd::plugin::chain (
$chainname = "Main",
$ensure = 'present',
$defaulttarget = "write",
$rules = []
) {
include collectd::params

$conf_dir = $collectd::params::plugin_conf_dir

file { "${conf_dir}/99-chain-${chainname}.conf":
ensure => $ensure,
mode => '0640',
owner => 'root',
group => $collectd::params::root_group,
content => template('collectd/plugin/chain.conf.erb'),
notify => Service['collectd'],
}
}
55 changes: 55 additions & 0 deletions templates/plugin/aggregation-aggregator.conf.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<Plugin "aggregation">
<Aggregation>
<% unless @host.nil? -%>
Host "<%= @host %>"
<% end -%>
<% unless @plugin.nil? -%>
Plugin "<%= @plugin %>"
<% end -%>
<% unless @plugininstance.nil? -%>
PluginInstance "<%= @plugininstance %>"
<% end -%>
<% unless @type.nil? -%>
Type "<%= @type %>"
<% end -%>
<% unless @typeinstance.nil? -%>
TypeInstance "<%= @typeinstance %>"
<% end -%>

<% unless @sethost.nil? -%>
SetHost "<%= @sethost %>"
<% end -%>
<% unless @setplugin.nil? -%>
SetPlugin "<%= @setplugin %>"
<% end -%>
<% unless @setplugininstance.nil? -%>
SetPluginInstance "<%= @setplugininstance %>"
<% end -%>
<% unless @settypeinstance.nil? -%>
SetTypeInstance "<%= @settypeinstance %>"
<% end -%>

<% @groupby.each do |groupby| -%>
GroupBy "<%= groupby %>"
<% end -%>

<% unless @calculatesum.nil? -%>
CalculateSum <%= @calculatesum %>
<% end -%>
<% unless @calculatenum.nil? -%>
CalculateNum <%= @calculatenum %>
<% end -%>
<% unless @calculateaverage.nil? -%>
CalculateAverage <%= @calculateaverage %>
<% end -%>
<% unless @calculateminimum.nil? -%>
CalculateMinimum <%= @calculateminimum %>
<% end -%>
<% unless @calculatemaximum.nil? -%>
CalculateMaximum <%= @calculatemaximum %>
<% end -%>
<% unless @calculatestddev.nil? -%>
CalculateStddev <%= @calculatestddev %>
<% end -%>
</Aggregation>
</Plugin>
23 changes: 23 additions & 0 deletions templates/plugin/chain.conf.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<Chain "<%= @chainname %>">
<% @rules.each do |rule| -%>
<Rule>
<Match "<%= rule['match']['type'] %>">
<% rule['match']["matches"].each do |key, value| -%>
<%= key %> "<%= value %>"
<% end -%>
</Match>
<% rule['targets'].each do |target| -%>
<% if target['attributes'].nil? -%>
Target "<%= target['type'] %>"
<% else -%>
<Target "<%= target['type'] %>">
<% target['attributes'].each do |key, value| -%>
<%= key %> "<%= value %>"
<% end -%>
</Target>
<% end -%>
<% end -%>
</Rule>
<% end -%>
Target "<%= @defaulttarget %>"
</Chain>

0 comments on commit f3eaad2

Please sign in to comment.