forked from redhat-openstack/openstack-puppet-modules
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request redhat-openstack#278 from bzed/process_processmatc…
…h_concat Use concat to define the process plugin config.
- Loading branch information
Showing
7 changed files
with
149 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
lib/puppet/parser/functions/collectd_convert_processmatch.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
module Puppet::Parser::Functions | ||
|
||
newfunction(:collectd_convert_processmatch, :type => :rvalue, :arity => 1, :doc => <<-ENDDOC | ||
Converts the array from the old style to define process matches in the | ||
processes plugin into a create_resources compatible hash which | ||
can be used with the new style define. | ||
Example: | ||
[ { 'name' => 'foo', 'regex' => '.*' } , { 'name' => 'bar', 'regex' => '[0-9]+' } ] | ||
will be converted to | ||
{ 'foo' => { 'regex' => '.*' } , 'bar' => { 'regex' => '[0-9]+' } } | ||
ENDDOC | ||
) do |args| | ||
if args.size != 1 then | ||
raise(Puppet::ParseError, "convert_process_match_array(): Needs exactly one argument") | ||
end | ||
|
||
parray = args[0] | ||
unless parray.is_a?(Array) | ||
raise(Puppet::ParseError, "convert_process_match_array(): Needs an array as argument") | ||
end | ||
|
||
phash = Hash.new | ||
|
||
parray.each do |p| | ||
phash[p['name']] = { 'regex' => p['regex'] } | ||
end | ||
|
||
return phash | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,55 @@ | ||
# See http://collectd.org/documentation/manpages/collectd.conf.5.shtml#plugin_processes | ||
class collectd::plugin::processes ( | ||
$ensure = present, | ||
$order = 10, | ||
$interval = undef, | ||
$processes = undef, | ||
$process_matches = undef, | ||
) { | ||
if $processes { validate_array($processes) } | ||
if $process_matches { validate_array($process_matches) } | ||
|
||
include collectd::params | ||
|
||
collectd::plugin {'processes': | ||
ensure => $ensure, | ||
content => template('collectd/plugin/processes.conf.erb'), | ||
order => $order, | ||
interval => $interval, | ||
} | ||
|
||
concat{"${collectd::params::plugin_conf_dir}/processes-config.conf": | ||
ensure => $ensure, | ||
mode => '0640', | ||
owner => 'root', | ||
group => $collectd::params::root_group, | ||
notify => Service['collectd'], | ||
ensure_newline => true, | ||
} | ||
concat::fragment{'collectd_plugin_processes_conf_header': | ||
ensure => $ensure, | ||
order => '00', | ||
content => '<Plugin processes>', | ||
target => "${collectd::params::plugin_conf_dir}/processes-config.conf", | ||
} | ||
concat::fragment{'collectd_plugin_processes_conf_footer': | ||
ensure => $ensure, | ||
order => '99', | ||
content => '</Plugin>', | ||
target => "${collectd::params::plugin_conf_dir}/processes-config.conf", | ||
} | ||
|
||
|
||
if $processes { | ||
collectd::plugin::processes::process { $processes : } | ||
} | ||
if $process_matches { | ||
$process_matches_resources = collectd_convert_processmatch($process_matches) | ||
$defaults = { 'ensure' => $ensure } | ||
create_resources( | ||
collectd::plugin::processes::processmatch, | ||
$process_matches_resources, | ||
$defaults | ||
) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
define collectd::plugin::processes::process ( | ||
$process = $name, | ||
$ensure = 'present' | ||
){ | ||
|
||
include collectd::plugin::processes | ||
include collectd::params | ||
|
||
concat::fragment{"collectd_plugin_processes_conf_process_${process}": | ||
ensure => $ensure, | ||
order => '50', | ||
content => "Process \"${process}\"\n", | ||
target => "${collectd::params::plugin_conf_dir}/processes-config.conf" | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
define collectd::plugin::processes::processmatch ( | ||
$regex, | ||
$ensure = 'present', | ||
$matchname = $name | ||
){ | ||
|
||
include collectd::plugin::processes | ||
include collectd::params | ||
|
||
concat::fragment{"collectd_plugin_processes_conf_processmatch_${matchname}": | ||
ensure => $ensure, | ||
order => '51', | ||
content => "ProcessMatch \"${matchname}\" \"${regex}\"\n", | ||
target => "${collectd::params::plugin_conf_dir}/processes-config.conf" | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.