From 6f8507e5474e9b77fef836ee7379a1bee25a7a5b Mon Sep 17 00:00:00 2001 From: Tom Mortensen Date: Sun, 12 Jul 2020 08:57:39 -0700 Subject: [PATCH] Remove out-of-band invokation of smartctl --- plugins/dynamix/include/DashUpdate.php | 2 +- plugins/dynamix/include/DeviceList.php | 3 --- plugins/dynamix/include/Helpers.php | 4 ---- plugins/dynamix/scripts/monitor | 5 ----- 4 files changed, 1 insertion(+), 13 deletions(-) diff --git a/plugins/dynamix/include/DashUpdate.php b/plugins/dynamix/include/DashUpdate.php index 3b607ed59..b470f1e4d 100644 --- a/plugins/dynamix/include/DashUpdate.php +++ b/plugins/dynamix/include/DashUpdate.php @@ -177,7 +177,7 @@ function device_smart(&$disk, $name, &$fail, &$smart) { $text = _('healthy'); $color = 'green'; $file = "state/smart/$name"; - if (file_exists("$file.ssa") && in_array(file_get_contents("$file.ssa"),$failed)) { + if (file_exists("$file") && exec("grep -Pom1 '^SMART.*: \K[A-Z]+' ".escapeshellarg($file)." |tr -d '\n' 2>/dev/null", $ssa) && in_array("$ssa",$failed)) { $title = "S.M.A.R.T health-check failed\n"; $thumb = 'thumbs-o-down'; $color = 'red'; $text = 'fail'; $fail++; } else { if (empty($saved["smart"]["$name.ack"])) { diff --git a/plugins/dynamix/include/DeviceList.php b/plugins/dynamix/include/DeviceList.php index 1f5e5de19..032a857ca 100644 --- a/plugins/dynamix/include/DeviceList.php +++ b/plugins/dynamix/include/DeviceList.php @@ -281,9 +281,6 @@ function read_disk($name, $part) { return disk_active($port) ? 'blue-on' : 'blue-blink'; case 'temp': $smart = "/var/local/emhttp/smart/$name"; - $type = $var['smType'] ?? ''; - // read and store SMART attributes of unassigned devices, take SMART poll interval and active disk status into consideration - if (poll_timer($smart) && disk_active($port)) exec("smartctl -A $type /dev/$port >".escapeshellarg($smart)); return read_temp($smart); } } diff --git a/plugins/dynamix/include/Helpers.php b/plugins/dynamix/include/Helpers.php index b22fee8af..67dc2c508 100644 --- a/plugins/dynamix/include/Helpers.php +++ b/plugins/dynamix/include/Helpers.php @@ -252,10 +252,6 @@ function cpu_list() { exec('cat /sys/devices/system/cpu/*/topology/thread_siblings_list|sort -nu', $cpus); return $cpus; } -function poll_timer($file) { - global $var; - return !file_exists($file) || time()-filemtime($file)>=$var['poll_attributes']; -} function disk_active($port) { return exec("hdparm -C /dev/$port|grep -Eom1 'active|unknown'")!=''; } diff --git a/plugins/dynamix/scripts/monitor b/plugins/dynamix/scripts/monitor index d1f89207f..1a07ce773 100755 --- a/plugins/dynamix/scripts/monitor +++ b/plugins/dynamix/scripts/monitor @@ -132,9 +132,6 @@ function check_smart($name,$port,$text,$info) { break; } } - $file .= '.ssa'; -// read and store SMART status (PASSED/FAILED) of all devices, take SMART poll interval and active disk status into consideration - if (poll_timer($file) && disk_active($port)) exec("smartctl -H $type /dev/$port|grep -Pom1 '^SMART.*: \K[A-Z]+'|tr -d '\n' >".escapeshellarg($file)." &"); } function check_usage($name,$used,$text,$info) { global $notify,$disks,$saved,$display,$server; @@ -229,8 +226,6 @@ foreach ($devs as $dev) { $smart = "/var/local/emhttp/smart/$name"; $type = $var['smType'] ?? ''; $port = port_name($name); -// read and store SMART attributes of unassigned devices, take SMART poll interval and active disk status into consideration - if (poll_timer($smart) && disk_active($port)) exec("smartctl -A $type /dev/$port >".escapeshellarg($smart)); $temp = read_temp($smart); $text = "device $name"; $info = !empty($dev['id']) ? "{$dev['id']} ($name)": "No device identification ($name)";