Module: Blue::Monit

Defined in:
lib/blue/monit.rb,
lib/blue/monit/version.rb

Constant Summary collapse

VERSION =
"0.0.4"

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.configureObject



8
9
10
11
12
# File 'lib/blue/monit.rb', line 8

def self.configure
  Blue.configure({
    :monit => {}
  })
end

.included(klass) ⇒ Object



53
54
55
56
57
58
# File 'lib/blue/monit.rb', line 53

def self.included(klass)
  klass.add_role(:monit)
  klass.class_eval do
    recipe :monit
  end
end

Instance Method Details

#monit(options = {}) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/blue/monit.rb', line 14

def monit(options = {})
  package 'monit',
    :ensure => :installed

  service 'monit',
    :ensure => :running,
    :require => package('monit')

  file "/etc/monit/monitrc",
    :ensure  => :present,
    :owner   => 'root',
    :group   => 'root',
    :mode    => '600',
    :backup  => false,
    :content => template(File.join(File.dirname(__FILE__), '..', '..', 'templates', 'monitrc.erb'), binding),
    :notify  => service('monit')

  # get all files in config/monit that match the current host name
  # drop them in /etc/monit/conf.d/ which is included by /etc/monit/monitrc
  Dir.glob(File.join(Blue.rails_root, "config/monit/*")).
    map{|filename| Pathname.new(filename)}.
    select{|pathname| roles.any?{|r| pathname.basename.to_s.match(r.to_s)}}.
    each do |pathname|
      file "/etc/monit/conf.d/#{pathname.basename.to_s.gsub(".erb","")}",
        :ensure  => :present,
        :mode    => '700',
        :backup  => false,
        :content => template(File.join(Blue.rails_root, 'config', 'monit', pathname.basename), binding),
        :notify  => service('monit')
    end

  file "/etc/monit/conf.d/default.conf",
    :ensure  => :present,
    :mode    => '700',
    :backup  => false,
    :content => template(File.join(File.dirname(__FILE__), '..', '..', 'templates', 'default.conf.erb'), binding),
    :notify  => service('monit')
end