graphiterb 0.1.1 → 0.1.2

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.1
1
+ 0.1.2
@@ -7,7 +7,7 @@ WC_EXEC = '/usr/bin/wc'
7
7
 
8
8
  class ApiCallMonitor < Graphiterb::GraphiteLogger
9
9
  API_CALLS_TO_MONITOR = %w[trstrank wordbag influence conversation]
10
- ERROR_CODES_TO_MONITOR = %w[4.. 5..]
10
+ ERROR_CODES_TO_MONITOR = %w[4.. 5.. 200]
11
11
 
12
12
  def initialize *args
13
13
  super *args
@@ -16,13 +16,13 @@ class ApiCallMonitor < Graphiterb::GraphiteLogger
16
16
  end
17
17
 
18
18
  def calls api
19
- total_calls = `cat /var/www/apeyeye/shared/log/apeyeye-access.log | grep 'GET /soc/net/tw/#{api}' | #{WC_EXEC} -l`
20
- @current_total[api] = total_calls
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
21
  end
22
22
 
23
23
  def errors error_code
24
- log_cat = `cat /var/www/apeyeye/shared/log/apeyeye-access.log | grep 'GET /soc/net/tw/.*HTTP/1\.[0-1]..#{error_code}' | #{WC_EXEC} -l`
25
- @current_total[error_code] = log_cat
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
26
  end
27
27
 
28
28
  def rate item
@@ -34,12 +34,12 @@ class ApiCallMonitor < Graphiterb::GraphiteLogger
34
34
 
35
35
  def get_metrics metrics, iter, since
36
36
  API_CALLS_TO_MONITOR.each do |api|
37
- calls(api)
38
- metrics << [scope_name(hostname, api, 'accesses'), rate(api)]
37
+ metrics << [scope_name(hostname, api, 'total_accesses'), calls(api)]
38
+ metrics << [scope_name(hostname, api, 'accesses'), rate(api)]
39
39
  end
40
40
  ERROR_CODES_TO_MONITOR.each do |code|
41
- errors(code)
42
- metrics << [scope_name(hostname, code.gsub('.','x'), 'errors'), rate(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
43
  end
44
44
  end
45
45
  end
data/graphiterb.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{graphiterb}
8
- s.version = "0.1.1"
8
+ s.version = "0.1.2"
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)"]
@@ -43,8 +43,8 @@ module Graphiterb
43
43
 
44
44
  def send *metrics
45
45
  now = timestamp
46
- message = metrics.map{|metric, val, ts| [metric, val, (ts||now)].join(" ") }.join("\n")
47
46
  safely do
47
+ message = metrics.map{|metric, val, ts| [metric, val, (ts||now)].join(" ") }.join("\n")+"\n"
48
48
  socket.puts(message)
49
49
  Log.info message.gsub(/\n+/, "\t")
50
50
  end
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: 25
4
+ hash: 31
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 1
10
- version: 0.1.1
9
+ - 2
10
+ version: 0.1.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Philip (flip) Kromer (@mrflip)