["pipe", "w"]], $pipes);
if (!is_resource($proc)) {
return;
}
$data = stream_get_contents($pipes[1]);
fclose($pipes[1]);
$retval = proc_close($proc);
if ($retval == 0) {
return json_decode($data);
}
return $data . "\nProcess exited with $retval";
}
const NVME_DATA_UNIT = 1000 * 512;
const GIGABYTE = 10 ** 9;
const TERABYTE = 10 ** 12;
function data_unit($data)
{
$num = $data * NVME_DATA_UNIT;
if ($num < TERABYTE) {
return strval(round($num / GIGABYTE, 2)) . " GB";
}
return strval(round($num / TERABYTE, 2)) . " TB";
}
$data = get_data();
?>
Block Device Status
= $_GET["name"] ?>
";
echo $data;
echo "";
} else {
?>
| Property |
Value |
| smartctl = implode(
".",
$data->smartctl->version,
) ?> |
|
| Model Name |
= $data->model_name ?> |
| Temperature |
= $data->temperature->current ?> Celcius |
SMART data
| Property |
Value |
device->type == "nvme") {
$health = $data->nvme_smart_health_information_log; ?>
| Data Units Read |
= number_format($health->data_units_read) .
" (" .
data_unit($health->data_units_read) .
")" ?> |
| Data Units Written |
= number_format($health->data_units_written) .
" (" .
data_unit($health->data_units_written) .
")" ?> |
Original Output
= implode("\n", $data->smartctl->output) ?>