Exclude an external shelf by explicit config, not by path shape
Testing on a second host showed the internal/external split cannot be inferred: iz-pve1's MD1200 sits behind its own HBA while iz-pve0's internal drives sit behind a SAS expander, so the previous "pci-*-scsi-*" glob matched every drive on one host and none on the other. DISK_EXCLUDE_PATTERN now names the shelf's HBA per host. Also fixes parse_disk_limit, which used awk's for-in over split fields and so returned 0 or 70 from "0/70" depending on iteration order. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
24
monitor.sh
24
monitor.sh
@@ -8,9 +8,17 @@
|
||||
|
||||
# ---------------------------------------------------------------- configuration
|
||||
|
||||
# Internal drives only. The DAS shelf enumerates behind a SAS expander
|
||||
# (*-sas-exp*) and has its own controller - it must not drive server fans.
|
||||
DISK_GLOB=${DISK_GLOB:-/dev/disk/by-path/pci-*-scsi-*}
|
||||
DISK_GLOB=${DISK_GLOB:-/dev/disk/by-path/*}
|
||||
|
||||
# Drives to leave alone, matched against the by-path link. Set this to the PCI
|
||||
# address of an external shelf's HBA on any host that has one.
|
||||
#
|
||||
# There is no reliable way to infer this. An external enclosure looks exactly
|
||||
# like an internal backplane from /dev/disk/by-path: iz-pve1's MD1200 sits
|
||||
# behind its own HBA at pci-0000:04:00.0, while iz-pve0's *internal* drives sit
|
||||
# behind a SAS expander at pci-0000:02:00.0. Guessing from "-sas-exp" picks up
|
||||
# the wrong set on one host or the other, so it has to be stated per host.
|
||||
DISK_EXCLUDE_PATTERN=${DISK_EXCLUDE_PATTERN:-}
|
||||
|
||||
# Each drive's fan ramp is derived from its own maximum operating temperature:
|
||||
# ramp starts at limit - DISK_RAMP_LOW_OFFSET
|
||||
@@ -53,6 +61,9 @@ disk_devices() {
|
||||
local link dev
|
||||
for link in $DISK_GLOB; do
|
||||
case "$link" in *-part*) continue ;; esac
|
||||
if [ -n "$DISK_EXCLUDE_PATTERN" ]; then
|
||||
case "$link" in *"$DISK_EXCLUDE_PATTERN"*) continue ;; esac
|
||||
fi
|
||||
[ -e "$link" ] || continue
|
||||
dev=$(readlink -f "$link")
|
||||
[ -b "$dev" ] && echo "$dev"
|
||||
@@ -73,8 +84,11 @@ parse_disk_temperature() {
|
||||
# smartctl -x output on stdin -> the drive's own maximum operating temperature.
|
||||
parse_disk_limit() {
|
||||
awk '
|
||||
/Min\/Max Temperature Limit/ { split($0, a, /[ \/]+/); for (i in a) if (a[i] ~ /^[0-9]+$/) v = a[i]; print v; exit }
|
||||
/Drive Trip Temperature/ { print $4; exit }'
|
||||
/Min\/Max Temperature Limit/ {
|
||||
if (match($0, /-?[0-9]+\/[0-9]+/)) { split(substr($0, RSTART, RLENGTH), a, "/"); print a[2] }
|
||||
exit
|
||||
}
|
||||
/Drive Trip Temperature/ { print $4; exit }'
|
||||
}
|
||||
|
||||
# -n standby: skip a sleeping drive rather than spinning it up to measure it.
|
||||
|
||||
Reference in New Issue
Block a user