- PHP 87.3%
- CSS 7.4%
- Shell 5.3%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
devices.paused + a pause/resume button per printer in the client-detail accordion, with a 'gepauzeerd' badge. A paused printer is excluded from alerts (supply_low + stock_short demand) and from the ink ordering counts, same as a paused client. |
||
| bin | ||
| deploy | ||
| docs | ||
| public | ||
| sql | ||
| src | ||
| warehouse | ||
| .gitignore | ||
| README.md | ||
inkagent-portal
Central portal + ingest API for Better Deals ink monitoring. Radxa E20C agents poll printers over SNMP and push HMAC-signed batches here; the portal ranks the fleet by predicted depletion date (not by percentage) and drives alerts.
Stack: PHP 8.2 + MariaDB + Caddy, native in a Debian 12 LXC. No framework.
Layout
sql/schema.sql MariaDB schema
src/ app classes (no framework)
Config Db Crypto Http infra
Enroll Ingest API logic
Forecast Overview depletion forecast + fleet assembly
Color View presentation helpers
public/
index.php fleet overview (sorted by depletion date)
admin/tokens.php clients + enrollment tokens (Caddy basic-auth)
api/v1/enroll.php POST /api/v1/enroll
api/v1/ingest.php POST /api/v1/ingest
deploy/
bootstrap.sh idempotent LXC installer
Caddyfile config.php.example
docs/printer-snmp-support.md fleet SNMP capability (risk #1)
API
POST /api/v1/enroll
Body {token, agent_id, client_ref, machine_id}. Redeems a single-use token,
provisions the agent, returns {secret, ingest_url, newt_id, newt_secret, newt_endpoint}. The token is burned on success.
POST /api/v1/ingest
Headers X-Agent-Id, X-Timestamp, X-Signature.
X-Signature = HMAC-SHA256(secret, timestamp + "." + raw_body). Timestamps older
than 300s are rejected. Body is the agent's batch (readings[], see the agent's
read_printer). Response may carry a config object (poll_interval,
community, extra_hosts, discovery_interval) that the agent applies itself.
Security
- Agent HMAC secrets are stored AES-256-GCM encrypted (
app_keyin the config file, outside the DB). The server needs the raw secret to verify signatures. - Enrollment tokens are stored as SHA-256 hashes; the plaintext is shown once.
/adminis gated by Caddy basic-auth.
Forecast
Least-squares regression of level_pct over the last ~30 readings gives a
percent-per-day decline and a projected empty date. Page-count run-rate is the
second signal — and the only usable one for tier-C ink tanks (EcoTank / HP
Smart Tank) that report no reliable percentage. Those are shown as pages-only
rather than given a false date. See docs/printer-snmp-support.md.
Deploy
On a fresh Debian 12 LXC, as root:
REPO_SRC=<git-url-or-path> DOMAIN=ink.4betterdeals.com bash deploy/bootstrap.sh
Generates the DB password, app_key, and an admin password (printed once).