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) <noreply@anthropic.com>
This commit is contained in:
@@ -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,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user