From 5cd92f2b555dda8421150a34e6da68f1116118c8 Mon Sep 17 00:00:00 2001 From: Tim Connors Date: Wed, 7 Dec 2022 12:52:59 +1100 Subject: [PATCH] Include hddtemp and upadte instructions for using it --- hddtemp | 38 ++++++++++++++++++++++++++++++++++++++ readme.md | 7 ++++++- 2 files changed, 44 insertions(+), 1 deletion(-) create mode 100755 hddtemp diff --git a/hddtemp b/hddtemp new file mode 100755 index 0000000..2a2f00b --- /dev/null +++ b/hddtemp @@ -0,0 +1,38 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +# much of this stolen from /etc/munin/plugins/hddtemp_smartctl + +$ENV{PATH}="$ENV{PATH}:/usr/sbin:/sbin"; + +foreach my $drive (@ARGV) { + my $sense=`sdparm --command=sense $drive 2>/dev/null`; + if (!($sense =~ /Standby/)) { + my $output=`smartctl -A -i --nocheck=standby $drive`; + + my $model=""; + if ($output =~ /(Model Number|Device Model):\s*(.*)/) { + $model="$2: "; + } + if ($output =~ /Current Drive Temperature:\s*(\d+)/) { + print "$drive: $model$1°C\n"; + } elsif ($output =~ /^(194 Temperature_(Celsius|Internal).*)/m) { + my @F = split /\s+/, $1; + print "$drive: $model$F[9]°C\n"; + } elsif ($output =~ /^(231 Temperature_Celsius.*)/m) { + my @F = split ' ', $1; + print "$drive: $model$F[9]°C\n"; + } elsif ($output =~ /^(190 (Airflow_Temperature_Cel|Temperature_Case).*)/m) { + my @F = split ' ', $1; + print "$drive: $model$F[9]°C\n"; + } elsif ($output =~ /Temperature:\s*(\d+) Celsius/) { + print "$drive: $model$1°C\n"; + } else { + print "$drive: Smart not available\n"; + } + } else { + print "$drive: Sleeping. Temperature not available\n"; + }; +} diff --git a/readme.md b/readme.md index fe2eb6c..fbf53a8 100755 --- a/readme.md +++ b/readme.md @@ -28,12 +28,17 @@ believe it's only 26 in my un-air conditioned study). # installation (debian/proxmox) -sudo apt install liblist-moreutils-perl hddtemp lm-sensors ipmitool +``` +sudo apt install liblist-moreutils-perl lm-sensors ipmitool +# I also use my own hddtemp, since debian's hddtemp itself is unmaintained and can't deal with SAS drives and often spins up drives that are spun down: +sudo apt remove hddtemp sudo cp -p fan-speed-control.pl /usr/local/bin +sudo cp -p hddtemp /usr/local/bin sudo cp -p fan-speed-control.service /etc/systemd/system/fan-speed-control.service sudo systemctl daemon-reload sudo systemctl --now enable fan-speed-control.service +``` [Reddit discussion](https://www.reddit.com/r/homelab/comments/ed6w7y)