Skip to content

Commit

Permalink
Remove out-of-band invokation of smartctl
Browse files Browse the repository at this point in the history
  • Loading branch information
limetech committed Jul 12, 2020
1 parent ac8bf28 commit 6f8507e
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 13 deletions.
2 changes: 1 addition & 1 deletion plugins/dynamix/include/DashUpdate.php
Expand Up @@ -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"])) {
Expand Down
3 changes: 0 additions & 3 deletions plugins/dynamix/include/DeviceList.php
Expand Up @@ -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);
}
}
Expand Down
4 changes: 0 additions & 4 deletions plugins/dynamix/include/Helpers.php
Expand Up @@ -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'")!='';
}
Expand Down
5 changes: 0 additions & 5 deletions plugins/dynamix/scripts/monitor
Expand Up @@ -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;
Expand Down Expand Up @@ -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)";
Expand Down

0 comments on commit 6f8507e

Please sign in to comment.