flapjack 0.7.25 → 0.7.26

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  ## Flapjack Changelog
2
2
 
3
+ # 0.7.26 - 2013-09-16
4
+ - Bug: last critical notification is empty in web UI gh-306 (@ali-graham)
5
+ - Bug: Ending unscheduled maintenance in Web UI is broken gh-307 (@jessereynolds)
6
+ - Bug: Acknowledgement jabber message shows incorrect duration gh-309 (@jessereynolds)
7
+ - Bug: Details showing up in email alerts when "empty" gh-310 (@jessereynolds)
8
+ - Bug: Only show Previous State and Summary when current state != previous unique state gh-311 (@jessereynolds)
9
+
3
10
  # 0.7.25 - 2013-09-13
4
11
  - Bug: EntityCheck last_update= isn't being called for update_state since refactoring gh-303 (@ali-graham)
5
12
  - Bug: flapjack-nagios-receiver is double-escaping its JSON data gh-304 (@jessereynolds)
@@ -151,7 +151,8 @@ module Flapjack
151
151
  pik.update_status
152
152
  status = pik.status
153
153
  next if old_status.eql?(status)
154
- @logger.info "#{pik.type}: #{old_status} -> #{status}"
154
+ # # can't log on exit w/Ruby 2.0
155
+ # @logger.info "#{pik.type}: #{old_status} -> #{status}"
155
156
  end
156
157
 
157
158
  if piks.any? {|p| p.status == 'stopping' }
@@ -106,6 +106,8 @@ module Flapjack
106
106
  'acknowledgement_id', 'duration'].each do |key|
107
107
  instance_variable_set("@#{key}", attrs[key])
108
108
  end
109
+ # details is optional. set it to nil if it only contains whitespace
110
+ @details = (@details.is_a?(String) && ! @details.strip.empty?) ? @details.strip : nil
109
111
  end
110
112
 
111
113
  def state
@@ -207,6 +207,7 @@ module Flapjack
207
207
  @details = opts['details']
208
208
  @time = opts['time']
209
209
  @count = opts['count']
210
+ @duration = opts['duration']
210
211
 
211
212
  @last_state = opts['last_state']
212
213
  @last_summary = opts['last_summary']
@@ -33,11 +33,10 @@ module Flapjack
33
33
  return true
34
34
  end
35
35
 
36
- entity_check.create_unscheduled_maintenance(timestamp,
37
- (event.duration || (4 * 60 * 60)),
38
- :summary => event.summary)
36
+ um_duration = event.duration || (4 * 60 * 60)
37
+ entity_check.create_unscheduled_maintenance(timestamp, um_duration, :summary => event.summary)
39
38
 
40
- @logger.debug("#{label} pass (unscheduled maintenance created for #{event.id})")
39
+ @logger.debug("#{label} pass (unscheduled maintenance created for #{event.id}, duration: #{um_duration})")
41
40
  false
42
41
  end
43
42
  end
@@ -2,18 +2,18 @@ Hi <%= @contact_first_name %>
2
2
 
3
3
  Monitoring has detected the following:
4
4
 
5
- Entity: <%= @entity_name %>
6
- Check: <%= @check %>
7
- State: <%= @state.upcase %>
8
- Summary: <%= @summary %>
5
+ Entity: <%= @entity_name %>
6
+ Check: <%= @check %>
7
+ State: <%= @state.upcase %>
8
+ Summary: <%= @summary %>
9
9
  <% if @details -%>
10
- Details: <%= @details %>
10
+ Details: <%= @details %>
11
11
  <% end -%>
12
12
  <% if @time -%>
13
- Time: <%= Time.at(@time.to_i).to_s %>
13
+ Time: <%= Time.at(@time.to_i).to_s %>
14
14
  <% end -%>
15
15
  <% if @duration && @duration > 40 -%>
16
- Duration: <%= ChronicDuration.output(@duration) %>
16
+ Duration: <%= ChronicDuration.output(@duration) %>
17
17
  <% end -%>
18
18
  <% if @last_state -%>
19
19
  Previous State: <%= @last_state.upcase %>
@@ -244,7 +244,7 @@ module Flapjack
244
244
  entity_check = get_entity_check(@entity, @check)
245
245
  return 404 if entity_check.nil?
246
246
 
247
- entity_check.end_unscheduled_maintenance
247
+ entity_check.end_unscheduled_maintenance(Time.now.to_i)
248
248
 
249
249
  redirect back
250
250
  end
@@ -403,9 +403,9 @@ module Flapjack
403
403
  [:critical, :warning, :unknown, :recovery, :acknowledgement].inject({}) do |memo, type|
404
404
  if last_notifications[type] && last_notifications[type][:timestamp]
405
405
  t = Time.at(last_notifications[type][:timestamp])
406
- memo[t] = {:time => t.to_s,
407
- :relative => relative_time_ago(t) + " ago",
408
- :summary => last_notifications[type][:summary]}
406
+ memo[type] = {:time => t.to_s,
407
+ :relative => relative_time_ago(t) + " ago",
408
+ :summary => last_notifications[type][:summary]}
409
409
  end
410
410
  memo
411
411
  end
@@ -88,6 +88,8 @@ module Flapjack
88
88
  # notification, updates the notification history in redis, generates the
89
89
  # notifications
90
90
  def process_notification(notification)
91
+ @logger.debug ("Processing notification: #{notification.inspect}")
92
+
91
93
  timestamp = Time.now
92
94
  event_id = notification.event_id
93
95
  entity_check = Flapjack::Data::EntityCheck.for_event_id(event_id, :redis => @redis)
@@ -247,25 +247,21 @@ module Flapjack
247
247
 
248
248
  severity = Flapjack::Data::Notification.severity_for_event(event, max_notified_severity)
249
249
 
250
- historical_state = case entity_check.state
251
- when previous_state
252
- # current state
253
- curr = entity_check.historical_states(nil, nil, :order => 'desc', :limit => 1)
254
- (curr && (curr.size == 1)) ? curr.first : nil
255
- else
256
- # last state
257
- curr_and_last = entity_check.historical_states(nil, nil, :order => 'desc', :limit => 2)
258
- (curr_and_last && (curr_and_last.size == 2)) ? curr_and_last.last : nil
259
- end
260
-
261
250
  lc = entity_check.last_change
262
251
  state_duration = lc ? (timestamp - lc) : nil
263
252
 
264
253
  Flapjack::Data::Notification.add(@notifier_queue, event,
265
254
  :type => notification_type, :severity => severity,
266
- :last_state => historical_state, :state_duration => state_duration,
255
+ :last_state => previous_unique_state(entity_check), :state_duration => state_duration,
267
256
  :redis => @redis)
268
257
  end
269
258
 
259
+ def previous_unique_state(entity_check)
260
+ hs = entity_check.historical_states(nil, nil, :order => 'desc', :limit => 2)
261
+ return { :last_state => nil, :last_summary => nil } unless hs.length == 2
262
+ return hs.last
263
+ end
264
+
270
265
  end
271
266
  end
267
+
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  module Flapjack
4
- VERSION = "0.7.25"
4
+ VERSION = "0.7.26"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flapjack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.25
4
+ version: 0.7.26
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2013-09-13 00:00:00.000000000 Z
14
+ date: 2013-09-16 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: dante
@@ -547,7 +547,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
547
547
  version: '0'
548
548
  segments:
549
549
  - 0
550
- hash: 2327642757705601515
550
+ hash: -187852671407725987
551
551
  required_rubygems_version: !ruby/object:Gem::Requirement
552
552
  none: false
553
553
  requirements:
@@ -556,7 +556,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
556
556
  version: '0'
557
557
  segments:
558
558
  - 0
559
- hash: 2327642757705601515
559
+ hash: -187852671407725987
560
560
  requirements: []
561
561
  rubyforge_project:
562
562
  rubygems_version: 1.8.23