Class: Kennel::UnmutedAlerts

Inherits:
Object
  • Object
show all
Defined in:
lib/kennel/unmuted_alerts.rb

Constant Summary collapse

COLORS =
{
  "Alert" => :red,
  "Warn" => :yellow,
  "No Data" => :cyan
}.freeze

Class Method Summary collapse

Class Method Details



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/kennel/unmuted_alerts.rb', line 14

def print(api, tag)
  monitors = filtered_monitors(api, tag)
  if monitors.empty?
    Kennel.out.puts "No unmuted alerts found"
  else
    monitors.each do |m|
      Kennel.out.puts m[:name]
      Kennel.out.puts Utils.path_to_url("/monitors/#{m[:id]}")
      m[:state][:groups].each do |g|
        color = COLORS[g[:status]] || :default
        since = "\t#{time_since(g[:last_triggered_ts])}"
        Kennel.out.puts "#{Kennel::Utils.color(color, g[:status])}\t#{g[:name]}#{since}"
      end
      Kennel.out.puts
    end
  end
end