From 138af226d10fe61ea25c450288947363416346c4 Mon Sep 17 00:00:00 2001 From: Jonathan Miller Date: Fri, 22 May 2026 23:13:20 -0500 Subject: [PATCH] feat: add site size and total disk to filesystem health check Reports total_disk_mb and site_size_mb (images, media, tmp, cache, logs). Shows in Infrastructure table on Grafana dashboard. Co-Authored-By: Claude Opus 4.6 (1M context) --- src/Extension/MokoWaaS.php | 43 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/src/Extension/MokoWaaS.php b/src/Extension/MokoWaaS.php index 40207542..a746d163 100644 --- a/src/Extension/MokoWaaS.php +++ b/src/Extension/MokoWaaS.php @@ -1286,12 +1286,55 @@ class MokoWaaS extends CMSPlugin $status = 'degraded'; } + // Total disk and site size + $totalBytes = @disk_total_space(JPATH_ROOT); + $totalMb = $totalBytes !== false + ? round($totalBytes / 1048576) + : null; + + // Site directory size (quick estimate via common dirs) + $siteMb = null; + + try + { + $siteSize = 0; + + foreach (['images', 'media', 'tmp', 'cache', + 'administrator/logs', 'administrator/cache'] as $dir) + { + $path = JPATH_ROOT . '/' . $dir; + + if (is_dir($path)) + { + $iter = new \RecursiveIteratorIterator( + new \RecursiveDirectoryIterator( + $path, + \FilesystemIterator::SKIP_DOTS + ) + ); + + foreach ($iter as $file) + { + $siteSize += $file->getSize(); + } + } + } + + $siteMb = round($siteSize / 1048576); + } + catch (\Exception $e) + { + // Ignore — siteMb stays null + } + return [ 'status' => $status, 'tmp_writable' => $tmpWritable, 'log_writable' => $logWritable, 'cache_writable' => $cacheWritable, 'free_disk_mb' => $freeMb, + 'total_disk_mb' => $totalMb, + 'site_size_mb' => $siteMb, ]; }