87 lines
2.4 KiB
PHP
87 lines
2.4 KiB
PHP
<?php
|
|
// Function to fetch SSD information from the API
|
|
function fetchSSDData() {
|
|
$url = 'http://172.17.0.1:5000/drives';
|
|
$options = [
|
|
'http' => [
|
|
'header' => "Content-type: application/json\r\n",
|
|
'method' => 'GET',
|
|
],
|
|
];
|
|
|
|
$context = stream_context_create($options);
|
|
$result = file_get_contents($url, false, $context);
|
|
|
|
if ($result === FALSE) {
|
|
die('Error Fetching data');
|
|
}
|
|
|
|
return json_decode($result, true); // Decode JSON as an associative array
|
|
}
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<title>SSD Health Dashboard</title>
|
|
<link rel="stylesheet" href="styles.css">
|
|
</head>
|
|
<body>
|
|
<div class="container">
|
|
<button onclick="window.location.reload();" class="title-button"><h1>SSD Health Dashboard</h1></button>
|
|
<?php
|
|
$i=0;
|
|
$ssdData = fetchSSDData(); // Fetch data from the API
|
|
echo '<div class="group-columns">';
|
|
foreach ($ssdData as $ssd):
|
|
if ($i % 2 == 0) {
|
|
echo '</div><div class="group-columns">';
|
|
}
|
|
echo <<<EOL
|
|
<div class="meter">
|
|
<table>
|
|
<tr><td align ="right">
|
|
Disk ID:
|
|
</td><td align ="left">
|
|
{$ssd['id']}
|
|
</td></tr><tr>
|
|
<tr><td align ="right">
|
|
Model String:
|
|
</td><td align ="left">
|
|
{$ssd['model']}
|
|
</td></tr><tr>
|
|
<tr><td align ="right">
|
|
Serial Number:
|
|
</td><td align ="left">
|
|
{$ssd['serial']}
|
|
</td></tr><tr>
|
|
<tr><td align ="right">
|
|
TB Written:
|
|
</td><td align ="left">
|
|
{$ssd['TBW']}
|
|
</td></tr><tr>
|
|
<tr><td align ="right">
|
|
Disk Capacity:
|
|
</td><td align ="left">
|
|
{$ssd['capacity']}
|
|
</td></tr><tr>
|
|
<tr><td align ="right">
|
|
Disk Flavor:
|
|
</td><td align ="left">
|
|
{$ssd['flavor']}
|
|
</td></tr><tr>
|
|
<tr><td align ="right">
|
|
SMART Result:
|
|
</td><td align ="left">
|
|
{$ssd['smart']}
|
|
</td></tr>
|
|
</table>
|
|
</div>
|
|
EOL;
|
|
$i++;
|
|
endforeach;
|
|
echo '</div>';
|
|
?>
|
|
</div>
|
|
</body>
|
|
</html>
|