Nextcloud Monitoring Loop Fix | Generated by AI

Home 2026.04

Here’s the full post-mortem:


🔍 Root Cause — What Happened

The Chain of Events

  1. Uptime-Kuma (your uptime monitor) was polling GET /apps/dashboard/ on Nextcloud every ~6 minutes
  2. This triggered Nextcloud’s Dashboard app to load → which calls PresetManager::refreshPresetApps()
  3. PresetManager iterates through every installed app and all their config entries, cloning config objects and rebuilding defaults for each of 10+ “lexicon presets”
  4. Somewhere in this chain (possibly a third-party app or a lexicon config bug in Nextcloud 33.0.0) it hit an infinite loop — every request ran for 3600+ seconds before PHP’s max_execution_time killed it
  5. Each time Uptime-Kuma polled, a new Apache worker picked up the request and joined the loop
  6. Over ~1.5 hours, 9 Apache workers all saturated at 55-65% CPU each → load hit 11 → fan at full blast

Why it wasn’t obvious


✅ The Fix — What We Did

1. Emergency — Stop the bleeding

docker restart nextcloud-app-1

Cleared all 9 stuck Apache workers immediately. Load dropped from 11 → 3.68 in seconds, fan quieted.

2. Root cause — Uptime-Kuma polling the wrong URL

3. Patch the wound — Upgrade Nextcloud 33.0.0 → 33.0.2


🛡️ How to Prevent This

For Nextcloud specifically:

Do Don’t
Use /status.php for health checks Poll /apps/dashboard/ or any UI route
Set Uptime-Kuma interval ≥ 60s for PHP apps Rapid polling of PHP apps
Monitor container CPU individually Only look at host load average

General fan/noise prevention:

  1. Set up alerting on container CPU — run this cron to alert before it gets bad:
    docker stats --no-stream --format ": " | awk -F: '$2>80 {print $1" high CPU"}'
    
  2. Rotate logs — prevent log files in containers from filling disk and causing swap pressure
  3. Restart containers periodically — many PHP apps (Nextcloud, LibreChat) benefit from occasional restarts to clear memory leaks

🔧 Quick Diagnostic Commands

# Find what's hottest
docker stats --no-stream

# See all processes inside a container
docker top <container>

# Watch container CPU in real time
watch -n2 'docker stats --no-stream --format " "'

# Nextcloud health
curl -s http://localhost:8080/status.php

# Full system load
uptime && top -b -n1 | head -8

Any container at sustained >50% CPU for more than a few minutes = investigate immediately.


Back Donate