Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions collectd/attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

default[:collectd][:base_dir] = "/var/lib/collectd"
default[:collectd][:plugin_dir] = "/usr/lib/collectd"
default[:collectd][:perl_include_dir] = "/usr/local/share/perl/5.10.1"
default[:collectd][:types_db] = ["/usr/share/collectd/types.db"]
default[:collectd][:interval] = 10
default[:collectd][:read_threads] = 5
Expand Down
23 changes: 20 additions & 3 deletions collectd/definitions/collectd_plugin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@
end
end

define :collectd_python_plugin, :options => {}, :module => nil, :path => nil do
define :collectd_python_plugin, :options => {}, :mod => nil, :path => nil do
begin
t = resources(:template => "/etc/collectd/plugins/python.conf")
rescue ArgumentError
rescue Chef::Exceptions::ResourceNotFound
collectd_plugin "python" do
options :paths=>[node[:collectd][:plugin_dir]], :modules=>{}
template "python_plugin.conf.erb"
Expand All @@ -48,5 +48,22 @@
if not params[:path].blank?
t.variables[:options][:paths] << params[:path]
end
t.variables[:options][:modules][params[:module] || params[:name]] = params[:options]
t.variables[:options][:modules][params[:mod] || params[:name]] = params[:options]
end

define :collectd_perl_plugin, :options => {}, :mod => nil, :include_dir => nil do
begin
t = resources(:template => "/etc/collectd/plugins/perl.conf")
rescue Chef::Exceptions::ResourceNotFound
collectd_plugin "perl" do
options :include_dir=>[node[:collectd][:perl_include_dir]], :modules=>{}
template "perl_plugin.conf.erb"
cookbook "collectd"
end
retry
end
if not params[:include_dir].nil?
t.variables[:options][:include_dir] << params[:include_dir]
end
t.variables[:options][:modules][params[:mod] || params[:name]] = params[:options]
end
21 changes: 21 additions & 0 deletions collectd/templates/default/perl_plugin.conf.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# This file autogenerated by Chef
# Do not edit, changes will be overwritten
<LoadPlugin perl>
Globals true
</LoadPlugin>

<Plugin perl>
<% @options[:include_dir].each do |path| %>
IncludeDir "<%= path %>"
<% end %>
BaseName "Collectd::Plugins"
<% @options[:modules].each_key do |mod| %>
LoadPlugin "<%= mod %>"
<% end %>

<% @options[:modules].each_pair do |mod, config| %>
<Plugin "<%= mod %>">
<%= collectd_settings(config, 2) %>
</Plugin>
<% end %>
</Plugin>