heroku_mongo_watcher 0.0.1.alpha → 0.0.2.alpha

Sign up to get free protection for your applications and to get access to all the features.
data/README.md ADDED
@@ -0,0 +1,30 @@
1
+ # Heroku Mongo Watcher
2
+
3
+ I needed to find a way to marry mongo stats with my application stats
4
+
5
+ It needed to accomplish the following:
6
+
7
+ * See Mongostats and heroku stats at the same time, the key ones being requests per minute, average response time and lock %
8
+ * Have multiple ways of notifying me: colors, beeps and email notifications
9
+ * Be able to parse the web log for certain errors and other logged events and aggregate data on them
10
+
11
+ The output looks like the following ...
12
+
13
+ |<---- heroku stats ------------------------------------------------------------>|<----mongo stats ------------------------------------------------------->|
14
+ dyno reqs art max r_err w_err wait queue slowest | insert query update faults locked qr|qw netIn netOut time |
15
+ 20 76 27 586 0 0 0 0 /pxl/4fdbc97dc6b36c003000| 0 0 0 0 0 0|0 305b 257b 15:03:19
16
+ 20 1592 62 1292 0 0 0 0 /assets/companions/5009ab| 17 2 32 0 1.2 0|0 14k 26k 15:04:19
17
+ [4] VAST Error
18
+ [28] Timeout::Error
19
+ [11] Cannot find impression when looking for asset
20
+ 20 23935 190 7144 0 43 0 0 /crossdomain.xml| 307 0 618 1 21.6 0|0 260k 221k 15:05:19
21
+
22
+ ## Prereqs
23
+
24
+ 1. need to have a heroku account, and have the heroku gem running on your machine
25
+
26
+ ## To install
27
+
28
+ 1. bundle install heroku_mongo_watcher
29
+ 2. create a .watcher file (see the examples) in your user directory ~/.watcher
30
+ 3. then run `bundle exec watcher`
data/example/.watcher CHANGED
@@ -23,4 +23,7 @@ mongo_password: 'skret'
23
23
  heroku_appname: 'my-heroku-app-name'
24
24
 
25
25
  #if you have multiple accounts
26
- heroku_account: 'my-heroku-account'
26
+ heroku_account: 'my-heroku-account'
27
+
28
+ # If you want to display the list of errors in the logs
29
+ display_errors: true
@@ -1,5 +1,17 @@
1
1
  require 'heroku_mongo_watcher/configuration'
2
2
  require 'term/ansicolor'
3
+
4
+ #http://stackoverflow.com/a/9117903/192791
5
+ require 'net/smtp'
6
+ Net.instance_eval {remove_const :SMTPSession} if defined?(Net::SMTPSession)
7
+
8
+ require 'net/pop'
9
+ Net::POP.instance_eval {remove_const :Revision} if defined?(Net::POP::Revision)
10
+ Net.instance_eval {remove_const :POP} if defined?(Net::POP)
11
+ Net.instance_eval {remove_const :POPSession} if defined?(Net::POPSession)
12
+ Net.instance_eval {remove_const :POP3Session} if defined?(Net::POP3Session)
13
+ Net.instance_eval {remove_const :APOPSession} if defined?(Net::APOPSession)
14
+
3
15
  require 'tlsmail'
4
16
 
5
17
  class HerokuMongoWatcher::CLI
@@ -142,7 +154,7 @@ class HerokuMongoWatcher::CLI
142
154
  end
143
155
 
144
156
  def self.print_errors
145
- if @errors && @errors.keys && @errors.keys.length > 0
157
+ if config[:print_errors] &&@errors && @errors.keys && @errors.keys.length > 0
146
158
  @errors.each do |error,count|
147
159
  puts "\t\t[#{count}] #{error}"
148
160
  end
@@ -253,7 +265,8 @@ class HerokuMongoWatcher::CLI
253
265
 
254
266
  def self.notify(msg)
255
267
  Thread.new('notify_admins') do
256
- notify.each { |user_email| send_email(user_email, msg) } unless notify.empty?
268
+ subscribers = config[:notify]
269
+ subscribers.each { |user_email| send_email(user_email, msg) } unless subscribers.empty?
257
270
  end
258
271
  end
259
272
 
@@ -268,9 +281,7 @@ class HerokuMongoWatcher::CLI
268
281
  end
269
282
 
270
283
  def self.send_email(to, msg)
271
-
272
284
  return unless config[:gmail_username] && config[:gmail_password]
273
-
274
285
  content = [
275
286
  "From: Mongo Watcher <#{config[:gmail_username]}>",
276
287
  "To: #{to}",
@@ -287,8 +298,6 @@ class HerokuMongoWatcher::CLI
287
298
  Net::SMTP.start('smtp.gmail.com', 587, 'gmail.com', config[:gmail_username], config[:gmail_password], :login) do |smtp|
288
299
  smtp.send_message(content, config[:gmail_username], to)
289
300
  end
290
-
291
-
292
301
  end
293
302
 
294
303
  def self.color_print(field, options ={})
@@ -10,7 +10,8 @@ module HerokuMongoWatcher::Configuration
10
10
  mongo_username: '',
11
11
  mongo_password: '',
12
12
  heroku_appname: '',
13
- heroku_account: ''
13
+ heroku_account: '',
14
+ display_errors: true
14
15
  }
15
16
 
16
17
  @@valid_config_keys = @@config.keys
@@ -1,3 +1,3 @@
1
1
  module HerokuMongoWatcher
2
- VERSION = "0.0.1.alpha"
2
+ VERSION = "0.0.2.alpha"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: heroku_mongo_watcher
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1.alpha
4
+ version: 0.0.2.alpha
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-07-20 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: term-ansicolor
16
- requirement: &2157145900 !ruby/object:Gem::Requirement
16
+ requirement: &2157594420 !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: :runtime
23
23
  prerelease: false
24
- version_requirements: *2157145900
24
+ version_requirements: *2157594420
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: tlsmail
27
- requirement: &2157145160 !ruby/object:Gem::Requirement
27
+ requirement: &2157593520 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *2157145160
35
+ version_requirements: *2157593520
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: heroku
38
- requirement: &2157144040 !ruby/object:Gem::Requirement
38
+ requirement: &2157586200 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *2157144040
46
+ version_requirements: *2157586200
47
47
  description: Also notifies you when certain thresholds are hit. I have found this
48
48
  much more accurate than New Relic
49
49
  email:
@@ -55,6 +55,7 @@ extra_rdoc_files: []
55
55
  files:
56
56
  - .gitignore
57
57
  - Gemfile
58
+ - README.md
58
59
  - Rakefile
59
60
  - bin/watcher
60
61
  - example/.watcher