Skip to content
Playbook: troubleshoot a failing site or app A read-first diagnosis sequence for a site, Docker app or stack that is down or slow — server state, services, logs, resource caps, certificates, disk — and the safe fixes with preview-then-apply.

Playbook: troubleshoot a failing site or app

Work read-only first, collect evidence, then propose one fix at a time. A read token covers the core tools and the registry reads. Over MCP, every step that goes through jobs_create needs an operate token (over REST, a read token may dispatch read-level kinds such as app.logs or site.stats; storage.usage and storage.du are operate kinds). Fixes need operate.

  • A site: servers_sites_all returns its server, type and state. site_get {domain} (core) returns details from the cache.
  • A Docker app or stack: servers_docker_all / servers_stacks_all.
  • Recent changes on that server: jobs_list {id}. A failed or recent deploy is the usual suspect.
  • External symptoms: uptime_incidents and uptime_monitors_list.

Start with one call: jobs_create {id, body: {type: "system.diagnose"}} (agent 0.2.156+, read level), then jobs_output. It returns findings (each with severity and a stable code: disk_full, disk_high, inodes_high, units_failed, oom_kills, memory_low, memory_pressure, load_high, journal_errors) plus host and load, memory, disks with inodes, failed units, listening ports, journal errors of the last hour, OOM kills of the last 24 h, the nginx error tail and the top CPU processes. It changes nothing. The checks below go deeper:

CheckToolLook for
Onlineservers_listonline: false → see Agent won’t come online. Cached reads may be stale.
Loadmetrics_get {server} · servers_metrics_history {id, query: {range: "6h"}}CPU or RAM pinned, swap in use, disk above 90%
Servicesservices_status {server} · servers_inventory {id, kind: "services"}nginx, php*-fpm, mariadb/postgresql, docker or redis not active
Diskjobs_create storage.usageA full root disk breaks almost everything
Trafficservers_traffic_history {id}A spike in 5xx, or a sudden traffic surge

Core tool logs_tail {server, target, lines} (live, read-only):

TargetWhen
site:<domain> (or site:<domain>:nginx-error / :nginx-access / :php-error)One site’s own logs, the first stop for a site
nginx-error · nginx-accessProxy errors (502/504), TLS errors, rewrites
php-fpmPHP pool crashes, max_children reached
mariadb (or mysql)Database crashes, too many connections
syslog · authOOM kills, systemd restarts, SSH issues

For containers, use jobs_create app.logs {name, lines} or docker.logs {container, lines}, and docker_ps {server} for state and restarts. service.logs {name, lines} returns a system unit’s journal.

  • Runtime sites (nodejs, python, go): sites_faults {id, domain, query: {range: "24h"}} shows OOM kills, memory or process caps and CPU throttling. jobs_create site.stats {domain} gives a per-site snapshot. A 502 usually means the process isn’t listening on its appPort.
  • PHP and WordPress: php_list {server} and servers_inventory {id, kind: "php_detail"} show versions and FPM settings. For WordPress, wp_cache {domain, action: "status"} shows the cache state, and jobs_create wp.updates lists pending updates.
  • Docker apps and stacks: a container in a restart loop shows in docker_ps. Check the image tag and env (app.env-list / stack.env-list mask every value unless you pass reveal: true; only reveal when you need a value, and handle that output carefully). For stacks, the primary service must still publish 127.0.0.1:__MZ_PORT__:<port>.
  • TLS: ssl_list {server} shows expired or missing certificates.
  • Firewall / SSH: risky firewall/SSH changes revert unless confirmed. A security.fw, security.fw-toggle, security.ssh or security.ssh-allow result with a revert object undoes itself after 120 s; servers_inventory {id, kind: "security"} shows it as pending_revert. Ask the human to open a new SSH session, then send security.confirm {id}. Locked out: the human runs mzagent rescue all from the provider’s console.

High CPU or swap: read the signal, not the number

Section titled “High CPU or swap: read the signal, not the number”
  • %CPU per process in ps-style lists is a lifetime average; check live load in metrics_get before acting.
  • A few PHP pools at high CPU with a low page-cache hit rate (cache:HIT rare in the access log) almost always means bots on uncached paths, not visitors.
  • Swap at 100% with plenty of available RAM is parked memory, not pressure (agent 0.2.143+ heartbeats carry swap_in_pps and mem_psi_some_avg60; alert on mem_pressure / swap_in, not swap). See the Assistant KB pages “CPU at 100% from php-fpm pools” and “Swap at 100%” (search_docs).

Propose the fix, get the human’s approval for anything user-facing, and verify after each step.

ProblemFixNotes
Service downservice_control {server, action: "restart", name} previews; add apply: true to runOr jobs_create service.action {action, name}
Runtime site stuckjobs_create site.restart {domain}
App or stack unhealthyapp.restart {name} / stack.restart {name}; roll back with stack.rollback {name, to} (backups:restore)Check stack.releases first
PHP pool exhaustedphp.fpm-get → php.fpm-set; php.restartRead jobs_schema for the fields
Disk fullstorage_clean {server, targets: ["apt","logs","tmp","caches"]} previews; add apply: true to deletejobs_create storage.du finds the big directories
Certificate expiredssl_renew {server, domain} (dry run) → apply: trueOr ssl.issue {domain}
Resource cap hitsite.limits-set {domain, mem?, cpu?, tasks?}Or reduce the load
Old agent: job exits 127agent_update {id}Then retry the job
CPU pinned by php-fpm pools of a few WordPress sitesRead site:<domain>:nginx-access: one IP or POST /xmlrpc.php / /wp-login.php dominating = brute force. agent_update {id} (agents after 0.2.141 apply the WordPress guard: xmlrpc 403, login rate limit, fail2ban)jobs_create {id, body: {type: "site.wp-guard", domain}} reads the guard (agent 0.2.142+); add xmlrpc: "allow" only if the site uses Jetpack or the WordPress app
Swap at 100%Parked pages if RAM is available and swap-in/out is ~0: the agent’s swap guard reclaims it automatically; real shortage if available RAM is lowjobs_create {id, body: {type: "system.swap-status"}} (agent 0.2.142+) explains the decision; system.swap-reclaim runs it now

After every fix: re-run the check that showed the problem (logs, services_status, docker_ps, curl the URL) and confirm the uptime monitor recovers.

  • The fix needs a shell (docker.exec and the terminal are never available to tokens): give the human the exact commands to run in Terminal, or in an SSH session with the on-box mz CLI.
  • The fix needs a scope or plan the token doesn’t have: report required_scope or required_tier.
  • The data looks corrupted: propose a restore (Backups and restore) rather than editing in place.