zbx-smartctl
zbx-smartctl copied to clipboard
On linux, name disks by ID
On linux, name disks by /dev/disk/by-id/xxx instead of /dev/xxx, since the latter may change after a reboot.
Thank you for this! Exactly what I needed, constant change of the name is a very annoying issue.
If my understanding of regex is correct, ^ata-
only searches for ata attached drives (SATA/IDE), as far as I know, SCSI attached drives should use ^scsi-
. That is consistent with SCSI and SAS drives. I don't know much about perl, if I would know, I would fix that my self. But maybe @rkarlsba can fix that and send another push request to @v-zhuravlev?
Cheers
- tschaerni
EDIT: I don't have NVMe drives to test it, but I would think they also have something other than ATA or SCSI, because they use a different protocol as far as I know.
I've tested it with a different regex, to also incorporate SCSI devices, a friend of mine made the regex, just replace it with: /^(?:ata|scsi)\-/
or /^(?:ata-|scsi-)/
both work, but I find the second one a bit more clear ;)
Cheers
- tschaerni
The code is/was
if ($devlink =~ /^ata-/) {
This can easily be replaced with
if ($devlink =~ /^(ata|scsi)-/) {
Don't know why you'd want ?: in front of that, or escaping -, it's a perfectly valid character in regex unless it's in []
I don't know that much about regex, I asked a friend of mine (perl dev with a lot of knowledge about regex) who gave me that regex, and it works after testing it.
btw. there are USB Harddrives with functional S.M.A.R.T, like the WD My Passport series. They identify as for example: usb-WD_My_Passport_25E1_XXXXXXXXXXXXXXXXXXXXXXXX-0:0
so, for USB Attached disks, the regex should also include USB: /^(?:ata-|scsi-|usb-)/
Cheers
- tschaerni
Sure - all we're waiting for is a pull…
@rkarlsba Can you implement the proposed change (/^(?:ata-|scsi-|usb-)/) in this pull request with another commit?
I beleive that should do