openusage-cli supports two complementary execution models:
queryfor on-demand readsrun-daemonfor always-on background collection
Use both together: keep a daemon running for fast responses, and call query from scripts/tools.
query is the default command mode.
# equivalent commands
openusage-cli query
openusage-cliBehavior:
- Try to discover a running daemon.
- If found, request data from daemon HTTP endpoints (
/v1/usageor/v1/plugins). - If no daemon is available (or request fails), fall back to local execution.
To disable step 1 entirely, run query with --use-daemon=false.
Fallback implications:
--type=usage: initializes runtime and actively polls providers, so response time is slower.--type=plugins: returns plugin metadata and typically completes faster than usage polling.
You can inspect which path was used:
openusage-cli query --with-statestate.queryMode is:
cachewhen data came from daemondirectwhen local fallback execution was used
Daemon mode keeps runtime warm and refreshes snapshots periodically (--refresh-interval-secs, default 180).
Benefits:
- Lower latency for clients that read data frequently
- Continuous background refresh without reinitializing plugins on every read
- Shared data source for multiple local consumers (CLI, dashboards, alerts, widgets)
Start daemon manually:
openusage-cli run-daemonBy default, this starts a background child process and returns control to your shell.
For interactive/debug runs:
openusage-cli run-daemon --foregroundBest for:
- quick local sessions
- testing configuration changes
- development and debugging (
--foreground)
Pros:
- minimal setup
- easy to launch ad hoc
Cons:
- less robust lifecycle management
- background default mode detaches from terminal output
- no service manager supervision unless you run it under one
Best for:
- daily usage on Linux desktops/workstations
- long-running reliable background service
Install/update the user unit:
openusage-cli install-systemd-unitEnable and start it:
systemctl --user daemon-reload
systemctl --user enable --now openusage-cli.service
systemctl --user status openusage-cli.serviceView logs:
journalctl --user -u openusage-cli.service -fPros:
- automatic restart on failure
- standard lifecycle commands (
start,stop,restart,status) - centralized logs via journald
- predictable startup and readiness behavior
Cons:
- requires systemd user services
- one-time setup and familiarity with
systemctl --user
Main runtime knobs:
-
host/port -
refresh_interval_secs(default:180) -
aggressive_refresh_interval_secs(default:10)When a provider plan includes a
resetAttimestamp, the daemon switches to the aggressive interval for that provider after the reset time is reached, polling more frequently so the new quota snapshot is available promptly. -
enabled_plugins -
plugins_dir -
plugin_overrides_dir -
app_data_dir -
existing_instance
Set these via CLI flags or config.yaml.
For config location and precedence, see configuration.md.
- Use systemd user service as your default operational mode.
- Use
queryfrom scripts and tools to read already-refreshed daemon data quickly. - Keep fallback behavior as a safety net for environments where daemon is not running.