Class: Ganymed::Client::Sampler
- Inherits:
-
UDPSocket
- Object
- UDPSocket
- Ganymed::Client::Sampler
- Defined in:
- lib/ganymed/client/sampler.rb
Overview
An EventMachine Protocol that can send samples to a Ganymed sampler.
Instance Attribute Summary collapse
-
#origin ⇒ Object
Returns the value of attribute origin.
Class Method Summary collapse
-
.connect(host, port, origin = nil) ⇒ Object
Connect to a Ganymed sampler.
Instance Method Summary collapse
-
#emit(ds, ns, value) ⇒ Object
Emit a new sample.
Instance Attribute Details
#origin ⇒ Object
Returns the value of attribute origin.
10 11 12 |
# File 'lib/ganymed/client/sampler.rb', line 10 def origin @origin end |
Class Method Details
.connect(host, port, origin = nil) ⇒ Object
Connect to a Ganymed sampler.
28 29 30 31 32 33 |
# File 'lib/ganymed/client/sampler.rb', line 28 def self.connect(host, port, origin=nil) new.tap do |socket| socket.connect(host, port) socket.origin = origin || ::Socket.gethostbyname(::Socket.gethostname).first end end |
Instance Method Details
#emit(ds, ns, value) ⇒ Object
Emit a new sample.
17 18 19 20 |
# File 'lib/ganymed/client/sampler.rb', line 17 def emit(ds, ns, value) data = [ds.to_s, ns, origin, value.to_f] send(data.pack("Z*Z*Z*G"), 0) end |