Permalink
Browse files

Moved monit status code from site model to monit module

  • Loading branch information...
1 parent 52b4045 commit 07208932393029eabc10c2c760e37e61370cdb34 @dce dce committed Oct 23, 2009
Showing with 11 additions and 11 deletions.
  1. +10 −1 app/models/monit.rb
  2. +0 −9 app/models/site.rb
  3. +1 −1 app/views/index.rb
View
@@ -1,7 +1,16 @@
module Monit
extend self
-
+
def reload
system "#{File.join(settings(:monit_bin_dir), 'monit')} #{settings(:monit_cli_options)} reload"
end
+
+ def statuses
+ output = `monit summary `.scan(/Remote Host '.*_(\d+)'[ ]*(.*)$/)
+
+ output.inject({}) do |coll, (site_id, status)|
+ coll[site_id.to_i] = (status == "online with all services" ? "success" : "fail")
+ coll
+ end
+ end
end
View
@@ -35,15 +35,6 @@ def self.http_url
validates_format_of :email, :with => Regex.email, :allow_nil => true
validates_format_of :url, :with => Regex.http_url, :allow_nil => true
- def self.statuses
- output = `monit summary `.scan(/Remote Host '.*_(\d+)'[ ]*(.*)$/)
-
- output.inject({}) do |coll, (site_id, status)|
- coll[site_id.to_i] = (status == "online with all services" ? "success" : "fail")
- coll
- end
- end
-
def host
URI.parse(url).host
end
View
@@ -4,7 +4,7 @@ class Index < Mustache
include Main::Helpers::AppHelper
def sites
- summaries = Site.statuses
+ summaries = Monit.statuses
Site.all.map do |site|
{

0 comments on commit 0720893

Please sign in to comment.