(recoveryLine string)
| 276 | } |
| 277 | |
| 278 | func evalRecoveryLine(recoveryLine string) (blocksSynced int64, blocksToBeSynced int64, pct float64, finish float64, speed float64, err error) { |
| 279 | matches := recoveryLineBlocksRE.FindStringSubmatch(recoveryLine) |
| 280 | if len(matches) != 2 { |
| 281 | return 0, 0, 0, 0, 0, fmt.Errorf("%w: Unexpected recoveryLine blocks %s: %w", ErrFileParse, recoveryLine, err) |
| 282 | } |
| 283 | |
| 284 | blocks := strings.Split(matches[1], "/") |
| 285 | blocksSynced, err = strconv.ParseInt(blocks[0], 10, 64) |
| 286 | if err != nil { |
| 287 | return 0, 0, 0, 0, 0, fmt.Errorf("%w: Unable to parse recovery blocks synced %q: %w", ErrFileParse, matches[1], err) |
| 288 | } |
| 289 | |
| 290 | blocksToBeSynced, err = strconv.ParseInt(blocks[1], 10, 64) |
| 291 | if err != nil { |
| 292 | return blocksSynced, 0, 0, 0, 0, fmt.Errorf("%w: Unable to parse recovery to be synced blocks %q: %w", ErrFileParse, matches[2], err) |
| 293 | } |
| 294 | |
| 295 | // Get percentage complete |
| 296 | matches = recoveryLinePctRE.FindStringSubmatch(recoveryLine) |
| 297 | if len(matches) != 2 { |
| 298 | return blocksSynced, blocksToBeSynced, 0, 0, 0, fmt.Errorf("%w: Unexpected recoveryLine matching percentage %s", ErrFileParse, recoveryLine) |
| 299 | } |
| 300 | pct, err = strconv.ParseFloat(strings.TrimSpace(matches[1]), 64) |
| 301 | if err != nil { |
| 302 | return blocksSynced, blocksToBeSynced, 0, 0, 0, fmt.Errorf("%w: Error parsing float from recoveryLine %q", ErrFileParse, recoveryLine) |
| 303 | } |
| 304 | |
| 305 | // Get time expected left to complete |
| 306 | matches = recoveryLineFinishRE.FindStringSubmatch(recoveryLine) |
| 307 | if len(matches) != 2 { |
| 308 | return blocksSynced, blocksToBeSynced, pct, 0, 0, fmt.Errorf("%w: Unexpected recoveryLine matching est. finish time: %s", ErrFileParse, recoveryLine) |
| 309 | } |
| 310 | finish, err = strconv.ParseFloat(matches[1], 64) |
| 311 | if err != nil { |
| 312 | return blocksSynced, blocksToBeSynced, pct, 0, 0, fmt.Errorf("%w: Unable to parse float from recoveryLine: %q", ErrFileParse, recoveryLine) |
| 313 | } |
| 314 | |
| 315 | // Get recovery speed |
| 316 | matches = recoveryLineSpeedRE.FindStringSubmatch(recoveryLine) |
| 317 | if len(matches) != 2 { |
| 318 | return blocksSynced, blocksToBeSynced, pct, finish, 0, fmt.Errorf("%w: Unexpected recoveryLine value: %s", ErrFileParse, recoveryLine) |
| 319 | } |
| 320 | speed, err = strconv.ParseFloat(matches[1], 64) |
| 321 | if err != nil { |
| 322 | return blocksSynced, blocksToBeSynced, pct, finish, 0, fmt.Errorf("%w: Error parsing float from recoveryLine: %q: %w", ErrFileParse, recoveryLine, err) |
| 323 | } |
| 324 | |
| 325 | return blocksSynced, blocksToBeSynced, pct, finish, speed, nil |
| 326 | } |
| 327 | |
| 328 | func evalComponentDevices(deviceFields []string) ([]MDStatComponent, error) { |
| 329 | mdComponentDevices := make([]MDStatComponent, 0) |
no outgoing calls
no test coverage detected
searching dependent graphs…