Class: Distem::DataCollection::ProbeBW
- Inherits:
-
Probe
- Object
- Probe
- Distem::DataCollection::ProbeBW
- Defined in:
- lib/distem/datacollection/probe_bw.rb
Instance Attribute Summary
Attributes inherited from Probe
Instance Method Summary (collapse)
- - (Object) get_value
-
- (ProbeBW) initialize(drift, data, opts)
constructor
A new instance of ProbeBW.
Methods inherited from Probe
Constructor Details
- (ProbeBW) initialize(drift, data, opts)
Returns a new instance of ProbeBW
9 10 11 12 13 |
# File 'lib/distem/datacollection/probe_bw.rb', line 9 def initialize(drift, data, opts) super(drift, data, opts) @last_tx = 0 @last_rx = 0 end |
Instance Method Details
- (Object) get_value
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/distem/datacollection/probe_bw.rb', line 15 def get_value iface = @opts['interface'] output = `cat /proc/net/dev`.split(/\n/).grep(/#{iface}/).first filter = output.gsub(iface,'').scan(/\d+/) rx = filter[0].to_i tx = filter[8].to_i if (@last_rx == 0) ret = nil else ret = [@frequency * (rx - @last_rx), @frequency * (tx - @last_tx)] end @last_rx = rx @last_tx = tx return ret end |