Architecture

ProxMenux Monitor~10 min

How ProxMenux Monitor is packaged, what runs inside the AppImage, and how requests flow from the browser through the Flask backend to the host's tooling and SQLite store.

One process, many responsibilities

A single Python process listens on TCP 8008. It serves the static Next.js build, exposes the REST API, handles the WebSocket terminal, runs the periodic Health Monitor, and dispatches notifications. There is no separate web server, no message broker, no external database.

Request flow

A typical dashboard data request follows this path; browser-only preferences can be handled locally:

Client
Browser or PWA + optional Nginx / Caddy / Traefik proxy
HTTP / WS
Flask :8008
Blueprints JWT middleware Fail2Ban hook (if installed)
HTTP / WS
Host tools
psutil pvesh smartctl journalctl
HTTP / WS
Local state
SQLite DB + auth.json

Protected routes validate JWT when authentication is enabled. Core routes and blueprints return cached or newly collected host data. The optional Fail2Ban hook checks its cached jail ban list. Forwarded client-IP headers are trusted only with PROXMENUX_TRUST_PROXY=1; otherwise the peer address is used. Persistent state includes SQLite databases and JSON files, including auth.json.

The process also runs background threads. The examples below sample host data, update caches and SQLite, and dispatch notifications. Other workers also exist, and notification delivery depends on its enabled setting:

ThreadCadenceJob
_temperature_collector_loop60 sRecords CPU temperature and a network-latency sample into the history DB so the dashboard graphs have data even when no client is connected.
_health_collector_loop5 minRuns the full Health Monitor cycle (10 categories), persists active errors, dismissals and disk observations, and feeds new events into the notification engine.
_vital_signs_samplerCPU 5 s; temperature 15 s; memory 30 sSamples CPU usage, memory and CPU temperature for live metrics and sustained-condition detection, independently of the five-minute health collector.
notification_manager.start()event-drivenSpawns the journal / task / hook watchers (JournalWatcher, TaskWatcher, ProxmoxHookWatcher) and dispatches to configured channels with optional AI rewriting.

systemd unit

The installer drops a unit at /etc/systemd/system/proxmenux-monitor.service. Default content:

[Unit]
Description=ProxMenux Monitor - Web Dashboard
After=network.target pve-cluster.service

[Service]
Type=simple
User=root
WorkingDirectory=/usr/local/share/proxmenux
ExecStart=/usr/local/share/proxmenux/monitor-app/AppRun
Restart=on-failure
RestartSec=10
Environment="PORT=8008"

[Install]
WantedBy=multi-user.target
  • User=root — the supported service runs with root privileges for host operations such as SMART access, pvesh and ZFS management. Its web-terminal processes inherit those privileges.
  • Restart=on-failure with a 10-second back-off — non-zero exits relaunch automatically.
  • After=network.target pve-cluster.service: orders startup after the network target and the Proxmox cluster filesystem; it does not guarantee an assigned IP, DNS or external connectivity.

Inspect the live unit

systemctl cat proxmenux-monitor.service       # show the unit content
systemctl status proxmenux-monitor.service    # state + recent log
journalctl -u proxmenux-monitor.service -f    # follow live

What the AppImage contains

The AppImage is a self-mounting filesystem. AppRun at the root sets up the environment and execs flask_server.py:

AppDir/
├── AppRun                              # entrypoint: sets PATH/LD_LIBRARY_PATH, exec flask_server
├── usr/
│   ├── bin/
│   │   ├── flask_server.py             # main process
│   │   ├── flask_*_routes.py           # Flask blueprints (auth, health, terminal, …)
│   │   ├── auth_manager.py             # JWT + TOTP + API tokens
│   │   ├── health_monitor.py           # 10-category checker
│   │   ├── health_persistence.py       # SQLite layer
│   │   ├── notification_manager.py     # orchestrator
│   │   ├── notification_channels.py    # Telegram, Discord, Email, …
│   │   ├── notification_templates.py   # message rendering + AI hook
│   │   ├── notification_events.py      # JournalWatcher, TaskWatcher, …
│   │   ├── ai_providers/               # OpenAI · Anthropic · Gemini · Groq · Ollama · OpenRouter
│   │   ├── proxmox_storage_monitor.py  # storage pool inspection
│   │   ├── hardware_monitor.py         # CPU/PCIe/GPU enumeration
│   │   ├── ipmitool, sensors, upsc     # vendored hardware tools
│   │   └── …
│   ├── lib/python3/                    # vendored Python deps (Flask, JWT, psutil, …)
│   └── share/                          # icons + .desktop file
└── web/                                # Next.js static export
    ├── index.html
    ├── _next/                          # JS / CSS chunks
    └── manifest.json                   # PWA manifest

Two consequences of this layout:

  • Bundled Python packages. Python packages ship inside the AppImage and run on the host's own Python 3.11 (PVE 8) or 3.13 (PVE 9) interpreter, without installing anything into the host's system Python. The application still uses host kernel interfaces and external host tools.
  • Hardware clients are bundled too. ipmitool, lm-sensors and upsc are included. Readings still depend on supported hardware, access to sensors and, for UPS data, a configured NUT server.

Flask app structure

flask_server.py creates one Flask(__name__) instance with restricted CORS origins, registers ten blueprints directly and initializes terminal routes. The table highlights the main modules; PBS, Monitor links, audit and VM-backup blueprints are also registered. PVE-specific prewarmers run only on PVE hosts.

Blueprint / moduleRoutes prefixOwns
flask_server.py/api/system
/api/storage
/api/network
/api/vms
/api/hardware
/api/logs
/api/prometheus
Core data endpoints + static dashboard serving + optional Fail2Ban app-level check (active only when Fail2Ban is installed on the host with the proxmenux jail).
flask_auth_routes.py/api/auth/*Login, JWT issuing, TOTP setup/verify, password change, API token generation.
flask_health_routes.py/api/health/*Health probes, detailed status, active and dismissed errors, and suppression settings. Protected routes require authentication when it is enabled.
flask_terminal_routes.py/api/terminal/* + WSPTY allocation per session and WebSocket pipe to xterm.js in the browser.
flask_notification_routes.py/api/notifications/*Channel CRUD, test-send, AI provider config, history, manual sends.
flask_security_routes.py/api/security/*Authentication failures and, when Fail2Ban is installed, jail status, ban events and manual unban.
flask_proxmenux_routes.py/api/proxmenux/*Reads the ProxMenux post-install optimizations recorded in the host registry.
flask_oci_routes.py/api/oci/*OCI / container app deployment helpers (Proxmox VE 9.1+).

Integration endpoints and their request/response formats are described in API Reference.

Data sources

Host data comes mainly from standard libraries, files and administrative commands. Some guest information also depends on the QEMU Guest Agent or commands executed inside a CT:

SourceUsed for
psutilCPU load, memory, swap, mountpoint usage, NIC counters, process list.
pvesh / qm / pctProxmox node info, VM and CT inventory and config, storage pools, task history.
smartctlSATA / NVMe attributes, SMART health, wear / lifetime, model and serial.
zpool / zfsPool state (ONLINE / DEGRADED / FAULTED / UNAVAIL), scrub progress, dataset usage.
journalctlSystem logs, OOM kills, ATA / NVMe / dm errors, security events, custom service units.
ip / iproute2Interfaces, addresses, bridges, bonds, OVS-managed devices.
nvidia-smi · intel_gpu_topAvailable GPU utilisation, VRAM, temperature and encoder/decoder measurements; fields depend on the vendor, tool and driver.
lspci · lscpu · dmidecodePCIe topology, CPU model and topology, board and BIOS info.
ipmitool · sensorsOut-of-band sensors, fan speeds, board temperatures (when supported).
upsc (NUT)UPS battery state, load, runtime — when a NUT server is configured on the host.

Output is cached — not every request hits the host

Expensive sources (smartctl -a, pvesh get) are wrapped in time-bound caches inside the Flask process so a busy dashboard tab doesn't hammer the disk or the cluster API. The cache TTLs are tuned per source (a few seconds for live metrics, several minutes for SMART).

Persistence

Several state files have different contents and access requirements:

PathOwnerContents
/usr/local/share/proxmenux/health_monitor.dbroot:rootSQLite DB. Tables: errors, events, disk_registry, disk_observations, user_settings, notification_history, excluded_storages, excluded_interfaces. WAL journal mode.
/usr/local/share/proxmenux/.notification_keyroot 060032-byte master key for the ENC2 notification-secret format. The implementation uses a per-value random salt, derived keys and a MAC; old fixed-key XOR values are supported for migration.
/root/.config/proxmenux-monitor/auth.jsonroot:rootAuthentication configuration: enabled flag, username, salted PBKDF2-HMAC-SHA256 password hash, TOTP secret, backup codes, per-install JWT signing secret, API-token metadata and revocation hashes. Legacy SHA-256 password hashes are migrated on successful login.
/var/log/proxmenux-auth.logroot:rootPlain-text authentication event log, written independently of Fail2Ban. When the [proxmenux] jail is installed and enabled, it reads this log to detect repeated failed logins. Without that jail, the log remains available for inspection.

Back up auth.json before reinstalling

Replacing the AppImage normally preserves /root/.config/proxmenux-monitor/auth.json and /usr/local/share/proxmenux/health_monitor.db. Preserve auth.json with its per-install jwt_secret to retain token validity and metadata. The database stores health and notification state independently. Back up .notification_key with the database to restore encrypted channel settings; restoring the DB alone does not restore API authentication.

Health Monitor cycle

About every five minutes, the background collector invokes health_monitor.py to run the checks behind the dashboard’s ten categories:

  1. Critical PVE services (pveproxy, pvedaemon, pvestatd, pve-cluster).
  2. Proxmox storage pools (pvesh get /storage + per-storage availability).
  3. Disks and filesystems: SMART, dmesg I/O errors, ZFS pool health, mountpoint capacity.
  4. VMs and CTs: failed starts, crashed guests, QMP errors, shutdown failures.
  5. Network: bridge / bond status, link state, latency to the gateway.
  6. Updates: pending package upgrades and security patches.
  7. Logs: persistent / spike / cascade pattern detection in the system journal.
  8. Memory: OOM killer activity, sustained high pressure.
  9. CPU: usage and CPU temperature checked against the configurable thresholds; available sensors depend on the hardware.
  10. Security: authentication failures, ban events, fail2ban jail status.

Findings use a stable error_key, category and severity. Existing records in errors are updated in place (last_seen, severity, reason) rather than duplicated. Notification delivery also has its own fingerprint and cooldown rules.

Cleanup can auto-resolve stale errors using category Suppression Duration values and state-based rules, remove orphan records for resources that were removed, and prune events older than 30 days. The categories and dashboard are described in Dashboard → Health Monitor.

Notification engine

notification_manager.py is the orchestrator. It loads the configured channels, owns the delivery queue, and exposes both a Python API (for Flask routes and the Health Monitor cycle) and a CLI entrypoint (for the .sh hook scripts shipped with ProxMenux).

  • Watchers push events: JournalWatcher tails the system journal, TaskWatcher polls the Proxmox task list, ProxmoxHookWatcher reacts to backup / replication / snapshot hooks, and PollingCollector handles slow data sources.
  • Templates turn an event into a (title, body) pair. The same template can run through the configured AI provider (OpenAI / Anthropic / Gemini / Groq / Ollama / OpenRouter) to produce a plain-language rewrite; both versions are stored in notification_history.
  • Channels deliver messages through services including Telegram, Discord, Email, Gotify, Pushover and Apprise. Implementations in notification_channels.py use the shared create_channel() / send() interface.
  • Encryption. Sensitive settings (telegram.bot_token, discord.webhook_url, pushover.user_key, pushover.api_token, ai_api_key_*, email.password) are encrypted with the key in .notification_key before being written to the DB and are masked in the interface.

Per-event toggles, channel overrides and AI configuration are surfaced in Settings → Notifications and Settings → AI Assistant.

WebSocket terminal

The Terminal tab in the dashboard is a thin xterm.js client wired to a server-side PTY through a WebSocket. Two transport modes:

  • HTTP mode (default): the built-in Flask server with flask-sock handles WebSocket upgrade requests.
  • HTTPS / WSS mode: the TLS server uses gevent.pywsgi.WSGIServer with its default handler; flask-sock handles WebSocket connections over TLS.

Terminal child processes inherit User=root from the service. Opening a WebSocket requires a short-lived, single-use ticket obtained from the authenticated terminal-ticket endpoint with administrative scope.

If you access the Monitor through a reverse proxy, make sure WebSocket forwarding is enabled (the Upgrade and Connection headers). Without it the terminal won't work.

Reverse proxy & Fail2Ban

Client-IP selection and optional application-level blocking depend on these settings and components:

  1. Client IP selection. The before_request ban check and auth logging trust X-Forwarded-For, then X-Real-IP, only when PROXMENUX_TRUST_PROXY=1. Otherwise they use request.remote_addr. Forwarded headers are not accepted automatically.
  2. Optional application-level Fail2Ban. A proxy connection can present the proxy as the TCP peer. When the trusted client address is available and the proxmenux jail is active, Flask rejects listed IPs with HTTP 403. The ban list is cached for 30 seconds and refreshed by request processing after expiry, rather than polled by a dedicated timer.

Fail2Ban is not bundled

Fail2Ban is not bundled or installed automatically. It can be installed through the optional Monitor Security workflow or Security → Fail2Ban in ProxMenux Scripts. If fail2ban-client or the proxmenux jail is absent, this application hook does not block requests. The configured authentication policy still applies.

Reverse-proxy snippets (Nginx / Caddy / Traefik) and the Fail2Ban jail walkthrough are in Access & Authentication and Security → Fail2Ban.

Where to next