class DogEventer::ChefRun
Public Class Methods
new(host, start_time)
click to toggle source
# File lib/dogeventer/event_emitter.rb, line 134 def initialize(host, start_time) @host = host @start_time = start_time @events = [] end
Public Instance Methods
date_happened(date=nil)
click to toggle source
# File lib/dogeventer/event_emitter.rb, line 152 def date_happened(date=nil) (date || @start_time).to_i end
error(duration=nil, date=nil)
click to toggle source
# File lib/dogeventer/event_emitter.rb, line 185 def error(duration=nil, date=nil) to_event :error, duration end
event_object()
click to toggle source
# File lib/dogeventer/event_emitter.rb, line 144 def event_object() @host end
event_type()
click to toggle source
# File lib/dogeventer/event_emitter.rb, line 148 def event_type() "config_management.run" end
msg_title(duration)
click to toggle source
# File lib/dogeventer/event_emitter.rb, line 140 def msg_title(duration) "Chef completed in #{duration} seconds on #{@host}" end
priority(alert_type)
click to toggle source
# File lib/dogeventer/event_emitter.rb, line 160 def priority(alert_type) if alert_type == :error :normal else :low end end
source_type_name()
click to toggle source
# File lib/dogeventer/event_emitter.rb, line 156 def source_type_name() "Chef" end
success(duration=nil, date=nil)
click to toggle source
# File lib/dogeventer/event_emitter.rb, line 182 def success(duration=nil, date=nil) to_event :success, duration end
to_event(alert_type, duration=nil, date=nil)
click to toggle source
# File lib/dogeventer/event_emitter.rb, line 168 def to_event(alert_type, duration=nil, date=nil) duration = duration || rand(1000) @events << { :event_object => event_object, :event_type => event_type, :alert_type => alert_type, :date_happened => date_happened(date), :msg_title => msg_title(duration), :source_type_name => source_type_name, :host => @host, :priority => priority(alert_type) } end