node-exporter-textfile-collector-scripts icon indicating copy to clipboard operation
node-exporter-textfile-collector-scripts copied to clipboard

smartmon.sh: Make the script aware of multipath disks.

Open araujobsd opened this issue 2 years ago • 0 comments

On systems where disks are in multipath, we can have duplicate metrics of the same disk. One way to mitigate this issue is to compare the DISK SERIAL of the devices and create a list of non-duplicated disks. These changes have no impact on systems with no disks in multipath.

Example: Linux multipath) multipath output:

35000cca0bb7ca048 dm-12 HGST,HUS728T8TAL4204
size=7.3T features='0' hwhandler='0' wp=rw
`-+- policy='service-time 0' prio=0 status=active
  |- 15:0:4:0   sdk  8:160  active undef running
  `- 15:0:55:0  sdbj 67:208 active undef running

Before patch prom output:

storage-linux:/tmp# cat old.prom |grep sdk | head -1
smartmon_device_active{disk="/dev/sdk",type="scsi"} 1
storage-linux:/tmp# cat old.prom |grep sdbj | head -1
smartmon_device_active{disk="/dev/sdbj",type="scsi"} 1

After patch prom output:

storage-linux:/tmp# cat smartmon-new.prom |grep sdk | head -1
smartmon_device_active{disk="/dev/sdk",type="scsi"} 1
storage-linux:/tmp# cat smartmon-new.prom |grep sdbj | head -1
storage:/tmp#

FreeBSD multipath) multipath output:

Providers:
1. Name: multipath/disk-7804ff03
   Mediasize: 4000787025920 (3.6T)
   Sectorsize: 4096
   Mode: r1w1e1
   State: OPTIMAL
Consumers:
1. Name: da8
   Mediasize: 4000787030016 (3.6T)
   Sectorsize: 4096
   Mode: r2w2e2
   State: ACTIVE
2. Name: da50
   Mediasize: 4000787030016 (3.6T)
   Sectorsize: 4096
   Mode: r2w2e2
   State: PASSIVE

Before patch prom output:

storage-freebsd:/tmp# cat old.prom |grep da8 | head -1
smartmon_device_active{disk="/dev/da8",type="scsi"} 1
storage-freebsd:/tmp# cat old.prom |grep da50 | head -1
smartmon_device_active{disk="/dev/da50",type="scsi"} 1

After patch prom output:

storage-freebsd:/tmp# cat smartmon.prom | grep da8 | head -1
smartmon_device_active{disk="/dev/da8",type="scsi"} 1
storage-freebsd:/tmp# cat smartmon.prom | grep da50 | head -1
storage-freebsd:/tmp#

And while I'm here, don't hardcode the smartctl binary path, some OS like FreeBSD installs it in a different path.

araujobsd avatar Apr 20 '22 08:04 araujobsd