Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add macOS smartmontools support #935

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

gtalusan
Copy link

smartmontools is available on macOS. In this PR, I just copy and paste the smart code verbatim from Linux to the Darwin conditional branch.

Below is the output of npm run test showing the smartData field for my 2019-ish iMac's NVMe.

SYSTEMINFORMATION - Test Scripts - Version: 5.23.5
═══════════════════════════════════════════════════════════

┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│  a ... Audio              i ... INET Latency       t ... time               1 ... NET Iface Default     ? ... Get Object    │
│  b ... BIOS               I ... INET Check Site    T ... CPU Temperature    2 ... NET Gateway Default   , ... All Static    │
│  B ... Baseboard          j ... CPU Current Speed  u ... USB                3 ... NET Interfaces        . ... All Dynamic   │
│  C ... Chassis            l ... CPU Current Load   U ... UUID               4 ... NET Stats             / ... All           │
│  c ... CPU                L ... Full Load          v ... Versions           5 ... NET Connections                           │
│  d ... DiskLayout         m ... Memory             V ... Virtual Box                                                        │
│  D ... DiskIO             M ... MEM Layout         w ... WIFI networks                                                      │
│  e ... Block Devices      o ... OS Info            W ... WIFI interfaces    6 ... Docker Info                               │
│  E ... Open Files         p ... Processes          x ... WIFI connections   7 ... Docker Images                             │
│  f ... FS Size            P ... Process Load       y ... System             8 ... Docker Container                          │
│  F ... FS Stats           r ... Printer            Y ... Battery            9 ... Docker Cont Stats                         │
│  g ... Graphics           s ... Services           z ... Users              0 ... Docker Cont Proc                          │
│  h ... Bluetooth          S ... Shell                                       + ... Docker Volumes        q >>> QUIT          │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
                                                                      
┌────────────────────────────────────────────────┐
│  Disk Layout                         v: 5.23.5 │
└────────────────────────────────────────────────┘
[
  {
    device: 'disk0',
    type: 'NVMe',
    name: 'APPLE SSD SM2048L',
    vendor: 'Apple',
    size: 2001111162880,
    bytesPerSector: null,
    totalCylinders: null,
    totalHeads: null,
    totalSectors: null,
    totalTracks: null,
    tracksPerCylinder: null,
    sectorsPerTrack: null,
    firmwareRevision: 'CXS7LA0Q',
    serialNum: 'XXXXXXXXXXXXXXXXXXXX',
    interfaceType: 'PCIe x4',
    smartStatus: 'Ok',
    temperature: 33,
    smartData: {
      json_format_version: [ 1, 0 ],
      smartctl: {
        version: [ 7, 4 ],
        pre_release: false,
        svn_revision: '5530',
        platform_info: 'Darwin 24.1.0 x86_64',
        build_info: '(local build)',
        argv: [ 'smartctl', '-a', '-j', 'disk0' ],
        exit_status: 0
      },
      local_time: { time_t: 1727721313, asctime: 'Mon Sep 30 14:35:13 2024 EDT' },
      device: {
        name: 'disk0',
        info_name: 'disk0',
        type: 'nvme',
        protocol: 'NVMe'
      },
      model_name: 'APPLE SSD SM2048L',
      serial_number: 'XXXXXXXXXXXXXXXXXXXXXXXX',
      firmware_version: 'CXS7LA0Q',
      nvme_pci_vendor: { id: 5197, subsystem_id: 5197 },
      nvme_ieee_oui_identifier: 9528,
      nvme_controller_id: 2,
      nvme_version: { string: '<1.2', value: 0 },
      nvme_number_of_namespaces: 1,
      smart_support: { available: true, enabled: true },
      smart_status: { passed: true, nvme: { value: 0 } },
      nvme_smart_health_information_log: {
        critical_warning: 0,
        temperature: 33,
        available_spare: 100,
        available_spare_threshold: 10,
        percentage_used: 2,
        data_units_read: 546637491,
        data_units_written: 272903651,
        host_reads: 15888683017,
        host_writes: 6175519199,
        controller_busy_time: 21850,
        power_cycles: 442,
        power_on_hours: 8149,
        unsafe_shutdowns: 127,
        media_errors: 0,
        num_err_log_entries: 0
      },
      temperature: { current: 33 },
      power_cycle_count: 442,
      power_on_time: { hours: 8149 },
      nvme_error_information_log: { size: 64, read: 16, unread: 0 }
    }
  },
  {
    device: 'disk2',
    type: 'USB',
    name: 'Micron_1100_MTFD',
    vendor: '',
    size: 2048408248320,
    bytesPerSector: null,
    totalCylinders: null,
    totalHeads: null,
    totalSectors: null,
    totalTracks: null,
    tracksPerCylinder: null,
    sectorsPerTrack: null,
    firmwareRevision: '',
    serialNum: '0123456789ABCDE',
    interfaceType: 'USB',
    smartStatus: 'not supported',
    temperature: null
  }
]
Time to complete: 1.066s

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant