ruby sensu_standalone_check.rb

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ruby sensu_standalone_check.rb相关的知识,希望对你有一定的参考价值。

# 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

以上是关于ruby sensu_standalone_check.rb的主要内容,如果未能解决你的问题,请参考以下文章

Ruby 25 岁了!Ruby 之父说 Ruby 3 有望 3 倍提速

如何学习ruby?Ruby学习技巧分享

ruby Ruby脚本,看看是否用openssl编译了ruby

什么是ruby?

ruby和ruby ee

ruby入门知识:了解ruby历史及特性