I can list physical drives on all megaraid adapters using:
megacli -PDList -aALL
This will display an adapter # for each adapter, and then list the physical drives attached to them.
The individual devices in the PDList output also have a Device Id which is used for the smartctl command e.g. for device id 3:
smartctl -a -d sat+megaraid,3 /dev/sda
Both commands use the same device id, so no problem there. But how can we properly map the adapter # to a device node?
Running smartmontools-5.43-1.el6 on CentOS 6. Looking at the source code it seems it needs a bus number / host_no obtained from ioctl SG_GET_SCSI_ID
or SCSI_IOCTL_GET_BUS_NUMBER
on the named device node. Is this the same number used as "Adapter #" in MegaCLI output?
Actually in my case I could probably get away with hardcoding it to /dev/sda, but I'd like to know if there's a better way.