Class: Malsh::Notification::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/malsh/notification/base.rb

Direct Known Subclasses

Slack

Class Method Summary collapse

Class Method Details

.doit?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/malsh/notification/base.rb', line 22

def self.doit?
  true
end

.notify_alert(subject, alerts) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/malsh/notification/base.rb', line 10

def self.notify_alert(subject, alerts)
  puts "#{subject}: "
  alerts.each do |alert|
    title = if Malsh.alert_has_host?(alert)
              alert.host.name
            else
              alert.monitor.name
            end
    puts "#{title}: #{alert.message}"
  end
end

.notify_host(subject, hosts) ⇒ Object



3
4
5
6
7
8
# File 'lib/malsh/notification/base.rb', line 3

def self.notify_host(subject, hosts)
  puts "#{subject}:"
  hosts.map do |h|
    puts "#{h.name}(#{h.roles.keys.join(",")})"
  end if doit?
end