Skip to content

Commit

Permalink
Merge pull request #666 from bodgit/redis
Browse files Browse the repository at this point in the history
Install Redis plugin package if needed
  • Loading branch information
oranenj authored Jul 19, 2017
2 parents 09978f6 + ba1de0c commit c4bb4e3
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 13 deletions.
27 changes: 18 additions & 9 deletions manifests/plugin/redis.pp
Original file line number Diff line number Diff line change
@@ -1,25 +1,34 @@
# https://collectd.org/wiki/index.php/Plugin:Redis
class collectd::plugin::redis (
$ensure = 'present',
$interval = undef,
$nodes = {
Enum['present', 'absent'] $ensure = 'present',
Optional[Integer[0]] $interval = undef,
Optional[Boolean] $manage_package = undef,
Hash[String[1], Collectd::Redis::Node] $nodes = {
'redis' => {
'host' => 'localhost',
'port' => '6379',
'port' => 6379,
'timeout' => 2000,
'queries' => {
'dbsize' => {
'type' => 'count',
'query' => 'DBSIZE',
},
'dbsize' => {
'type' => 'count',
'query' => 'DBSIZE',
},
},
},
},
) {

include ::collectd

validate_hash($nodes)
$_manage_package = pick($manage_package, $::collectd::manage_package)

if $::osfamily == 'RedHat' {
if $_manage_package {
package { 'collectd-redis':
ensure => $ensure,
}
}
}

collectd::plugin { 'redis':
ensure => $ensure,
Expand Down
8 changes: 4 additions & 4 deletions templates/plugin/redis.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
<% if params['password'] -%>
Password "<%= params['password'] %>"
<% end -%>
<% if params['queries'] -%>
<% params['queries'].each do |instance,qparams| -%>
<% if params['queries'] -%>
<% params['queries'].each do |instance,qparams| -%>
<Query "<%= qparams['query'] -%>">
Type "<%= qparams['type'] -%>"
Instance "<%= instance -%>"
</Query>
<% end -%>
<% end -%>
<% end -%>
<% end -%>
</Node>
<% end -%>
</Plugin>
Expand Down
2 changes: 2 additions & 0 deletions types/redis/node.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#
type Collectd::Redis::Node = Struct[{Optional['host'] => String[1], Optional['port'] => Variant[Integer[0, 65535], String[1]], Optional['password'] => String[1], Optional['timeout'] => Integer[0], Optional['queries'] => Hash[String[1], Hash[String[1], String[1]]]}]

0 comments on commit c4bb4e3

Please sign in to comment.