Class: SystemdMon::Notifiers::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/systemd_mon/notifiers/base.rb

Direct Known Subclasses

Email, Hipchat, Slack

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Base

Returns a new instance of Base.



5
6
7
8
# File 'lib/systemd_mon/notifiers/base.rb', line 5

def initialize(options)
  self.options = options
  self.me      = self.class.name
end

Instance Method Details

#debug(message = nil, &blk) ⇒ Object



31
32
33
34
# File 'lib/systemd_mon/notifiers/base.rb', line 31

def debug(message = nil, &blk)
  message = "#{me}: #{message}" if message
  SystemdMon::Logger.debug message, &blk
end

#log(message) ⇒ Object

Subclasses can choose to do something when SystemdMon stops E.g. with

def notify_stop!(hostname) end



27
28
29
# File 'lib/systemd_mon/notifiers/base.rb', line 27

def log(message)
  SystemdMon::Logger.puts "#{me}: #{message}"
end

#notify!(notification) ⇒ Object

Subclasses must respond to a unit change



11
12
13
# File 'lib/systemd_mon/notifiers/base.rb', line 11

def notify!(notification)
  raise "Notifier #{self.class} does not respond to notify!"
end