['bind' => '10.200.27.20', 'port' => '5000'], 'gali' => ['bind' => '10.200.27.20', 'port' => '5000'], // same as cosmostat 'drive_health' => ['bind' => '172.25.1.18', 'port' => '5001'], // new API ]; /* ---------- Helper: fetch client details ---------- */ function fetchClientDetails(string $bindIp, string $port, string $path = '/client_details'): array { $url = "http://{$bindIp}:{$port}{$path}"; $ctx = stream_context_create([ 'http' => [ 'timeout' => 5, 'header' => "User-Agent: PHP/" . PHP_VERSION . "\r\n" ] ]); $json = @file_get_contents($url, false, $ctx); if ($json === false) { return []; // caller will handle empty case } $data = json_decode($json, true); if (!is_array($data)) { return []; } return $data; } /* ---------- Fetch client details ---------- */ $apiInfo = $apiConfig[$mode]; $clients = fetchClientDetails($apiInfo['bind'], $apiInfo['port']); /* ---------- Handle empty / error ---------- */ if ($clients === []) { die('

Could not retrieve data from the API for mode "' . h($mode) . '".

'); } /* ---------- Ensure each client has a short_id ---------- */ foreach ($clients as &$client) { if (!isset($client['short_id'])) { $client['short_id'] = substr($client['uuid'] ?? '', 0, 8); } } unset($client); /* ---------- Determine selected hosts (Drive Health only) ---------- */ $selectedHosts = $_GET['hosts'] ?? []; if ($mode === 'drive_health') { if (isset($_GET['action'])) { switch ($_GET['action']) { case 'all': $selectedHosts = array_column($clients, 'short_id'); break; case 'none': $selectedHosts = []; break; // 'apply' – nothing to do; $selectedHosts already contains the posted hosts } } } /* ---- Determine selected host ---- */ $selectedId = $_GET['host'] ?? ''; $selectedIdx = null; foreach ($clients as $idx => $client) { if (isset($client['short_id']) && $client['short_id'] === $selectedId) { $selectedIdx = $idx; break; } } if ($selectedIdx === null) { // Default to the first client (if any) $selectedIdx = 0; $selectedId = $clients[$selectedIdx]['short_id'] ?? ''; } #global $clients, $client, $properties, $systemProperties, $systemComponents, $selectedHost, $selectedHosts, $selectedId, $selectedIdx; $client = $clients[$selectedIdx] ?? null; $properties = $client['client_properties'][0] ?? []; $systemProperties = $properties['system_properties'] ?? []; $systemComponents = $properties['system_components'] ?? []; $selectedHost = $clients[$selectedIdx]['hostname'] ?? 'Unknown'; /* ---- ---- */ /* ---- Sidebar Renderer ---- */ function renderSidebar(string $mode){ global $clients, $client, $properties, $systemProperties, $systemComponents, $selectedHost, $selectedHosts, $selectedId, $selectedIdx; $modes = [ 'cosmostat' => 'Cosmostat', 'gali' => 'Shuttle Gali', 'drive_health' => 'Drive Health', ]; ?>

No hosts selected.

'; return; } echo '
'; foreach ($selectedHosts as $sid) { // Find the client that matches this short_id $c = null; foreach ($clients as $cl) { if ($cl['short_id'] === $sid) { $c = $cl; break; } } if ($c === null) continue; // safety $hostname = $c['name'] ?? 'Unknown'; echo '
'; echo '

Drive Health - ' . h($hostname) . '

IP: '.h($c['ip']).'
Timestamp: '.date('F j, Y g:i a', (int) $c['timestamp']).'

'; if (isset($c['drives']) && is_array($c['drives']) && count($c['drives']) > 0) { echo ''; echo ' '; echo ' '; foreach ($c['drives'] as $drive) { echo ' '; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ' '; } echo '
Drive LetterModelCapacityPower On HoursHost WritesWear Level
' . h($drive['drive_letter'] ?? '') . '' . h($drive['model'] ?? '') . '' . h($drive['capacity'] ?? '') . '' . h($drive['power_on_hours'] ?? '') . '' . h($drive['host_writes'] ?? '') . '' . h($drive['wear_level'] ?? '') . '
'; } else { echo '

No drive data available for this host.

'; } echo '
'; } echo '
'; return; } ?>

Matt-Cloud Cosmostat Dashboard

This dashboard shows the local Matt-Cloud system stats.

Component Desriptor

To view the component descriptor, you may
curl -s https:///descriptor

This will return the entire JSON descriptor variable.
The endpoint agent uses this descriptor to build out its local System Object.
The agent then reports back to the Cosmostat Server with all the data found in the descriptor.
Full Source Code can be found at its Gitea page.

System Properties

Live System Metrics

Connecting...

Components

Shuttle Gali

Cosmostat - <?= h($selectedHost) ?>