Improve organization & SAS support
This commit is contained in:
+17
-36
@@ -1,4 +1,7 @@
|
||||
<?php
|
||||
require "components/nvme.php";
|
||||
require "components/sat.php";
|
||||
|
||||
if ($_GET["name"] == null) {
|
||||
header("Location: /");
|
||||
exit();
|
||||
@@ -6,7 +9,14 @@ if ($_GET["name"] == null) {
|
||||
|
||||
function get_data()
|
||||
{
|
||||
$cmd = ["sudo", "-n", "/usr/local/sbin/smartctl-proxy.sh", $_GET["name"]];
|
||||
$cmd = [
|
||||
"sudo",
|
||||
"-n",
|
||||
"smartctl",
|
||||
"--json=oc",
|
||||
"-a",
|
||||
"/dev/" . $_GET["name"],
|
||||
];
|
||||
$proc = proc_open($cmd, [1 => ["pipe", "w"]], $pipes);
|
||||
|
||||
if (!is_resource($proc)) {
|
||||
@@ -17,10 +27,7 @@ function get_data()
|
||||
fclose($pipes[1]);
|
||||
$retval = proc_close($proc);
|
||||
|
||||
if ($retval == 0) {
|
||||
return json_decode($data);
|
||||
}
|
||||
return $data . "\nProcess exited with $retval";
|
||||
return json_decode($data);
|
||||
}
|
||||
|
||||
const NVME_DATA_UNIT = 1000 * 512;
|
||||
@@ -81,37 +88,11 @@ $data = get_data();
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<h2>SMART data</h2>
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Property</th>
|
||||
<th>Value</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php if ($data->device->type == "nvme") {
|
||||
$health = $data->nvme_smart_health_information_log; ?>
|
||||
<tr>
|
||||
<td>Data Units Read</td>
|
||||
<td><?= number_format($health->data_units_read) .
|
||||
" (" .
|
||||
data_unit($health->data_units_read) .
|
||||
")" ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Data Units Written</td>
|
||||
<td><?= number_format($health->data_units_written) .
|
||||
" (" .
|
||||
data_unit($health->data_units_written) .
|
||||
")" ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
} ?>
|
||||
<tr></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php if ($data->device->type == "nvme") {
|
||||
nvme_data($data);
|
||||
} elseif ($data->device->type == "sat") {
|
||||
sat_data($data);
|
||||
} ?>
|
||||
|
||||
<details>
|
||||
<summary>Original Output</summary>
|
||||
|
||||
Reference in New Issue
Block a user