From 242f49b0f110a8ee94c245584be64826434a5ba6 Mon Sep 17 00:00:00 2001 From: Robby Grossman Date: Wed, 8 Aug 2012 10:39:03 -0400 Subject: [PATCH] Add a monit recipe to monitor and restart riak, for use in conjunction with the monit cookbook. Monit implementation has its own recipe, so it will not affect any nodes that do not specifically add it to their run list. --- attributes/monit.rb | 4 ++++ recipes/monit.rb | 14 ++++++++++++++ templates/default/riak-monit.conf.erb | 7 +++++++ 3 files changed, 25 insertions(+) create mode 100644 attributes/monit.rb create mode 100644 recipes/monit.rb create mode 100644 templates/default/riak-monit.conf.erb diff --git a/attributes/monit.rb b/attributes/monit.rb new file mode 100644 index 0000000..6bbfa04 --- /dev/null +++ b/attributes/monit.rb @@ -0,0 +1,4 @@ +default.riak.monit.process_matching = "/usr/lib/riak/erts-5.8.5/bin/beam.smp" +default.riak.monit.start_program = "/usr/sbin/riak" +default.riak.monit.http_host = "localhost" +default.riak.monit.http_port = "8098" diff --git a/recipes/monit.rb b/recipes/monit.rb new file mode 100644 index 0000000..492839e --- /dev/null +++ b/recipes/monit.rb @@ -0,0 +1,14 @@ +# This is an optional recipe that provides monit monitoring of your riak node. Requires the monit cookbook. + +include_recipe "monit::default" + +monitrc "riak" do + variables( + :process_matching => node[:riak][:monit][:process_matching], + :start_program => node[:riak][:monit][:start_program], + :http_host => node[:riak][:monit][:http_host], + :http_port => node[:riak][:monit][:http_port] + ) + template_source "riak-monit.conf.erb" + template_cookbook "riak" +end diff --git a/templates/default/riak-monit.conf.erb b/templates/default/riak-monit.conf.erb new file mode 100644 index 0000000..a2fca41 --- /dev/null +++ b/templates/default/riak-monit.conf.erb @@ -0,0 +1,7 @@ +check process riak matching "<%= @process_matching %>" + group riak + start program = "<%= @start_program %>" + if failed host <%= @http_host %> port <%= @http_port %> protocol http + and request "/" + with timeout 2 seconds for 2 cycles + then restart \ No newline at end of file