feat(services): add storage, cache, and DB services - #983
Open
karlitschek wants to merge 2 commits into
Open
Conversation
Adds five read-only service classes used by the upcoming admin
dashboard cards. None are wired into existing controllers yet, so
this change is a pure addition with no behavior change.
* DbHealth - largest tables on MySQL / PostgreSQL
* CachingInfo - OPcache and APCu hit rates plus Redis config
* ExternalStoragesInfo - mounts configured via files_external
* DiskGrowth - rolling history snapshots with a
days-until-full prediction
* TopUsersByQuota - top users ranked by home::*/files size
Signed-off-by: Frank Karlitschek <frank@nextcloud.com>
kesselb
reviewed
May 12, 2026
kesselb
reviewed
May 12, 2026
kesselb
reviewed
May 12, 2026
karlitschek
requested review from
ChristophWurst and
kesselb
and
a lite review from Copilot
August 6, 2026 11:55
There was a problem hiding this comment.
Pull request overview
Adds a set of new read-only “service” classes under OCA\ServerInfo intended to power upcoming admin dashboard cards, focused on DB health, caching status, external storage mounts, disk growth prediction, and identifying largest user home storages.
Changes:
- Introduces new DB- and filesystem-backed service classes for collecting storage, caching, and database metrics.
- Adds disk free-space history persistence + simple growth/prediction computation.
- Adds queries for external mounts and top users by home storage size.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| lib/DbHealth.php | New DB health service querying largest tables for MySQL/PostgreSQL. |
| lib/CachingInfo.php | New cache status service for OPcache/APCu and Redis/memcache config. |
| lib/ExternalStoragesInfo.php | New external storage mounts summary service (files_external). |
| lib/DiskGrowth.php | New snapshot/history + disk growth estimation/prediction service. |
| lib/TopUsersByQuota.php | New service to rank users by “home::” storage size via filecache. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+16
to
+18
| * Persists daily snapshots of (free space + file count) and uses a | ||
| * simple linear regression over the last samples to predict when | ||
| * the system disk will fill up. |
Comment on lines
+33
to
+37
| 'memcache' => [ | ||
| 'local' => $this->shortClassName($this->config->getSystemValue('memcache.local', '')), | ||
| 'distributed' => $this->shortClassName($this->config->getSystemValue('memcache.distributed', '')), | ||
| 'locking' => $this->shortClassName($this->config->getSystemValue('memcache.locking', '')), | ||
| ], |
| * simple linear regression over the last samples to predict when | ||
| * the system disk will fill up. | ||
| * | ||
| * Snapshots are stored in app config as JSON: list of {ts, free, files}. |
Comment on lines
+29
to
+47
| public function getDbHealth(): array { | ||
| $driver = (string)$this->config->getSystemValue('dbtype', 'sqlite'); | ||
|
|
||
| try { | ||
| $tables = match ($driver) { | ||
| 'mysql', 'mariadb' => $this->mysqlTables(), | ||
| 'pgsql' => $this->pgTables(), | ||
| default => [], | ||
| }; | ||
| } catch (\Throwable) { | ||
| $tables = []; | ||
| } | ||
|
|
||
| return [ | ||
| 'driver' => $driver, | ||
| 'largestTables' => $tables, | ||
| 'available' => $tables !== [] || $driver === 'sqlite', | ||
| ]; | ||
| } |
Comment on lines
+34
to
+52
| try { | ||
| $qb = $this->db->getQueryBuilder(); | ||
| $qb->select('mount_id', 'mount_point', 'storage_backend', 'auth_backend', 'type') | ||
| ->from('external_mounts') | ||
| ->setMaxResults(50); | ||
| $result = $qb->executeQuery(); | ||
| $mounts = []; | ||
| while (($row = $result->fetch()) !== false) { | ||
| $mounts[] = [ | ||
| 'name' => $this->prettyMountPoint((string)($row['mount_point'] ?? '')), | ||
| 'backend' => $this->shortBackend((string)($row['storage_backend'] ?? '')), | ||
| 'scope' => (int)($row['type'] ?? 1) === 2 ? 'user' : 'admin', | ||
| ]; | ||
| } | ||
| $result->closeCursor(); | ||
| return ['installed' => true, 'count' => count($mounts), 'mounts' => $mounts]; | ||
| } catch (\Throwable) { | ||
| return ['installed' => true, 'count' => 0, 'mounts' => []]; | ||
| } |
| * hasEnoughData: bool | ||
| * } | ||
| */ | ||
| public function getGrowthInfo(): array { |
| * available: bool | ||
| * } | ||
| */ | ||
| public function getDbHealth(): array { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds five read-only service classes used by the upcoming admin dashboard cards. None are wired into existing controllers yet, so this change is a pure addition with no behavior change.
days-until-full prediction