2 # Cookbook Name:: munin
3 # Definition:: munin_plugin
5 # Copyright 2010, OpenStreetMap Foundation
7 # Licensed under the Apache License, Version 2.0 (the "License");
8 # you may not use this file except in compliance with the License.
9 # You may obtain a copy of the License at
11 # http://www.apache.org/licenses/LICENSE-2.0
13 # Unless required by applicable law or agreed to in writing, software
14 # distributed under the License is distributed on an "AS IS" BASIS,
15 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 # See the License for the specific language governing permissions and
17 # limitations under the License.
20 define :munin_plugin, :action => :create do
21 target = params[:target] || params[:name]
23 if File.exists?(target)
25 elsif File.exists?("/usr/local/share/munin/plugins/#{target}")
26 target_path = "/usr/local/share/munin/plugins/#{target}"
27 elsif File.exists?("/usr/share/munin/plugins/#{target}")
28 target_path = "/usr/share/munin/plugins/#{target}"
33 if target_path.nil? or params[:action] == :delete
34 link "/etc/munin/plugins/#{params[:name]}" do
38 link "/etc/munin/plugins/#{params[:name]}" do
39 action params[:action]
41 notifies :restart, resources(:service => "munin-node")
46 conf_template = params[:conf]
47 conf_cookbook = params[:conf_cookbook]
48 conf_variables = params[:conf_variables]
50 munin_plugin_conf params[:name] do
51 action params[:action]
52 template conf_template
54 cookbook conf_cookbook
57 variables conf_variables