Class: EventMachine::SFlow::CounterSample
- Inherits:
-
Object
- Object
- EventMachine::SFlow::CounterSample
- Defined in:
- lib/em-sflow/packet/counter_sample.rb
Instance Attribute Summary collapse
-
#records ⇒ Object
Returns the value of attribute records.
-
#sequence_number ⇒ Object
Returns the value of attribute sequence_number.
-
#source_class ⇒ Object
Returns the value of attribute source_class.
-
#source_value ⇒ Object
Returns the value of attribute source_value.
Instance Method Summary collapse
-
#initialize(data) ⇒ CounterSample
constructor
A new instance of CounterSample.
Constructor Details
#initialize(data) ⇒ CounterSample
Returns a new instance of CounterSample.
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/em-sflow/packet/counter_sample.rb', line 3 def initialize data @records = [] data.extend EM::SFlow::BinaryString @sequence_number, source_id_class_value, record_count = data.unpack("NNN") @source_class = source_id_class_value >> 24 @source_value = source_id_class_value & (2 ** 24 - 1) data.advance(12) record_count.times do enterprise_format, length = data.unpack("NN") enterprise = enterprise_format >> 12 format = enterprise_format & (2 ** 12 - 1) data.advance(8) record_data = data.advance(length) if enterprise == 0 && format == 1 @records << EM::SFlow::GenericInterfaceCounters.new(record_data) elsif enterprise == 0 && format == 2 @records << EM::SFlow::EthernetInterfaceCounters.new(record_data) elsif enterprise == 0 && format == 3 # @records << EM::SFlow::TokenRingCounters.new(record_data) elsif enterprise == 0 && format == 4 # @records << EM::SFlow::HundredBaseVgCounters.new(record_data) elsif enterprise == 0 && format == 5 # @records << EM::SFlow::VlanCounters.new(record_data) elsif enterprise == 0 && format == 1001 # @records << EM::SFlow::ProcessorInformation.new(record_data) end end end |
Instance Attribute Details
#records ⇒ Object
Returns the value of attribute records.
2 3 4 |
# File 'lib/em-sflow/packet/counter_sample.rb', line 2 def records @records end |
#sequence_number ⇒ Object
Returns the value of attribute sequence_number.
2 3 4 |
# File 'lib/em-sflow/packet/counter_sample.rb', line 2 def sequence_number @sequence_number end |
#source_class ⇒ Object
Returns the value of attribute source_class.
2 3 4 |
# File 'lib/em-sflow/packet/counter_sample.rb', line 2 def source_class @source_class end |
#source_value ⇒ Object
Returns the value of attribute source_value.
2 3 4 |
# File 'lib/em-sflow/packet/counter_sample.rb', line 2 def source_value @source_value end |