From 276e04fd83f89c79752d2ce44a871dc00632e435 Mon Sep 17 00:00:00 2001 From: Andreas Bachlechner <62039342+bachandi@users.noreply.github.com> Date: Sat, 9 Oct 2021 23:58:40 +0200 Subject: [PATCH] Add respect_standby to disk.pm to avoid waking up sleeping disks. --- lib/disk.pm | 9 +++++++-- man/man5/monitorix.conf.5 | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/disk.pm b/lib/disk.pm index 6fa093c..b32efce 100644 --- a/lib/disk.pm +++ b/lib/disk.pm @@ -182,6 +182,7 @@ sub disk_update { my ($package, $config, $debug) = @_; my $rrd = $config->{base_lib} . $package . ".rrd"; my $disk = $config->{disk}; + my $respect_standby = lc($disk->{respect_standby} || "") eq "y" ? 1 : 0; my $temp; my $smart1; @@ -208,8 +209,12 @@ sub disk_update { $d = abs_path(dirname($d) . "/" . readlink($d)); chomp($d); } + my $smartctl_options = "-A"; + if($respect_standby) { + $smartctl_options .= " -n standby"; + } - open(IN, "smartctl -A $d |"); + open(IN, "smartctl $smartctl_options $d |"); while() { if(/^ 5/ && /Reallocated_Sector_Ct/) { my @tmp = split(' ', $_); @@ -243,7 +248,7 @@ sub disk_update { } } close(IN); - if(!$temp) { + if(!$temp && !$respect_standby) { if(open(IN, "hddtemp -wqn $d |")) { $temp = ; close(IN); diff --git a/man/man5/monitorix.conf.5 b/man/man5/monitorix.conf.5 index e334242..27145c8 100644 --- a/man/man5/monitorix.conf.5 +++ b/man/man5/monitorix.conf.5 @@ -1354,7 +1354,7 @@ This is a list of groups of disk drives that you want to monitor. Each group wil .P WARNING: Every time the number of groups in this option changes, Monitorix will resize the \fIdisk.rrd\fP file accordingly, removing all historical data. .P -To collect the disk drive temperatures and health the \fIsmartmontools\fP or the \fIhddtemp\fP command are required. +To collect the disk drive temperatures and health the \fIsmartmontools\fP or the \fIhddtemp\fP command are required. \fIsmartmontools\fP will wake up sleeping disk. To avoid this set \fIrespect_standby = y\fP. .P It is recommended that you first check if either \fIsmartctl\fP(8) or \fIhddtemp\fP are able to collect data from the disk drive(s) that you plan to monitor. You may test this with the following command: .P