Skip to content

feat: SMART attribute override functionality (upstream #835) #114

Description

@Starosdev

Summary

Port feature from upstream AnalogJ/scrutiny PR AnalogJ#835 to allow users to ignore, force status, or set custom thresholds for specific SMART attributes.

Problem

Users experience false positives from:

  • Vendor-specific attributes that don't follow standard thresholds
  • Old but irrelevant errors that persist on drives
  • Attributes that don't apply to their specific hardware

Currently there's no way to suppress or customize how individual attributes are evaluated.

Solution

Add an attribute_overrides configuration section that allows users to:

  • Ignore specific attributes (prevents false positives)
  • Force status to passed/warn/failed
  • Set custom thresholds (warn_above/fail_above) for attribute values

Configuration Example

smart:
  attribute_overrides:
    - protocol: ATA           # ATA | NVMe | SCSI
      attribute_id: "187"     # string ID as shown in UI
      wwn: "0x5000c5002df89099" # optional: limit to specific device
      action: ignore          # ignore | force_status

    - protocol: NVMe
      attribute_id: "media_errors"
      action: force_status
      status: passed          # passed | warn | failed

    - protocol: ATA
      attribute_id: "5"
      warn_above: 5           # warn when value exceeds
      fail_above: 10          # fail when value exceeds (takes precedence)

Changes Required

Backend

New files:

  • webapp/backend/pkg/models/attribute_override.go - AttributeOverride struct

Files to modify:

  • example.scrutiny.yaml - Add attribute_overrides documentation
  • webapp/backend/pkg/config/config.go - Add default for smart.attribute_overrides
  • webapp/backend/pkg/database/scrutiny_repository_device.go - Update device status handling
  • webapp/backend/pkg/database/scrutiny_repository_device_smart_attributes.go - Add override logic
  • webapp/backend/pkg/web/handler/upload_device_metrics.go - Always persist evaluated status
  • webapp/backend/pkg/web/server_test.go - Update test mocks

New test file:

  • webapp/backend/pkg/database/scrutiny_repository_device_smart_attributes_test.go

Key Implementation Details

  1. Override Matching: Matches by protocol (required), attribute_id (required), and optionally WWN
  2. Threshold Priority: fail_above takes precedence over warn_above when both exceeded
  3. Value Comparison: Uses raw values for ATA, current Value for NVMe/SCSI
  4. Status Rebuilding: After applying overrides, device status is rebuilt from attribute statuses
  5. SMART Failure Preservation: Original SMART failure flags are preserved even when attributes are ignored

Upstream Reference

Acceptance Criteria

  • Add AttributeOverride model
  • Implement config parsing for attribute_overrides
  • Implement override matching logic (protocol, attribute_id, wwn)
  • Implement ignore action
  • Implement force_status action (passed/warn/failed)
  • Implement threshold overrides (warn_above/fail_above)
  • Rebuild device status after applying overrides
  • Add comprehensive unit tests
  • Update example config with documentation
  • Test with various override scenarios

Metadata

Metadata

Assignees

Labels

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions