diff --git a/admin/server.php b/admin/server.php
index 0d21841..0676a5e 100644
--- a/admin/server.php
+++ b/admin/server.php
@@ -189,6 +189,108 @@ include __DIR__ . '/../includes/header.php';
+
+
= icon('home') ?> Lumina-Website
+
+ Nur die Website selbst – ihre Dateien= $site !== null ? ' (' . e((string) $site['path']) . ')' : '' ?> und ihre Datenbank.
+ Bots, Backups und alles andere auf dem Server zählen hier nicht mit.
+
+
+
+ Website gesamt
+ = e(format_bytes($siteTotal)) ?>
+ = e(format_share($siteTotal, $used)) ?> des belegten Speichers
+
+
+ Dateien
+ = $site !== null ? e(format_bytes($siteFiles)) : '–' ?>
+ Code, Bilder, Karten, Uploads
+
+
+ Datenbank
+ = $dbTables ? e(format_bytes($dbBytes)) : '–' ?>
+ = count($dbTables) ?> Tabellen
+
+
+
+ = icon('alert') ?> Die Aufteilung der Dateien kommt mit dem nächsten Lauf des Sammelskripts (alle 15 Minuten).
+
+ Dateien der Website
+
+
+
+ Hochgeladene Dateien nach Bereich
+
+
+
+
+
+ Datenbank: größte Tabellen
+
+
+
+
= icon('transfer') ?> Datenvolumen (Traffic)
) mit lesbarem Namen fuer die Uebersicht "Lumina-Website". */
+const SERVER_STATS_UPLOAD_LABELS = [
+ 'profiles' => 'Bilder der Profilseiten',
+ 'avatars' => 'Profilbilder (Avatare)',
+ 'armory' => 'Symbole und Portraits aus dem Spiel',
+ 'gear' => 'Gear-Planer',
+ 'skills' => 'Skill-Symbole',
+ 'hunt' => 'Schnitzeljagd',
+ 'bugs' => 'Fehlermeldungen (Screenshots)',
+ 'maps' => 'Karten',
+ 'wiki' => 'Wiki',
+ 'roles' => 'Symbole der Gruppen',
+];
+
+/**
+ * Tabellen der Website-Datenbank nach Groesse (Daten + Indizes), groesste zuerst. Die Zeilenzahl ist bei InnoDB
+ * eine Schaetzung. Leer, wenn die Abfrage nicht erlaubt ist.
+ *
+ * @return array
+ */
+function server_stats_db_tables(): array
+{
+ try {
+ $rows = db()->query(
+ 'SELECT table_name AS name, COALESCE(data_length, 0) + COALESCE(index_length, 0) AS bytes, COALESCE(table_rows, 0) AS row_count
+ FROM information_schema.tables WHERE table_schema = DATABASE() ORDER BY bytes DESC, name'
+ )->fetchAll();
+ } catch (PDOException $e) {
+ return [];
+ }
+ return array_map(static fn (array $r): array => ['name' => (string) $r['name'], 'bytes' => (int) $r['bytes'], 'rows' => (int) $r['row_count']], $rows);
+}
+
/** Groesse lesbar: "512 MB", "63,4 GB" (1 GB = 1024 MB, wie df -h und die Angabe des Hosters). */
function format_bytes(int|float $bytes): string
{
diff --git a/includes/server_stats_collect.php b/includes/server_stats_collect.php
index 30a170a..a675753 100644
--- a/includes/server_stats_collect.php
+++ b/includes/server_stats_collect.php
@@ -184,6 +184,49 @@ function stats_traffic(string $interface): array
return $traffic;
}
+/**
+ * Nur die Lumina-Website: ihre Dateien nach Art und die Upload-Ordner im Einzelnen (die Datenbank fragt die Seite
+ * selbst ab). Ein du-Aufruf ueber das ganze Verzeichnis, daraus die einzelnen Pfade.
+ *
+ * @return array{path: string, total: int, parts: array, uploads: array}
+ */
+function stats_site(string $site): array
+{
+ $sizes = [];
+ foreach (explode("\n", stats_run('du -B1 --max-depth=3 ' . escapeshellarg($site))) as $line) {
+ if (preg_match('/^(\d+)\s+(.+)$/', $line, $m)) {
+ $sizes[$m[2]] = (int) $m[1];
+ }
+ }
+ $total = $sizes[$site] ?? 0;
+ $assets = $sizes[$site . '/assets'] ?? 0;
+ $uploadsBytes = $sizes[$site . '/assets/uploads'] ?? 0;
+ $mapData = $sizes[$site . '/assets/map/data'] ?? 0;
+ $git = $sizes[$site . '/.git'] ?? 0;
+ $parts = [
+ ['label' => 'Hochgeladene Dateien', 'bytes' => $uploadsBytes],
+ ['label' => 'Karten-Daten (Kacheln und Markierungen)', 'bytes' => $mapData],
+ ['label' => 'Bilder, Stile und Skripte der Website', 'bytes' => max(0, $assets - $uploadsBytes - $mapData)],
+ ['label' => 'Git-Verlauf', 'bytes' => $git],
+ ['label' => 'Programmcode', 'bytes' => max(0, $total - $assets - $git)],
+ ];
+ usort($parts, static fn (array $a, array $b): int => $b['bytes'] <=> $a['bytes']);
+
+ $uploads = [];
+ $prefix = $site . '/assets/uploads/';
+ foreach ($sizes as $path => $bytes) {
+ if (str_starts_with($path, $prefix) && !str_contains(substr($path, strlen($prefix)), '/')) {
+ $uploads[] = [
+ 'dir' => substr($path, strlen($prefix)),
+ 'bytes' => $bytes,
+ 'files' => (int) stats_run('find ' . escapeshellarg($path) . ' -type f | wc -l'),
+ ];
+ }
+ }
+ usort($uploads, static fn (array $a, array $b): int => $b['bytes'] <=> $a['bytes']);
+ return ['path' => $site, 'total' => $total, 'parts' => $parts, 'uploads' => $uploads];
+}
+
$config = server_stats_config();
$target = (string) ($argv[1] ?? server_stats_file());
$site = dirname(__DIR__);
@@ -249,6 +292,7 @@ $data = [
'hostname' => (string) gethostname(),
'disk' => ['total' => $total, 'used' => $used, 'free' => $free, 'history' => $history],
'groups' => $groups,
+ 'site' => stats_site($site),
'tree' => stats_tree(),
'docker' => stats_docker(),
'traffic' => stats_traffic((string) ($config['interface'] ?? '')),