brainframe-sys-tools
Python CLI tools for monitoring and debugging BrainFrame system deployment.
Installation
pip install brainframe-sys-tools
Usage
brainframe-sys-tools <command> [options]
Commands
perf-monitor- Monitor CPU, GPU, memory, storage, and temperaturesfps-monitor- Monitor BrainFrame stream FPS and throughputservice-monitor- Run in the foreground, or useinstall,status, anduninstallto manage the daemon and WDAT watchdogsys-info- Display system informationssh-tunnel- Create SSH tunnels
Example
brainframe-sys-tools perf-monitor
brainframe-sys-tools fps-monitor --server-url http://localhost
brainframe-sys-tools service-monitor install --dry-run
Help
brainframe-sys-tools <command> --help
BrainFrame Service Monitoring & Recovery Design
The target NUC setup has two independent recovery layers. Follow the setup steps below to activate them; neither layer is active just because this repository has been updated.
- BrainFrame service monitor: every 30 seconds, request the local
BrainFrame version with a 10-second timeout. After three consecutive
failures, and no sooner than 10 minutes after the previous automatic
recovery, run
brainframe compose downandbrainframe compose up -d. On startup, allow BrainFrame up to five minutes to initialize before counting failed checks. Zone status is logged after a successful version check but never triggers a restart. This layer never reboots the host. systemd also restarts the monitor itself if it exits or stops sending its service heartbeat for 10 minutes. - Hardware watchdog: the kernel's
wdat_wdtdriver exposes the NUC's WDAT device as/dev/watchdog0. systemd (PID 1) feeds the device. If systemd cannot run long enough to feed it, the hardware timer resets the host. The BrainFrame monitor does not feed this timer: an application failure should restart the application, not the whole machine.
The old watchdog.service used a load-average check that rebooted this NUC
when its 15-minute load average exceeded 12 for 60 seconds. Keep that
service disabled. It did not detect out-of-memory events. The previous
BrainFrame monitor would restart the full Compose stack after a single
failed API check; the NUC had no monitor service installed.
Install the system watchdog and service monitor
On a WDAT-capable BrainFrame server, run the installed sys-tools command as the account that runs BrainFrame:
brainframe-sys-tools service-monitor install
Run the command as the login account, not with sudo. It prompts for
sudo when changing system settings. Use --dry-run to inspect the generated
unit and configuration without changing the machine.
service-monitor install checks for the WDAT firmware device and BrainFrame CLI,
then performs these steps in order:
- Mask the old watchdog's keepalive helper, then disable the load-based
watchdog.servicebefore loading WDAT. Neither can then take ownership of the hardware timer. - Load
wdat_wdt, confirm/dev/watchdog0identifies aswdat_wdt, add the module to the initramfs, and rebuild the initramfs for future boots. - Configure systemd (PID 1) to feed
/dev/watchdog0with a three-minute timeout. This is within the inspected NUC's 2-613 second range. - Install and enable
brainframe-service-monitor.servicefor the login account, with 30-second checks, 10-second request timeout, three failures before recovery, a 10-minute restart cooldown, and a 10-minute systemd service watchdog for a stuck monitor process. - Confirm that the hardware watchdog and BrainFrame monitor are active.
The command stops with an error if this host lacks WDAT or if verification fails. It does not deliberately expire the hardware timer. A controlled expiry test is still needed to prove that the firmware resets the machine; do that during a maintenance window. Enabling the hardware watchdog arms a real reset timer, so run setup while you can observe the machine.
Run service-monitor daemon
service-monitor install installs brainframe-service-monitor.service, starts it immediately,
and enables it at boot. The daemon runs as the login account supplied during
setup. It checks the BrainFrame API and writes heartbeat logs to
~/.local/state/brainframe-service-monitor/.
Use systemd to start, stop, or restart daemon mode:
sudo systemctl start brainframe-service-monitor.service
sudo systemctl stop brainframe-service-monitor.service
sudo systemctl restart brainframe-service-monitor.service
Restarting the monitor process does not restart BrainFrame unless the monitor later observes three consecutive API failures.
For foreground troubleshooting, stop the systemd service before running the CLI directly. This avoids two monitors trying to recover BrainFrame at once:
sudo systemctl stop brainframe-service-monitor.service
brainframe-sys-tools service-monitor
Press Ctrl+C to stop foreground mode, then run
sudo systemctl start brainframe-service-monitor.service to restore daemon
mode. The local URL, log path, check interval, request timeout, failure
count, and restart cooldown shown by service-monitor --help have defaults;
pass options only when you need to override them.
Check status
Check both recovery layers and show the last 30 monitor journal entries with:
brainframe-sys-tools service-monitor status
The summary reports whether brainframe-service-monitor.service is active
and enabled, whether WDAT is active and fed by systemd, and whether the old
load watchdog is inactive. It also lists machine boots from wtmp and
monitor-initiated BrainFrame stack restarts from the system journal for the
past 30 days. The available history may be shorter if wtmp or journal
records have been rotated away; manual Compose restarts are not logged by the
monitor. The command exits with an error if a recovery layer is missing. Use
--logs 0 to omit the recent monitor log tail (the 30-day history still
appears), or --logs N to choose its length. Repeat the status check after
the next planned host reboot to verify both layers started automatically.
Uninstall the system watchdog and service monitor
To stop the BrainFrame monitor and disarm systemd's hardware watchdog, run:
brainframe-sys-tools service-monitor uninstall
Run this as the login account; the command prompts for sudo. It removes
only configuration files marked as managed by sys-tools and the WDAT
initramfs entry if sys-tools added it. It unmasks the old wd_keepalive
helper without starting it, and does not re-enable the old load-based
watchdog.service. The WDAT driver may remain loaded until the next
reboot, but its timer is inactive. Use service-monitor uninstall --dry-run
to preview the changes and service-monitor status --logs 0 to inspect the
result.
If WDAT cannot be made usable, the kernel's softdog is a fallback for a
stalled user-space feeder while kernel timers still work. It cannot reset a
fully frozen kernel, so it is weaker than the NUC's hardware watchdog.
See the systemd hardware watchdog settings and the initramfs module loading rules.
Metadata
Release files for brainframe-sys-tools 0.5.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| brainframe_sys_tools-0.5.7.tar.gz | 58.4 kB | Without provenance | Details for brainframe_sys_tools-0.5.7.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| brainframe_sys_tools-0.5.7-py3-none-any.whl | Python 3 | none | any | Details for brainframe_sys_tools-0.5.7-py3-none-any.whl |
Total release size: 98.0 kB
Release files / brainframe_sys_tools-0.5.7.tar.gz
| Download URL | brainframe_sys_tools-0.5.7.tar.gz |
|---|---|
| Size | 58.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e783793616466e052530b4744f69cc7a572ea9904d5de85556798d320dd2b0b4
|
|
BLAKE2b-256 checksum How to use checksums |
bbbcba50eee22876f8557f5b56af70ba27c9a0e3954144e1d9ea5c29a9dc6453
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.4
|
Release files / brainframe_sys_tools-0.5.7-py3-none-any.whl
| Download URL | brainframe_sys_tools-0.5.7-py3-none-any.whl |
|---|---|
| Size | 39.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b938801e370808b5f0f85f1321da89c2000458597e09859b16aed983f081a9c1
|
|
BLAKE2b-256 checksum How to use checksums |
3b31b319c0a9bc82cf318cc428bcf92bced354b40c460569cbf02c14fc36bd40
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.4
|
Security for brainframe-sys-tools 0.5.7
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.