v-zhuravlev / zbx-smartctl

Templates and scripts for monitoring disks health with Zabbix and smartmontools
https://share.zabbix.com/storage-devices/smartmontools/smart-monitoring-with-smartmontools-lld
GNU General Public License v3.0
245 stars 127 forks source link

On linux, name disks by ID #106

Open rkarlsba opened 5 years ago

rkarlsba commented 5 years ago

On linux, name disks by /dev/disk/by-id/xxx instead of /dev/xxx, since the latter may change after a reboot.

fliker09 commented 5 years ago

Thank you for this! Exactly what I needed, constant change of the name is a very annoying issue.

tschaerni commented 4 years ago

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

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.

tschaerni commented 4 years ago

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

rkarlsba commented 4 years ago

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 []

tschaerni commented 4 years ago

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

rkarlsba commented 4 years ago

Sure - all we're waiting for is a pull…

Phlogi commented 4 years ago

@rkarlsba Can you implement the proposed change (/^(?:ata-|scsi-|usb-)/) in this pull request with another commit?

rkarlsba commented 4 years ago

I beleive that should do