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

[BUG] Incorrect query for IOService devices on MacOS #742

Open
TheNoim opened this issue Jan 19, 2025 · 0 comments
Open

[BUG] Incorrect query for IOService devices on MacOS #742

TheNoim opened this issue Jan 19, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@TheNoim
Copy link

TheNoim commented Jan 19, 2025

Describe the bug
I have multiple HDDs connected via thunderbolt to nvme -> nvme to sata. smartctl lists them just fine and I can also manual query them with smartctl --info --json. But, the collector incorrectly crafts the command for this.

To better explain the issue, this is one of the HDDs (via smartctl --scan --json)

{
      "name": "IOService:/AppleARMPE/arm-io@10F00000/AppleH16GFamilyIO/apciec3@80000000/AppleT8132PCIeC/pcic3-bridge@0/IOPP/pci-bridge@0/IOPP/pci-bridge@0/IOPP/pci1b21,1166@0/AppleAHCI/PRT2@2/IOAHCIDevice@0/AppleAHCIDiskDriver/IOAHCIBlockStorageDevice",
      "info_name": "IOService:/AppleARMPE/arm-io@10F00000/AppleH16GFamilyIO/apciec3@80000000/AppleT8132PCIeC/pcic3-bridge@0/IOPP/pci-bridge@0/IOPP/pci-bridge@0/IOPP/pci1b21,1166@0/AppleAHCI/PRT2@2/IOAHCIDevice@0/AppleAHCIDiskDriver/IOAHCIBlockStorageDevice",
      "type": "ata",
      "protocol": "ATA"
}

You can see, the name is a bit weird. This is how you query the device:

smartctl --info --json "IOService:/AppleARMPE/arm-io@10F00000/AppleH16GFamilyIO/apciec3@80000000/AppleT8132PCIeC/pcic3-bridge@0/IOPP/pci-bridge@0/IOPP/pci-bridge@0/IOPP/pci1b21,1166@0/AppleAHCI/PRT2@2/IOAHCIDevice@0/AppleAHCIDiskDriver/IOAHCIBlockStorageDevice"

This results in the following correct output:

{
  "json_format_version": [
    1,
    0
  ],
  "smartctl": {
    "version": [
      7,
      4
    ],
    "pre_release": false,
    "svn_revision": "5530",
    "platform_info": "Darwin 24.2.0 arm64",
    "build_info": "(local build)",
    "argv": [
      "smartctl",
      "--info",
      "--json",
      "IOService:/AppleARMPE/arm-io@10F00000/AppleH16GFamilyIO/apciec3@80000000/AppleT8132PCIeC/pcic3-bridge@0/IOPP/pci-bridge@0/IOPP/pci-bridge@0/IOPP/pci1b21,1166@0/AppleAHCI/PRT2@2/IOAHCIDevice@0/AppleAHCIDiskDriver/IOAHCIBlockStorageDevice"
    ],
    "drive_database_version": {
      "string": "7.3/5528"
    },
    "exit_status": 0
  },
  "local_time": {
    "time_t": 1737285973,
    "asctime": "Sun Jan 19 12:26:13 2025 CET"
  },
  "device": {
    "name": "IOService:/AppleARMPE/arm-io@10F00000/AppleH16GFamilyIO/apciec3@80000000/AppleT8132PCIeC/pcic3-bridge@0/IOPP/pci-bridge@0/IOPP/pci-bridge@0/IOPP/pci1b21,1166@0/AppleAHCI/PRT2@2/IOAHCIDevice@0/AppleAHCIDiskDriver/IOAHCIBlockStorageDevice",
    "info_name": "IOService:/AppleARMPE/arm-io@10F00000/AppleH16GFamilyIO/apciec3@80000000/AppleT8132PCIeC/pcic3-bridge@0/IOPP/pci-bridge@0/IOPP/pci-bridge@0/IOPP/pci1b21,1166@0/AppleAHCI/PRT2@2/IOAHCIDevice@0/AppleAHCIDiskDriver/IOAHCIBlockStorageDevice",
    "type": "ata",
    "protocol": "ATA"
  },
  "model_family": "Toshiba MG08ACA... Enterprise Capacity HDD",
  "model_name": "TOSHIBA MG08ACA16TE",
  "serial_number": "[Removed]",
  "wwn": {
    "naa": 5,
    "oui": 57,
    "id": [Removed]
  },
  "firmware_version": "0103",
  "user_capacity": {
    "blocks": 31251759104,
    "bytes": 16000900661248
  },
  "logical_block_size": 512,
  "physical_block_size": 4096,
  "rotation_rate": 7200,
  "form_factor": {
    "ata_value": 2,
    "name": "3.5 inches"
  },
  "trim": {
    "supported": false
  },
  "in_smartctl_database": true,
  "ata_version": {
    "string": "ACS-3 T13/2161-D revision 5",
    "major_value": 2040,
    "minor_value": 109
  },
  "sata_version": {
    "string": "SATA 3.3",
    "value": 511
  },
  "interface_speed": {
    "max": {
      "sata_value": 14,
      "string": "6.0 Gb/s",
      "units_per_second": 60,
      "bits_per_unit": 100000000
    },
    "current": {
      "sata_value": 3,
      "string": "6.0 Gb/s",
      "units_per_second": 60,
      "bits_per_unit": 100000000
    }
  },
  "smart_support": {
    "available": true,
    "enabled": true
  }
}

This is how the collector tries to execute the info command:

smartctl --info --json /dev/ioservice:/applearmpe/arm-io@10f00000/appleh16gfamilyio/apciec3@80000000/applet8132pciec/pcic3-bridge@0/iopp/pci-bridge@0/iopp/pci-bridge@0/iopp/pci1b21,1166@0/appleahci/prt1@1/ioahcidevice@0/appleahcidiskdriver/ioahciblockstoragedevice

The collector adds the /dev/ prefix which is wrong and results in a failure.

Expected behavior

If the device name starts with IOService on MacOS, don't add the /dev/ prefix.

Log Files

INFO[0000] Verifying required tools                      type=metrics
INFO[0000] Executing command: smartctl --scan --json     type=metrics
INFO[0003] Executing command: smartctl --info --json /dev/ioservice:/applearmpe/arm-io@10f00000/appleh16gfamilyio/apciec3@80000000/applet8132pciec/pcic3-bridge@0/iopp/pci-bridge@0/iopp/pci-bridge@0/iopp/pci1b21,1166@0/appleahci/prt4@4/ioahcidevice@0/appleahcidiskdriver/ioahciblockstoragedevice  type=metrics
ERRO[0003] Could not retrieve device information for ioservice:/applearmpe/arm-io@10f00000/appleh16gfamilyio/apciec3@80000000/applet8132pciec/pcic3-bridge@0/iopp/pci-bridge@0/iopp/pci-bridge@0/iopp/pci1b21,1166@0/appleahci/prt4@4/ioahcidevice@0/appleahcidiskdriver/ioahciblockstoragedevice: exit status 1  type=metrics
INFO[0003] Executing command: smartctl --info --json --device nvme /dev/ioservice:/applearmpe/arm-io@10f00000/appleh16gfamilyio/ans@81600000/appleascwrapv6/iop-ans-nub/rtbuddy(ans2)/rtbuddyservice/appleans3cgv2controller/ns_01@1  type=metrics
ERRO[0003] Could not retrieve device information for ioservice:/applearmpe/arm-io@10f00000/appleh16gfamilyio/ans@81600000/appleascwrapv6/iop-ans-nub/rtbuddy(ans2)/rtbuddyservice/appleans3cgv2controller/ns_01@1: exit status 2  type=metrics
INFO[0003] Executing command: smartctl --info --json /dev/ioservice:/applearmpe/arm-io@10f00000/appleh16gfamilyio/apciec3@80000000/applet8132pciec/pcic3-bridge@0/iopp/pci-bridge@0/iopp/pci-bridge@0/iopp/pci1b21,1166@0/appleahci/prt2@2/ioahcidevice@0/appleahcidiskdriver/ioahciblockstoragedevice  type=metrics
ERRO[0003] Could not retrieve device information for ioservice:/applearmpe/arm-io@10f00000/appleh16gfamilyio/apciec3@80000000/applet8132pciec/pcic3-bridge@0/iopp/pci-bridge@0/iopp/pci-bridge@0/iopp/pci1b21,1166@0/appleahci/prt2@2/ioahcidevice@0/appleahcidiskdriver/ioahciblockstoragedevice: exit status 1  type=metrics
INFO[0003] Executing command: smartctl --info --json /dev/ioservice:/applearmpe/arm-io@10f00000/appleh16gfamilyio/apciec3@80000000/applet8132pciec/pcic3-bridge@0/iopp/pci-bridge@0/iopp/pci-bridge@0/iopp/pci1b21,1166@0/appleahci/prt0@0/ioahcidevice@0/appleahcidiskdriver/ioahciblockstoragedevice  type=metrics
ERRO[0003] Could not retrieve device information for ioservice:/applearmpe/arm-io@10f00000/appleh16gfamilyio/apciec3@80000000/applet8132pciec/pcic3-bridge@0/iopp/pci-bridge@0/iopp/pci-bridge@0/iopp/pci1b21,1166@0/appleahci/prt0@0/ioahcidevice@0/appleahcidiskdriver/ioahciblockstoragedevice: exit status 1  type=metrics
INFO[0003] Executing command: smartctl --info --json /dev/ioservice:/applearmpe/arm-io@10f00000/appleh16gfamilyio/apciec3@80000000/applet8132pciec/pcic3-bridge@0/iopp/pci-bridge@0/iopp/pci-bridge@0/iopp/pci1b21,1166@0/appleahci/prt1@1/ioahcidevice@0/appleahcidiskdriver/ioahciblockstoragedevice  type=metrics
ERRO[0003] Could not retrieve device information for ioservice:/applearmpe/arm-io@10f00000/appleh16gfamilyio/apciec3@80000000/applet8132pciec/pcic3-bridge@0/iopp/pci-bridge@0/iopp/pci-bridge@0/iopp/pci1b21,1166@0/appleahci/prt1@1/ioahcidevice@0/appleahcidiskdriver/ioahciblockstoragedevice: exit status 1  type=metrics
INFO[0003] Executing command: smartctl --info --json /dev/ioservice:/applearmpe/arm-io@10f00000/appleh16gfamilyio/apciec3@80000000/applet8132pciec/pcic3-bridge@0/iopp/pci-bridge@0/iopp/pci-bridge@0/iopp/pci1b21,1166@0/appleahci/prt3@3/ioahcidevice@0/appleahcidiskdriver/ioahciblockstoragedevice  type=metrics
ERRO[0003] Could not retrieve device information for ioservice:/applearmpe/arm-io@10f00000/appleh16gfamilyio/apciec3@80000000/applet8132pciec/pcic3-bridge@0/iopp/pci-bridge@0/iopp/pci-bridge@0/iopp/pci1b21,1166@0/appleahci/prt3@3/ioahcidevice@0/appleahcidiskdriver/ioahciblockstoragedevice: exit status 1  type=metrics
INFO[0003] Executing command: smartctl --info --json /dev/disk0  type=metrics
INFO[0003] Using WWN Fallback                            type=metrics
INFO[0007] Executing command: smartctl --info --json /dev/disk1  type=metrics
INFO[0007] Using WWN Fallback                            type=metrics
INFO[0010] Executing command: smartctl --info --json /dev/disk2  type=metrics
INFO[0010] Using WWN Fallback                            type=metrics
INFO[0014] Executing command: smartctl --info --json /dev/disk3  type=metrics
INFO[0014] Using WWN Fallback                            type=metrics
INFO[0017] Executing command: smartctl --info --json /dev/disk6  type=metrics
ERRO[0017] Could not retrieve device information for disk6: exit status 2  type=metrics
INFO[0017] Executing command: smartctl --info --json /dev/disk7  type=metrics
ERRO[0017] Could not retrieve device information for disk7: exit status 2  type=metrics
INFO[0017] Sending detected devices to API, for filtering & validation  type=metrics
INFO[0018] Collecting smartctl results for disk0         type=metrics
INFO[0018] Executing command: smartctl --xall --json --device nvme /dev/disk0  type=metrics
ERRO[0018] smartctl returned an error code (4) while processing disk0  type=metrics
ERRO[0018] smartctl detected a checksum error            type=metrics
INFO[0018] Publishing smartctl results for 0ba028496204a606  type=metrics
INFO[0018] Collecting smartctl results for disk1         type=metrics
INFO[0018] Executing command: smartctl --xall --json --device nvme /dev/disk1  type=metrics
ERRO[0018] smartctl returned an error code (4) while processing disk1  type=metrics
ERRO[0018] smartctl detected a checksum error            type=metrics
INFO[0018] Publishing smartctl results for 0ba028496204a606  type=metrics
INFO[0018] Collecting smartctl results for disk2         type=metrics
INFO[0018] Executing command: smartctl --xall --json --device nvme /dev/disk2  type=metrics
ERRO[0018] smartctl returned an error code (4) while processing disk2  type=metrics
ERRO[0018] smartctl detected a checksum error            type=metrics
INFO[0018] Publishing smartctl results for 0ba028496204a606  type=metrics
INFO[0018] Collecting smartctl results for disk3         type=metrics
INFO[0018] Executing command: smartctl --xall --json --device nvme /dev/disk3  type=metrics
ERRO[0018] smartctl returned an error code (4) while processing disk3  type=metrics
ERRO[0018] smartctl detected a checksum error            type=metrics
INFO[0018] Publishing smartctl results for 0ba028496204a606  type=metrics
INFO[0018] Main: Completed                               type=metrics
@TheNoim TheNoim added the bug Something isn't working label Jan 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant