monitoring-client 0.2.6 → 0.2.7

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,14 +1,13 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- monitoring-client (0.2.3)
5
- json
4
+ monitoring-client (0.2.6)
5
+ yajl-ruby
6
6
 
7
7
  GEM
8
8
  remote: http://rubygems.org/
9
9
  specs:
10
10
  diff-lcs (1.1.3)
11
- json (1.5.3)
12
11
  rspec (2.6.0)
13
12
  rspec-core (~> 2.6.0)
14
13
  rspec-expectations (~> 2.6.0)
@@ -17,6 +16,7 @@ GEM
17
16
  rspec-expectations (2.6.0)
18
17
  diff-lcs (~> 1.1.2)
19
18
  rspec-mocks (2.6.0)
19
+ yajl-ruby (0.8.3)
20
20
 
21
21
  PLATFORMS
22
22
  ruby
data/bin/monitoringd CHANGED
@@ -6,7 +6,7 @@ module Monitoring
6
6
  require "optparse"
7
7
  require "thread"
8
8
  require "socket"
9
- require "json"
9
+ require "yajl"
10
10
  require "net/https"
11
11
  require "uri"
12
12
  require "timeout"
@@ -151,7 +151,7 @@ module Monitoring
151
151
  while @alive
152
152
  begin
153
153
  line = socket.gets()
154
- JSON.parse(line).each do |sample|
154
+ json_parse(line).each do |sample|
155
155
  @samples.push(sample)
156
156
  end
157
157
  rescue StandardError => e
@@ -163,7 +163,7 @@ module Monitoring
163
163
  end
164
164
 
165
165
  def post_samples(uri, samples)
166
- generic_http_post(uri, "/api/samples", nil, nil, 3, { "samples" => samples.to_json })
166
+ generic_http_post(uri, "/api/samples", nil, nil, 3, { "samples" => json_encode(samples) })
167
167
  rescue Timeout::Error => e
168
168
  STDOUT.puts("Could not post sample (will requeue): " + samples.inspect()) rescue nil
169
169
  STDERR.puts([[e.class.name, e.message].join(": "),
@@ -193,6 +193,14 @@ module Monitoring
193
193
  resp.body
194
194
  end
195
195
  end
196
+
197
+ def json_parse(what)
198
+ Yajl::Parser.parse(what)
199
+ end
200
+
201
+ def json_encode(what)
202
+ Yajl::Encoder.encode(what)
203
+ end
196
204
 
197
205
  end
198
206
  end
@@ -2,7 +2,7 @@ module Monitoring
2
2
  module Client
3
3
  class Profiler
4
4
 
5
- require "json"
5
+ require "yajl"
6
6
  require "socket"
7
7
  require "monitoring/client/config"
8
8
  require "monitoring/client/compiler"
@@ -30,10 +30,14 @@ module Monitoring
30
30
  end
31
31
 
32
32
  def post_metrics(compiled)
33
- UDPSocket.new().send(compiled.to_json + "\n",
33
+ UDPSocket.new().send(json_encode(compiled) + "\n",
34
34
  0, "localhost", 57475)
35
35
  end
36
36
 
37
+ def json_encode(what)
38
+ Yajl::Encoder.encode(what)
39
+ end
40
+
37
41
  def default_decorations
38
42
  {
39
43
  :hostname => config.hostname,
@@ -1,5 +1,5 @@
1
1
  module Monitoring
2
2
  module Client
3
- VERSION = "0.2.6"
3
+ VERSION = "0.2.7"
4
4
  end
5
5
  end
@@ -19,6 +19,6 @@ Gem::Specification.new do |s|
19
19
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
20
  s.require_paths = ["lib"]
21
21
 
22
- s.add_runtime_dependency "json"
22
+ s.add_runtime_dependency "yajl-ruby"
23
23
  s.add_development_dependency "rspec"
24
24
  end
metadata CHANGED
@@ -1,48 +1,62 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: monitoring-client
3
- version: !ruby/object:Gem::Version
4
- version: 0.2.6
3
+ version: !ruby/object:Gem::Version
4
+ hash: 25
5
5
  prerelease:
6
+ segments:
7
+ - 0
8
+ - 2
9
+ - 7
10
+ version: 0.2.7
6
11
  platform: ruby
7
- authors:
12
+ authors:
8
13
  - Marc Bowes
9
14
  autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
- date: 2011-09-17 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
15
- name: json
16
- requirement: &11494580 !ruby/object:Gem::Requirement
17
+
18
+ date: 2011-09-24 00:00:00 +02:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: yajl-ruby
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
17
25
  none: false
18
- requirements:
19
- - - ! '>='
20
- - !ruby/object:Gem::Version
21
- version: '0'
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 0
32
+ version: "0"
22
33
  type: :runtime
23
- prerelease: false
24
- version_requirements: *11494580
25
- - !ruby/object:Gem::Dependency
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
26
36
  name: rspec
27
- requirement: &11493980 !ruby/object:Gem::Requirement
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
28
39
  none: false
29
- requirements:
30
- - - ! '>='
31
- - !ruby/object:Gem::Version
32
- version: '0'
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ hash: 3
44
+ segments:
45
+ - 0
46
+ version: "0"
33
47
  type: :development
34
- prerelease: false
35
- version_requirements: *11493980
36
- description: Ruby client which uses UDP to communicate with a daemon which uses HTTP
37
- POST to communicate with a Web server
38
- email:
48
+ version_requirements: *id002
49
+ description: Ruby client which uses UDP to communicate with a daemon which uses HTTP POST to communicate with a Web server
50
+ email:
39
51
  - marcbowes+monitoring+client@gmail.com
40
- executables:
52
+ executables:
41
53
  - monitor-system-info
42
54
  - monitoringd
43
55
  extensions: []
56
+
44
57
  extra_rdoc_files: []
45
- files:
58
+
59
+ files:
46
60
  - .gitignore
47
61
  - Gemfile
48
62
  - Gemfile.lock
@@ -61,28 +75,39 @@ files:
61
75
  - spec/config_spec.rb
62
76
  - spec/profiler_spec.rb
63
77
  - spec/spec_helper.rb
78
+ has_rdoc: true
64
79
  homepage: http://rubygems.org/gems/monitoring-client
65
80
  licenses: []
81
+
66
82
  post_install_message:
67
83
  rdoc_options: []
68
- require_paths:
84
+
85
+ require_paths:
69
86
  - lib
70
- required_ruby_version: !ruby/object:Gem::Requirement
87
+ required_ruby_version: !ruby/object:Gem::Requirement
71
88
  none: false
72
- requirements:
73
- - - ! '>='
74
- - !ruby/object:Gem::Version
75
- version: '0'
76
- required_rubygems_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ hash: 3
93
+ segments:
94
+ - 0
95
+ version: "0"
96
+ required_rubygems_version: !ruby/object:Gem::Requirement
77
97
  none: false
78
- requirements:
79
- - - ! '>='
80
- - !ruby/object:Gem::Version
81
- version: '0'
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ hash: 3
102
+ segments:
103
+ - 0
104
+ version: "0"
82
105
  requirements: []
106
+
83
107
  rubyforge_project: monitoring-client
84
- rubygems_version: 1.8.5
108
+ rubygems_version: 1.6.2
85
109
  signing_key:
86
110
  specification_version: 3
87
111
  summary: Simple client & daemon to post metrics
88
112
  test_files: []
113
+