graphiterb 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.4
1
+ 0.1.5
@@ -0,0 +1,51 @@
1
+ #!/usr/bin/env ruby
2
+ $: << File.dirname(__FILE__)+'/../lib/'
3
+ require 'graphiterb'
4
+ require 'graphiterb/graphite_script'
5
+
6
+ WC_EXEC = '/usr/bin/wc'
7
+
8
+ class ApiCallMonitor < Graphiterb::GraphiteLogger
9
+ API_CALLS_TO_MONITOR = %w[trstrank wordbag influence conversation]
10
+ ERROR_CODES_TO_MONITOR = %w[4.. 5.. 200]
11
+
12
+ def initialize *args
13
+ super *args
14
+ @current_total = Hash.new
15
+ @prev_total = Hash.new
16
+ end
17
+
18
+ def calls api
19
+ total_calls = `cat /var/www/apeyeye/shared/log/apeyeye-access.log | egrep 'GET /soc/net/tw/#{api}' | #{WC_EXEC} -l` rescue 0
20
+ @current_total[api] = total_calls.to_i
21
+ end
22
+
23
+ def errors error_code
24
+ log_cat = `cat /var/www/apeyeye/shared/log/apeyeye-access.log | egrep 'GET /soc/net/tw/.*HTTP/1\.[0-1]..#{error_code}' | #{WC_EXEC} -l` rescue 0
25
+ @current_total[error_code] = log_cat.to_i
26
+ end
27
+
28
+ def rate item
29
+ @prev_total[item] ||= @current_total[item]
30
+ rate = @current_total[item].to_i - @prev_total[item].to_i
31
+ @prev_total[item] = @current_total[item]
32
+ [0, rate].max
33
+ end
34
+
35
+ def get_metrics metrics, iter, since
36
+ API_CALLS_TO_MONITOR.each do |api|
37
+ metrics << [scope_name(hostname, api, 'total_accesses'), calls(api)]
38
+ metrics << [scope_name(hostname, api, 'accesses'), rate(api)]
39
+ end
40
+ ERROR_CODES_TO_MONITOR.each do |code|
41
+ metrics << [scope_name(hostname, code.gsub('.','x'), 'total_errors'), errors(code)]
42
+ metrics << [scope_name(hostname, code.gsub('.','x'), 'errors'), rate(code)]
43
+ end
44
+ end
45
+ end
46
+
47
+
48
+ warn "Update delay is #{Settings.update_delay} seconds. You probably want something larger: some of these checks are data-intensive" if Settings.update_delay < 60
49
+ Settings.die "Update delay is #{Settings.update_delay} seconds. You need to radio in at least as often as /usr/local/share/graphite/conf/storage-schemas says -- this is typically 5 minutes." if Settings.update_delay >= 300
50
+
51
+ ApiCallMonitor.new('apeyeye', :iters => nil, :time => Settings.update_delay).run!
@@ -74,7 +74,7 @@ class FilePool
74
74
  end
75
75
 
76
76
  def self.recent? file
77
- (Time.now - File.mtime(file)) < 1.hour
77
+ (Time.now - File.mtime(file)) < 3600
78
78
  end
79
79
  def self.recency_filter
80
80
  Proc.new{|file| recent?(file) }
@@ -0,0 +1,2 @@
1
+ PYTHONPATH=$pwd/whisper nohup ./bin/run-graphite-devel-server.py --libs=$pwd/webapp/ /usr/local/share/graphite/ >> ./storage/log/webapp/server.log 2>&1 &
2
+ PYTHONPATH=$pwd/whisper nohup ./carbon/bin/carbon-cache.py --debug start >> ./storage/log/carbon-cache/console.log 2>&1 &
data/graphiterb.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{graphiterb}
8
- s.version = "0.1.4"
8
+ s.version = "0.1.5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Philip (flip) Kromer (@mrflip)"]
12
- s.date = %q{2010-07-20}
12
+ s.date = %q{2010-08-16}
13
13
  s.description = %q{Uses http://github.com/mrflip/configliere and http://graphite.wikidot.com}
14
14
  s.email = %q{info@infochimps.org}
15
15
  s.extra_rdoc_files = [
@@ -24,6 +24,12 @@ Gem::Specification.new do |s|
24
24
  "README.textile",
25
25
  "Rakefile",
26
26
  "VERSION",
27
+ "examples/api_call_monitor.rb",
28
+ "examples/file_monitor.rb",
29
+ "examples/loadavg_graphite_sender.rb",
30
+ "examples/run_servers.sh",
31
+ "examples/storage_monitor.rb",
32
+ "examples/toy.rb",
27
33
  "graphiterb.gemspec",
28
34
  "lib/graphiterb.rb",
29
35
  "lib/graphiterb/graphite_logger.rb",
@@ -42,9 +48,10 @@ Gem::Specification.new do |s|
42
48
  s.test_files = [
43
49
  "spec/graphiterb_spec.rb",
44
50
  "spec/spec_helper.rb",
45
- "examples/toy.rb",
46
51
  "examples/storage_monitor.rb",
52
+ "examples/api_call_monitor.rb",
47
53
  "examples/loadavg_graphite_sender.rb",
54
+ "examples/toy.rb",
48
55
  "examples/file_monitor.rb"
49
56
  ]
50
57
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graphiterb
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 4
10
- version: 0.1.4
9
+ - 5
10
+ version: 0.1.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - Philip (flip) Kromer (@mrflip)
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-07-20 00:00:00 -05:00
18
+ date: 2010-08-16 00:00:00 +00:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -65,6 +65,12 @@ files:
65
65
  - README.textile
66
66
  - Rakefile
67
67
  - VERSION
68
+ - examples/api_call_monitor.rb
69
+ - examples/file_monitor.rb
70
+ - examples/loadavg_graphite_sender.rb
71
+ - examples/run_servers.sh
72
+ - examples/storage_monitor.rb
73
+ - examples/toy.rb
68
74
  - graphiterb.gemspec
69
75
  - lib/graphiterb.rb
70
76
  - lib/graphiterb/graphite_logger.rb
@@ -74,10 +80,6 @@ files:
74
80
  - spec/graphiterb_spec.rb
75
81
  - spec/spec.opts
76
82
  - spec/spec_helper.rb
77
- - examples/toy.rb
78
- - examples/storage_monitor.rb
79
- - examples/loadavg_graphite_sender.rb
80
- - examples/file_monitor.rb
81
83
  has_rdoc: true
82
84
  homepage: http://github.com/infochimps/graphiterb
83
85
  licenses: []
@@ -115,7 +117,8 @@ summary: Fast Ubiquitous Dashboard Logs with Graphite (http://graphite.wikidot.c
115
117
  test_files:
116
118
  - spec/graphiterb_spec.rb
117
119
  - spec/spec_helper.rb
118
- - examples/toy.rb
119
120
  - examples/storage_monitor.rb
121
+ - examples/api_call_monitor.rb
120
122
  - examples/loadavg_graphite_sender.rb
123
+ - examples/toy.rb
121
124
  - examples/file_monitor.rb