aws-alert-monitor 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,4 @@
1
+ rvm:
2
+ - 1.9.2
3
+ - 1.9.3
4
+ script: "rake spec"
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.0.4:
2
+
3
+ * Updated email message format and content
4
+
1
5
  ## 0.0.3:
2
6
 
3
7
  * Log message if destination set to nil
data/README.md CHANGED
@@ -1,4 +1,6 @@
1
- # Aws::Alert::Monitor
1
+ [![Build Status](https://secure.travis-ci.org/intuit/aws-alert-monitor.png)](http://travis-ci.org/intuit/aws-alert-monitor)
2
+
3
+ ## AWS Alert Monitor
2
4
 
3
5
  AWS Alert Monitor listenting to an SQS queue for alarms and sends email via SES based on rules applied in ~/.aws-alert-monitor.yml to those alerts.
4
6
 
@@ -27,43 +27,46 @@ module AwsAlertMonitor
27
27
  private
28
28
 
29
29
  def send_alert(policy)
30
- message_source = policy['email']['source']
31
- message_destination = policy['email']['destination']
30
+ @message_source = policy['email']['source']
31
+ @message_destination = policy['email']['destination']
32
32
 
33
- if message_destination
34
- @logger.info "Sending alert to #{message_destination}."
35
-
36
- options = { :source => message_source,
37
- :destination => { :to_addresses => [ message_destination ] },
38
- :message => { :subject => {
39
- :data => "Alert: #{@name}"
40
- },
41
- :body => {
42
- :text => {
43
- :data => @message_data
44
- }
45
- }
46
- }
47
- }
48
- ses.send_email options
33
+ if @message_destination
34
+ @logger.info "Sending alert to #{@message_destination}."
35
+ ses.send_email email_options
49
36
  else
50
37
  @logger.info "Destination not set, no message sent."
51
38
  end
52
39
  end
53
40
 
41
+ def email_options
42
+ { :source => @message_source,
43
+ :destination => { :to_addresses => [ @message_destination ] },
44
+ :message => { :subject => {
45
+ :data => "Alert: #{@message_subject}"
46
+ },
47
+ :body => {
48
+ :text => {
49
+ :data => @message_data
50
+ }
51
+ }
52
+ }
53
+ }
54
+ end
55
+
54
56
  def process_message(message)
55
57
  begin
56
58
  message_body = JSON.parse message
57
- message = JSON.parse message_body['Message']
59
+ message_details = JSON.parse message_body['Message']
58
60
  rescue JSON::ParserError => e
59
61
  @logger.error e.message
60
62
  return false
61
63
  end
62
64
 
63
- @message_cause = message['Cause']
64
- @message_event = message['Event']
65
- @message_description = message['Description']
66
- @message_data = "#{@message_description} \n\n #{@message_cause}"
65
+ @message_cause = message_details['Cause']
66
+ @message_event = message_details['Event']
67
+ @message_description = message_details['Description']
68
+ @message_subject = message_body['Subject']
69
+ @message_data = "#{@name} received alert: \n\n #{@message_description} \n\n #{@message_cause}"
67
70
 
68
71
  true
69
72
  end
@@ -1,3 +1,3 @@
1
1
  module AwsAlertMonitor
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -16,7 +16,7 @@ describe AwsAlertMonitor::Alert do
16
16
 
17
17
  it "should process the given message against known events" do
18
18
  @ses_mock.should_receive(:send_email)
19
- .with({:source=>"brett_weaver@intuit.com", :destination=>{:to_addresses=>["brett_weaver@intuit.com"]}, :message=>{:subject=>{:data=>"Alert: test app"}, :body=>{:text=>{:data=>"Launching a new EC2 instance: i-d6a2cb8f \n\n At 2012-11-29T16:39:05Z an instance was started in response to a difference between desired and actual capacity, increasing the capacity from 0 to 1."}}}})
19
+ .with({:source=>"brett_weaver@intuit.com", :destination=>{:to_addresses=>["brett_weaver@intuit.com"]}, :message=>{:subject=>{:data=>"Alert: Auto Scaling: launch for group \"lc-pod-2-qa-1-app-1-Instances-XCYGCEQC0H02\""}, :body=>{:text=>{:data=>"test app received alert: \n\n Launching a new EC2 instance: i-d6a2cb8f \n\n At 2012-11-29T16:39:05Z an instance was started in response to a difference between desired and actual capacity, increasing the capacity from 0 to 1."}}}})
20
20
  @alert.process @options
21
21
  end
22
22
 
@@ -4,6 +4,7 @@ require 'yaml'
4
4
  describe AwsAlertMonitor::Config do
5
5
  before do
6
6
  @data = "app:\n access_key: key \n secret_key: secret\n region: us-west-1\n sqs_endpoint: https://sqs.us-west-1.amazonaws.com/123456789012/app\n events: \n 'autoscaling:EC2_INSTANCE_LAUNCH':\n email:\n source: brett_weaver@intuit.com\n destination: brett_weaver@intuit.com\n"
7
+ File.stub :exists? => true
7
8
  File.should_receive(:open).
8
9
  with("#{ENV['HOME']}/.aws-alert-monitor.yml").
9
10
  and_return @data
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aws-alert-monitor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-10 00:00:00.000000000 Z
12
+ date: 2013-01-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
16
- requirement: &70164408200380 !ruby/object:Gem::Requirement
16
+ requirement: &70314215544440 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70164408200380
24
+ version_requirements: *70314215544440
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rspec
27
- requirement: &70164408199440 !ruby/object:Gem::Requirement
27
+ requirement: &70314215543440 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 2.11.0
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70164408199440
35
+ version_requirements: *70314215543440
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: aws-sdk
38
- requirement: &70164408198940 !ruby/object:Gem::Requirement
38
+ requirement: &70314215542860 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: 1.7.1
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70164408198940
46
+ version_requirements: *70314215542860
47
47
  description: I watch an SQS queue and escalate alert messages.
48
48
  email:
49
49
  - brett@weav.net
@@ -54,6 +54,7 @@ extra_rdoc_files: []
54
54
  files:
55
55
  - .gitignore
56
56
  - .rvmrc
57
+ - .travis.yml
57
58
  - CHANGELOG
58
59
  - Gemfile
59
60
  - LICENSE.txt
@@ -91,7 +92,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
91
92
  version: '0'
92
93
  segments:
93
94
  - 0
94
- hash: -86907863604503039
95
+ hash: -3329563464597490015
95
96
  required_rubygems_version: !ruby/object:Gem::Requirement
96
97
  none: false
97
98
  requirements:
@@ -100,7 +101,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
100
101
  version: '0'
101
102
  segments:
102
103
  - 0
103
- hash: -86907863604503039
104
+ hash: -3329563464597490015
104
105
  requirements: []
105
106
  rubyforge_project:
106
107
  rubygems_version: 1.8.16