Open Source / Shizuku · Myaku
Open Source · Symfony Bundle

Myaku Health Check.

Health monitoring for Symfony, disk, RAM, database and cache behind a single secured endpoint.

PHP ≥ 8.2 Symfony 7.4 · 8.0 MIT
$ composer require devexploris/myaku-health-check
01 — Introduction

One endpoint, four checks

Myaku Health Check exposes a single GET /health endpoint that reports the state of your disk, RAM, database, and cache. Database and cache are auto-detected, no extra config.

Access control
IP whitelist + x-myaku-token header. Two independent guards evaluated in order.
Auto-detection
doctrine.dbal.default_connection and cache.app are wired automatically when available. Absent services are skipped.
Thresholds
Configure alert thresholds for disk and RAM usage. Crossing one returns a 503.
02 — Requirements

Dependencies

PackageVersionRole
php≥ 8.2Required by Symfony 7.4+
symfony/http-kernel^7.4 · ^8.0AbstractBundle, Request handling
symfony/console^7.4 · ^8.0Dependency injection
doctrine/dbal^3.0 · ^4.0Database connectivity check
symfony/cache-contracts^3.0Cache interface (optional)
Optional: doctrine/doctrine-bundle and symfony/cache are auto-wired when present their checks are simply skipped when absent.
03 — Installation

Setup

01 — Require

$ composer require devexploris/myaku-health-check

02 — Register the bundle

// config/bundles.php
return [
    Devexploris\MyakuHealthCheck\MyakuHealthCheckBundle::class => ['all' => true],
];

03 — Register the route

# config/routes.yaml
myaku_health_check:
    resource: Devexploris\MyakuHealthCheck\Controller\HealthCheckController
    type: attribute
04 — Configuration

Configuration

Create config/packages/myaku_health_check.yaml:

myaku_health_check:
    threshold:                              # optional
        space: 80                           # alert if disk usage exceeds X% (0–100)
        memory: 90                          # alert if RAM usage exceeds X% (0–100)
    space:
        path: /                             # mount point to monitor (default: /)
    security:
        token: "%env(APP_MYAKU_TOKEN)%"     # generate with: openssl rand -hex 24
        whitelist:                          # optional if empty, all IPs are allowed
            - "127.0.0.1"
            - "172.21.0.1"

Thresholds

Both thresholds are optional. When configured, a usage percentage above the threshold triggers a 503 response and sets threshold_targeted: true in the JSON payload.

KeyTypeDescription
threshold.spaceint (0–100)Disk usage alert threshold (%)
threshold.memoryint (0–100)RAM usage alert threshold (%)for Linux only
space.pathstringMount point to monitor (default: /)

Security keys

KeyDescription
security.tokenBearer token required in the x-myaku-token header
security.whitelistList of allowed client IPs. If empty, all IPs are accepted
05 — Endpoint

GET /health

Single entry point for all health checks. Returns 200 when everything is healthy, 503 when at least one check fails or exceeds its threshold.

CodeMeaning
200 All checks are healthy
403 IP not allowed or invalid token
503 At least one check failed or exceeded its threshold
06 — Security

Two guards, one order

Two controls are applied sequentially. The first failure immediately returns 403, the second guard is never evaluated.

01
IP Whitelist
02
x-myaku-token
01IP whitelist if the list is not empty, the client IP must be present. Otherwise 403. An empty whitelist allows all IPs.
02Token the x-myaku-token header must match the configured token. Otherwise 403.
Example request:
curl -H "x-myaku-token: your_token_here" https://your-app.com/health
07 — Response

JSON payload

Healthy response

The fields threshold and threshold_targeted only appear when the corresponding threshold is configured.

{
    "space": {
        "free": "45.30 Go",
        "used": "54.70 Go",
        "total": "100.00 Go",
        "threshold": "80%",
        "threshold_targeted": false
    },
    "memory": {
        "free": "4.77 Go",
        "used": "10.04 Go",
        "total": "14.81 Go",
        "threshold": "90%",
        "threshold_targeted": false
    },
    "database": {
        "connected": true,
        "latency": "1.23ms"
    },
    "cache": {
        "connected": true,
        "latency": "0.45ms"
    }
}
threshold_targeted: true the usage percentage exceeds the configured threshold. This alone triggers a 503.

Error responses

When a service is unreachable, connected is false and an error field contains the exception message. The overall response becomes 503.

Database

{
    "database": {
        "connected": false,
        "error": "SQLSTATE[HY000] [2002] Connection refused"
    }
}

Cache

{
    "cache": {
        "connected": false,
        "error": "No cache configured"
    }
}
08 — Compatibility

Platform support

Check Linux macOS Windows
Disk space
RAM
Database
Cache
RAM: Linux only. MemoryChecker reads /proc/meminfo, which is only available on Linux. On other systems, the memory check is silently skipped.