0 ? floor(log($bytes, 1024)) : 0; $factor = min($factor, count($units) - 1); return sprintf("%.{$decimals}f %s", $bytes / (1024 ** $factor), $units[$factor]); } if (!file_exists($stats_file)) { $stats = [ "storage" => $disks, ]; foreach ($stats["storage"] as $disk_name => $disk_stats) { $stats["storage"][$disk_name]["total_bytes"] = disk_total_space($disk_stats["mount_point"]); $stats["storage"][$disk_name]["used_bytes"] = (int) trim(shell_exec('df --block-size=1 --output=used ' . escapeshellarg($disk_stats["mount_point"]) . ' | tail -1')); $other_used = $stats["storage"][$disk_name]["used_bytes"]; if (!isset($disk_stats["categories"])) { $disk_stats["categories"] = []; } foreach ($disk_stats["categories"] as $category_name => $category_stats) { $paths = $category_stats["path"]; if (!is_array($category_stats["path"])) { $paths = [$category_stats["path"]]; } $stats["storage"][$disk_name]["categories"][$category_name]["bytes"] = 0; foreach ($paths as $path) { $bytes = (int) shell_exec('du -sb ' . escapeshellarg($path) . ' | cut -f1'); $stats["storage"][$disk_name]["categories"][$category_name]["bytes"] += $bytes; } $other_used -= $stats["storage"][$disk_name]["categories"][$category_name]["bytes"]; } $stats["storage"][$disk_name]["categories"]["Other"] = [ "color" => "white", "bytes" => max(0, $other_used), ]; } $stats["time"] = time(); $stats = file_put_contents($stats_file, json_encode($stats), LOCK_EX); } $stats = json_decode(file_get_contents($stats_file), true); if ($stats["time"] + $auto_recalculate_seconds < time()) { header("Location: ?recalculate"); exit(0); } ?> Stats

Storage

$disk_stats): ?>

%

$category_stats): ?>
%; --color: ">
$category_stats): ?>
">

%

Actions