Skip to content

Commit af22b88

Browse files
committed
added ses stats, renamed old ses to ses_quota
1 parent 02a8018 commit af22b88

File tree

4 files changed

+95
-0
lines changed

4 files changed

+95
-0
lines changed

amazon_ses_quota/amazon_ses_quota.rb

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Amazon Simple Email Service Quota monitor
2+
# Monitors the maximum number of emails you can send in a 24 hour period and actual sent emails.
3+
# Created by Valery Vishnyakov
4+
class AwsSesQuota < Scout::Plugin
5+
needs 'aws/ses'
6+
7+
OPTIONS=<<-EOS
8+
awskey:
9+
name: AWS Access Key
10+
notes: Your Amazon Web Services Access key. 20-char alphanumeric, looks like 022QF06E7MXBSH9DHM02
11+
awssecret:
12+
name: AWS Secret
13+
notes: Your Amazon Web Services Secret key. 40-char alphanumeric, looks like kWcrlUX5JEDGMLtmEENIaVmYvHNif5zBd9ct81S
14+
EOS
15+
16+
def build_report
17+
access_key_id = option('awskey')
18+
secret_access_key = option('awssecret')
19+
20+
ses = AWS::SES::Base.new(
21+
:access_key_id => access_key_id,
22+
:secret_access_key => secret_access_key
23+
)
24+
25+
response = ses.quota
26+
27+
if (response.sent_last_24_hours.to_i >= response.max_24_hour_send.to_i)
28+
alert('You have reached the maximum quota per 24 hours') unless memory(:notified)
29+
remember(:notified => true)
30+
else
31+
remember(:notified => false)
32+
end
33+
34+
report :sent => response.sent_last_24_hours,
35+
:max => response.max_24_hour_send
36+
end
37+
38+
end

amazon_ses_quota/amazon_ses_quota.yml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
metadata:
2+
sent:
3+
precision: 0
4+
label: Sent Emails (w/n 24 hours)
5+
max:
6+
precision: 0
7+
label: Sending quota

amazon_ses_stats/amazon_ses_stats.rb

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Amazon Simple Email Service Statistics (http://aws.amazon.com/ses/)
2+
# Displays Amazon SES automatically collected statistics regarding your sending activity:
3+
# * Successful delivery attempts
4+
# * Rejected messages
5+
# * Bounces
6+
# * Complaints
7+
8+
class AwsSesStatisticsPlugin < Scout::Plugin
9+
needs 'aws/ses'
10+
11+
OPTIONS=<<-EOS
12+
awskey:
13+
name: AWS Access Key
14+
notes: Your Amazon Web Services Access key. 20-char alphanumeric, looks like 022QF06E7MXBSH9DHM02
15+
awssecret:
16+
name: AWS Secret
17+
notes: Your Amazon Web Services Secret key. 40-char alphanumeric, looks like kWcrlUX5JEDGMLtmEENIaVmYvHNif5zBd9ct81S
18+
EOS
19+
20+
def build_report
21+
access_key_id = option('awskey')
22+
secret_access_key = option('awssecret')
23+
24+
ses = AWS::SES::Base.new(
25+
:access_key_id => access_key_id,
26+
:secret_access_key => secret_access_key
27+
)
28+
29+
response = ses.statistics
30+
data_point = response.data_points.sort_by{|r| Time.parse(r['Timestamp'])}.last
31+
32+
33+
report :bounces => data_point['Bounces'],
34+
:deliveries => data_point['DeliveryAttempts'],
35+
:rejects => data_point['Rejects'],
36+
:complaints => data_point['Complaints']
37+
end
38+
39+
end

amazon_ses_stats/amazon_ses_stats.yml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
metadata:
2+
complaints:
3+
precision: 0
4+
rejects:
5+
precision: 0
6+
label: Rejected messages
7+
bounces:
8+
precision: 0
9+
deliveries:
10+
precision: 0
11+
label: Successful delivery attempts

0 commit comments

Comments
 (0)