taler-monitoring/host-agent/ROOT-APPLY-MONITORING.md

71 lines
2.6 KiB
Markdown

# Root: make monitoring pages live on koopa (GOA)
## Detection (v1.3.1+)
Suite phase **`monpages`** and the host-agent **post-check** curl each public
FQDN (`https://taler.hacktivism.ch/monitoring/` …). Merchant JSON **code 21**
or non-HTML is an **ERROR** until this apply is done.
## Symptom if not applied
Public URLs return **merchant/bank JSON** like:
```json
{ "code": 21, "hint": "There is no endpoint defined for the URL provided..." }
```
or a **404 HTML** page from the app reverse_proxy.
Cause: live `/etc/caddy/Caddyfile` has **no** `handle /monitoring*` (falls through to
API). Prepared config is only under **`/home/hernani/koopa-caddy/Caddyfile`**.
## One-shot as root (recommended)
```bash
# absolute path required: as root, ~ is /root (not /home/hernani)
sudo /home/hernani/koopa-caddy/apply-monitoring-live.sh
# or already root:
# /home/hernani/koopa-caddy/apply-monitoring-live.sh
```
**Caddy bare-path redir (v1.9.2+):** inside a `handle` block use
`redir * /path/ 302` — never `redir /path/ 302` alone (Caddy treats the first
token as matcher and sets `Location: 302`, so bare URLs fall through to the
merchant API as JSON **code 21**).
That script:
1. `rsync` staging HTML → `/var/www/monitoring-sites/` (incl. surface + aptdeploy)
2. Makes tree writable for `hernani` (group `caddy` + ACL) so later runs self-sync
3. Installs prepared Caddyfile → `/etc/caddy/Caddyfile`, validates, reloads Caddy
4. Smoke-curls all monitoring URLs (must **not** be JSON `code:21`)
## Paths
| Path | Host | Source timer |
|------|------|----------------|
| `/monitoring/` + `/monitoring_err/` | bank + exchange + taler | `taler-monitoring-hacktivism.timer` (4h) |
| `/taler-monitoring-surface/` + `/_err/` | **taler.hacktivism.ch only** | `taler-monitoring-surface.timer` (1h) |
| `/taler-monitoring-aptdeploy/` + `/_err/` | **taler.hacktivism.ch only** | `taler-monitoring-aptdeploy.timer` (4h) |
HTML is generated as **hernani** into
`/home/hernani/monitoring-sites-staging/`.
## Manual equivalent
```bash
rsync -a --delete /home/hernani/monitoring-sites-staging/ /var/www/monitoring-sites/
chown -R hernani:caddy /var/www/monitoring-sites && chmod -R g+rwX /var/www/monitoring-sites
sudo /home/hernani/koopa-caddy/apply.sh # or apply-monitoring-live.sh
```
Expect **200** (HTML with sticky bar). Not merchant JSON `code:21`.
## After each monitoring run (if www is not hernani-writable)
```bash
rsync -a --delete /home/hernani/monitoring-sites-staging/ /var/www/monitoring-sites/
chown -R caddy:caddy /var/www/monitoring-sites
```
Or grant `hernani` write on `/var/www/monitoring-sites` once so the host-agent can rsync itself.