rack-jsonz 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3b1f9796c7d7c2369e61b3bcfa76b8fd5fbcc066
4
- data.tar.gz: 1ac20d51ba18127c8cd8cc0745ad345d464735c6
3
+ metadata.gz: de3ab72fc2689917da6343629d54265f695291ae
4
+ data.tar.gz: 3dbde2b53434c1802c743237ed47f451b68ba08c
5
5
  SHA512:
6
- metadata.gz: e9df32dd5874e08cec19f1bceacbf6867770b0592fd924c8378f1448c4a08baaf4543d4b84dda608cd8464cd132eac5e2f91d923cb389605827b4ef6feff916f
7
- data.tar.gz: d9c4d9b3e3e2865087e8e164f59ab6948dbe931b71b19febe9e28148e12221e31577360d61f96e1ca0a9eec9ceb345a88215031f045714c2beb5e2641143fc25
6
+ metadata.gz: 9f378936941ab2e9b46b4dbdc3ffc11213e2c9b16599c134b1159919451240843f01f1710d6a27dca9bdad7e95d402efdd99aaf52c7d780d88e66789f48ed3be
7
+ data.tar.gz: 7c297a48bf67c10ebe538fb712209bace3e0d473ead8f021d5f7286e7cfd2dda8e42bc6bf2aad155376feeb52327dd02ef04179bf7f92d90c63d208cf7de9d50
@@ -24,8 +24,8 @@ module Rack
24
24
  ret = {}
25
25
 
26
26
  cpu = CPU.new
27
- cpu.metrics.each_pair do |k, v|
28
- ret["/cpu/#{k}"] = v
27
+ cpu.each_metric do |k, v|
28
+ ret["/#{cpu.metric_group}/#{k}"] = v.to_s
29
29
  end
30
30
 
31
31
  return ret
@@ -1,13 +1,21 @@
1
+ require 'rack/jsonz/metric'
2
+
1
3
  require 'system'
4
+ require 'usagewatch_ext'
2
5
 
3
6
  module Rack
4
7
  class Jsonz
5
- class CPU
8
+ class CPU < Metric
6
9
  def metrics
7
10
  return {
8
- :count => System::CPU.count
11
+ :count => System::CPU.count.to_f,
12
+ :load => Usagewatch.uw_load.to_f,
9
13
  }
10
14
  end
15
+
16
+ def metric_group
17
+ "cpu"
18
+ end
11
19
  end
12
20
  end
13
21
  end
@@ -0,0 +1,9 @@
1
+ module Rack
2
+ class Jsonz
3
+ class Metric
4
+ def each_metric(&block)
5
+ self.metrics.each_pair(&block)
6
+ end
7
+ end
8
+ end
9
+ end
@@ -1,5 +1,5 @@
1
1
  module Rack
2
2
  class Jsonz
3
- VERSION = "0.0.2"
3
+ VERSION = "0.0.3"
4
4
  end
5
5
  end
@@ -21,6 +21,8 @@ Gem::Specification.new do |spec|
21
21
  spec.add_dependency "oj"
22
22
  spec.add_dependency "rack"
23
23
  spec.add_dependency "system"
24
+ spec.add_dependency "usagewatch"
25
+ spec.add_dependency "usagewatch_ext"
24
26
 
25
27
  spec.add_development_dependency "bundler", "~> 1.5"
26
28
  spec.add_development_dependency "rake"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-jsonz
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nat Welch
@@ -52,6 +52,34 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: usagewatch
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: usagewatch_ext
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
55
83
  - !ruby/object:Gem::Dependency
56
84
  name: bundler
57
85
  requirement: !ruby/object:Gem::Requirement
@@ -94,6 +122,7 @@ files:
94
122
  - Rakefile
95
123
  - lib/rack/jsonz.rb
96
124
  - lib/rack/jsonz/cpu.rb
125
+ - lib/rack/jsonz/metric.rb
97
126
  - lib/rack/jsonz/version.rb
98
127
  - rack-jsonz.gemspec
99
128
  homepage: http://github.com/icco/rack-jsonz