Class: Diskmon::RaidController

Inherits:
Object
  • Object
show all
Defined in:
lib/diskmon/client/raidcontroller.rb

Instance Method Summary collapse

Constructor Details

#initializeRaidController

Returns a new instance of RaidController.



9
10
11
12
# File 'lib/diskmon/client/raidcontroller.rb', line 9

def initialize
  @vendor  = get_vendor
  @disks   = []
end

Instance Method Details

#get_all_statsObject



112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# File 'lib/diskmon/client/raidcontroller.rb', line 112

def get_all_stats

  ctl_ids = get_ctl_ids

  zp = Diskmon::ZpoolsTree.new

  if not ctl_ids.empty?
    ctl_ids.each do |ctl_id|
      get_ctl_disks_info(ctl_id) do |d| 

        d.member_of_zpool = zp.which_pool(d.system_device)
        d.read_errors     = zp.read_errors(d.system_device)
        d.write_errors    = zp.write_errors(d.system_device)
        d.checksum_errors = zp.checksum_errors(d.system_device)

        d.zpool_health       = zp.get_pool_param(d.member_of_zpool, "health")
        d.zpool_last_command = zp.get_pool_param(d.member_of_zpool, "last_command")
        d.zpool_total_space  = zp.get_pool_param(d.member_of_zpool, "total_space")
        d.zpool_free_space   = zp.get_pool_param(d.member_of_zpool, "free_space")

        @disks.push(d)
      end
    end
  end

  # TODO: /c3 show events

  p @disks if $DEBUG

end

#parse_smart_status(smart_arr) ⇒ Object



143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
# File 'lib/diskmon/client/raidcontroller.rb', line 143

def parse_smart_status(smart_arr)

  # TODO: dig smartmontools sources

  smart_attributes = {
    '00' => 'Zero_Field',
    '01' => 'Raw_Read_Error_Rate',
    '03' => 'Spin_Up_Time',
    '04' => 'Start_Stop_Count',
    '05' => 'Reallocated_Sector_Ct',
    '07' => 'Seek_Error_Rate',
    '09' => 'Power_On_Hours',
    '0A' => 'Spin_Retry_Count',
    '0B' => 'Calibration_Retry_Count',
    '0C' => 'Power_Cycle_Count',
    'B8' => 'End-to-End_error',
    'BB' => 'Reported_Uncorrect',
    'BC' => 'Command_Timeout',
    'BD' => 'High Fly Writes',
    'BE' => 'Airflow Temperature',
    'C0' => 'Power-off_Retract_Count',
    'C1' => 'Load_Cycle_Count',
    'C2' => 'Temperature',
    'C3' => 'Hardware ECC Recovered',
    'C4' => 'Reallocation Event Count',
    'C5' => 'Current Pending Sector Count',
    'C6' => 'Uncorrectable Sector Count',
    'C7' => 'UltraDMA CRC Error Count',
    'C8' => 'Multi-Zone Error Rate',
  }

  smart_parsed = {}

  i = 0 ; while i < 360 do

      if smart_arr[i+2].to_i != 0
  
        j = 0 ; while j < 12 do
          if j == 0
            smart_param = smart_attributes[smart_arr[i+j+2]]
            smart_val = ''
          end

            if j > 4 and j < 11
            smart_val << smart_arr[i+j+2]
          end

          j += 1
        end # while j < 12

        smart_parsed["#{smart_param}"] = smart_val.to_i(10)
                  
      end # if smart_arr
      
      i += 12

  end # while i

  #    p smart_parsed if $DEBUG

  smart_parsed

end

#serializeObject



207
208
209
# File 'lib/diskmon/client/raidcontroller.rb', line 207

def serialize
  Marshal.dump(@disks)
end