Class: Adapter_fc
- Inherits:
-
Object
- Object
- Adapter_fc
- Defined in:
- lib/AIX/adapter_fc.rb
Instance Attribute Summary collapse
-
#fcstats ⇒ Object
readonly
Returns the value of attribute fcstats.
-
#serial_number ⇒ Object
Returns the value of attribute serial_number.
Instance Method Summary collapse
- #analyze ⇒ Object
- #diffs ⇒ Object
- #fcstat_add(timestamp, string) ⇒ Object
-
#initialize ⇒ Adapter_fc
constructor
A new instance of Adapter_fc.
- #validate_new_fcstat_data(timestamp) ⇒ Object
Constructor Details
#initialize ⇒ Adapter_fc
Returns a new instance of Adapter_fc.
9 10 11 12 13 |
# File 'lib/AIX/adapter_fc.rb', line 9 def initialize @fcstats = Hash.new @serial_number = nil end |
Instance Attribute Details
#fcstats ⇒ Object (readonly)
Returns the value of attribute fcstats.
5 6 7 |
# File 'lib/AIX/adapter_fc.rb', line 5 def fcstats @fcstats end |
#serial_number ⇒ Object
Returns the value of attribute serial_number.
7 8 9 |
# File 'lib/AIX/adapter_fc.rb', line 7 def serial_number @serial_number end |
Instance Method Details
#analyze ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/AIX/adapter_fc.rb', line 34 def analyze verbose = 1 if @fcstats.count == 2 puts 'Will analyze data' keys = @fcstats.keys fcs_1 = @fcstats[keys[0]] fcs_2 = @fcstats[keys[1]] if keys[0] < keys[1] puts "Test of timestamps - [passed] " if verbose > 0 else raise 'Wrong timestamps order in object, this version can work in this case (wrong data file?)' end if fcs_1.data["Seconds Since Last Reset"] < fcs_2.data["Seconds Since Last Reset"] puts "Seconds from liast Reset are increasing, it means adapter stats weren't reset and we can compare both states [passed]" else raise 'data statistics were reset, cannot compare data' end else puts 'I cannot find 2 fcstats entries' end end |
#diffs ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/AIX/adapter_fc.rb', line 64 def diffs diffs = Hash.new = @fcstats.keys fcs_1 = @fcstats[[0]] fcs_2 = @fcstats[[1]] fcs_1.data.each_pair { |key, value| diff = Hash.new if value.class == Hash value.each_pair { |key2, value2| puts "key: #{key}, key2: #{key2}, value2 type: #{value2.class}" if fcs_1.data[key][key2] != fcs_2.data[key][key2] diff[[0]] = fcs_1.data[key][key2] diff[[1]] = fcs_2.data[key][key2] diffs["#{key}-#{key2}"] = diff end } elsif value.class == String or value.class == Integer #puts "key: #{key}, value type: #{value.class}" if fcs_1.data[key] != fcs_2.data[key] diff[[0]] = fcs_1.data[key] diff[[1]] = fcs_2.data[key] diffs[key] = diff end else puts "Unknown type: #{value.class}" end } diffs end |
#fcstat_add(timestamp, string) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/AIX/adapter_fc.rb', line 15 def fcstat_add(, string) @fcstats[] = Fcstat.new(string) self.validate_new_fcstat_data() end |
#validate_new_fcstat_data(timestamp) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/AIX/adapter_fc.rb', line 22 def validate_new_fcstat_data() if @fcstats.count == 1 @serial_number = @fcstats[].data['Serial Number'] else pp @serial_number pp @fcstats[].data['Serial Number'] raise 'wrong serial number' if @fcstats[].data['Serial Number'] != @serial_number end end |