counts, storage usage, engine version, ping status */ declare(strict_types=1); require __DIR__ . '/../include/bootstrap.php'; $action = $_GET['action'] ?? ''; switch ($action) { case 'summary': podman_json_response(system_summary($client, $podmanConfig)); break; default: podman_json_error("Unknown action '{$action}'", 400); } /** @return array */ function system_summary(PodmanClient $client, PodmanConfig $config): array { if (!$client->ping()) { return [ 'reachable' => false, 'socketPath' => $config->socketPath, ]; } $containers = $client->listContainers(true); $running = 0; foreach ($containers as $c) { if (strtolower((string) ($c['State'] ?? '')) === 'running') { $running++; } } $pods = $client->listPods(); $images = $client->listImages(); $volumes = $client->listVolumes(); $networks = $client->listNetworks(); $info = $client->info(); $df = $client->systemDf(); $imagesSize = 0; foreach (($df['Images'] ?? []) as $img) { $imagesSize += (int) ($img['Size'] ?? 0); } return [ 'reachable' => true, 'socketPath' => $config->socketPath, 'podmanVersion' => $info['Version']['Version'] ?? null, 'containers' => [ 'total' => count($containers), 'running' => $running, ], 'pods' => count($pods), 'images' => count($images), 'volumes' => count($volumes), 'networks' => count($networks), 'storage' => [ 'imagesSizeBytes' => $imagesSize, 'imagesSizeFormatted' => podman_format_bytes($imagesSize), ], ]; }