Skip to content

Instantly share code, notes, and snippets.

@grantr
Created July 13, 2012 19:32
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save grantr/3106886 to your computer and use it in GitHub Desktop.
Save grantr/3106886 to your computer and use it in GitHub Desktop.
standalone sensu check chef definition
# 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