Class: SystemdMon::Notifiers::Hipchat

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

Instance Method Summary collapse

Methods inherited from Base

#debug, #log

Constructor Details

#initializeHipchat



12
13
14
15
16
17
# File 'lib/systemd_mon/notifiers/hipchat.rb', line 12

def initialize(*)
  super
  self.client = ::HipChat::Client.new(
      options['token'],
      :api_version => 'v2')
end

Instance Method Details

#notify!(notification) ⇒ Object



29
30
31
32
33
34
35
36
37
# File 'lib/systemd_mon/notifiers/hipchat.rb', line 29

def notify!(notification)
  unit = notification.unit
  message = "#{notification.type_text}: systemd unit #{unit.name} on #{notification.hostname} #{unit.state_change.status_text}: #{unit.state.active} (#{unit.state.sub})"

  chat message,
       color(notification.type)

  log "sent hipchat notification"
end

#notify_start!(hostname) ⇒ Object



19
20
21
22
# File 'lib/systemd_mon/notifiers/hipchat.rb', line 19

def notify_start!(hostname)
  chat "SystemdMon is starting on #{hostname}",
       'green'
end

#notify_stop!(hostname) ⇒ Object



24
25
26
27
# File 'lib/systemd_mon/notifiers/hipchat.rb', line 24

def notify_stop!(hostname)
  chat "SystemdMon is stopping on #{hostname}",
       'yellow'
end