Created
July 13, 2012 19:32
-
-
Save grantr/3106886 to your computer and use it in GitHub Desktop.
standalone sensu check chef definition
This file contains hidden or 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
# installs a standalone sensu check | |
# sensu_standalone_check "unicorn_master" do | |
# command "#{node.sensu.directory}/plugins/processes/check-procs.rb" | |
# arguments "-f #{deploy_to}/shared/pids/unicorn.pid" | |
# end | |
define :sensu_standalone_check, :interval => 60, :enable => true, :owner => "root", :mode => 0644 do | |
include_recipe "sensu::_config" | |
if params[:enable] | |
command = params[:command] || File.join(node.sensu.directory, "plugins", params[:plugin]) | |
command << " " << params[:arguments] if params[:arguments] | |
check_params = params.dup | |
[:enable, :plugin, :arguments, :name].each { |k| check_params.delete(k) } | |
check_params[:standalone] = true | |
file File.join(node.sensu.directory, "conf.d", "#{params[:name]}.json") do | |
content JSON.pretty_generate({ "checks" => { params[:name] => check_params }}) | |
mode params[:mode] | |
owner params[:owner] | |
notifies :updated, resources(:sensu_config => node.name), :immediately | |
end | |
else | |
file File.join(node.sensu.directory, "conf.d", "#{params[:name]}.json") do | |
action :delete | |
notifies :updated, resources(:sensu_config => node.name), :immediately | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment