ganymed-client 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/ganymed/client/sampler.rb +9 -12
- data/lib/ganymed/client/version.rb +1 -1
- metadata +6 -6
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'socket'
|
2
2
|
|
3
3
|
module Ganymed
|
4
4
|
module Client
|
@@ -6,8 +6,8 @@ module Ganymed
|
|
6
6
|
##
|
7
7
|
# An EventMachine Protocol that can send samples to a Ganymed sampler.
|
8
8
|
#
|
9
|
-
|
10
|
-
|
9
|
+
class Sampler < UDPSocket
|
10
|
+
attr_accessor :origin
|
11
11
|
|
12
12
|
# Emit a new sample.
|
13
13
|
#
|
@@ -15,8 +15,8 @@ module Ganymed
|
|
15
15
|
# @param [String] ns Event namespace.
|
16
16
|
# @param [Fixnum, Float] value Sample value.
|
17
17
|
def emit(ds, ns, value)
|
18
|
-
data = [ds.to_s, ns,
|
19
|
-
|
18
|
+
data = [ds.to_s, ns, origin, value.to_f]
|
19
|
+
send(data.pack("Z*Z*Z*G"), 0)
|
20
20
|
end
|
21
21
|
|
22
22
|
# Connect to a Ganymed sampler.
|
@@ -26,13 +26,10 @@ module Ganymed
|
|
26
26
|
# @param [String] origin Origin of events. Defaults to the
|
27
27
|
# fully-qualified hostname.
|
28
28
|
def self.connect(host, port, origin=nil)
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
def initialize(host, port, origin=nil)
|
34
|
-
@host, @port = host, port
|
35
|
-
@origin = origin || ::Socket.gethostbyname(::Socket.gethostname).first
|
29
|
+
new.tap do |socket|
|
30
|
+
socket.connect(host, port)
|
31
|
+
socket.origin = origin || ::Socket.gethostbyname(::Socket.gethostname).first
|
32
|
+
end
|
36
33
|
end
|
37
34
|
end
|
38
35
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ganymed-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-07-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: msgpack
|
16
|
-
requirement: &
|
16
|
+
requirement: &19791620 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *19791620
|
25
25
|
description: Client library for Ganymed
|
26
26
|
email:
|
27
27
|
- bb@xnull.de
|
@@ -61,7 +61,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
61
61
|
version: '0'
|
62
62
|
segments:
|
63
63
|
- 0
|
64
|
-
hash:
|
64
|
+
hash: 3452556534310659277
|
65
65
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
66
66
|
none: false
|
67
67
|
requirements:
|
@@ -70,7 +70,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
70
70
|
version: '0'
|
71
71
|
segments:
|
72
72
|
- 0
|
73
|
-
hash:
|
73
|
+
hash: 3452556534310659277
|
74
74
|
requirements: []
|
75
75
|
rubyforge_project:
|
76
76
|
rubygems_version: 1.8.17
|