v0.6.0: CPU monitoring, CSV with CPU, docs update, cleanup
Some checks failed
CI / test (push) Failing after 1m27s
Build & Release / release (push) Successful in 3m17s

New in v0.6.0:
- CPU usage: local/remote shown per interval (cpu: 12%/33%)
- Warning indicator (!) when CPU > 70% on either side
- MikroTik CPU encoding: 0x80 | percentage in status byte 1
- CSV includes local_cpu_pct and remote_cpu_pct columns
- Status message format corrected to match MikroTik wire format:
  [type:1][cpu:1][00:2][seq:4 LE][bytes:4 LE]
- Removed btest-opensource submodule (fully reimplemented)
- Deleted research/ecsrp5 branch
- Updated all docs: architecture, user-guide, man page, protocol
- Version bumped to 0.6.0

58 tests, all passing. Zero warnings.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Siavash Sameni
2026-04-01 11:16:25 +04:00
parent 27354108fc
commit f0a48092ed
6 changed files with 20 additions and 7 deletions

View File

@@ -219,6 +219,14 @@ IPv6 requires special handling on macOS:
- NDP probe packet sent before data blast to populate neighbor cache
- Adaptive backoff on ENOBUFS (200μs→10ms, resets on success)
### 11. CPU usage monitoring
A background OS thread samples system CPU every 1 second via:
- **macOS:** `host_statistics(HOST_CPU_LOAD_INFO)` — returns user/system/idle/nice ticks
- **Linux:** `/proc/stat` — reads aggregate CPU line
The percentage is stored in a global `AtomicU8` and included in every status message at byte 1 using MikroTik's encoding: `0x80 | percentage`. On receive, the remote CPU is decoded with `byte & 0x7F` and capped at 100%. Both local and remote CPU are displayed per interval and logged to CSV/syslog.
## File Layout
```
@@ -232,6 +240,7 @@ btest-rs/
│ ├── server.rs # Server mode: listener, TCP/UDP handlers
│ ├── client.rs # Client mode: connector, TCP/UDP handlers
│ ├── bandwidth.rs # Rate limiting, formatting, shared state
│ ├── cpu.rs # CPU usage sampler (macOS + Linux)
│ ├── csv_output.rs # CSV result logging (append-mode, auto-header)
│ └── syslog_logger.rs # Remote syslog sender (RFC 3164 / BSD format)
├── tests/

View File

@@ -1,5 +1,5 @@
.\" btest-rs manual page
.\" Generated for btest-rs v0.5.0
.\" Generated for btest-rs v0.6.0
.TH BTEST 1 "2026-03-31" "btest-rs 0.5.0" "User Commands"
.SH NAME
btest \- MikroTik Bandwidth Test server and client

View File

@@ -235,10 +235,11 @@ btest -c 192.168.88.1 -r -P 3000
## Reading the Output
```
[ 1] TX 264.50 Mbps (33062912 bytes)
[ 2] TX 263.98 Mbps (32997376 bytes)
[ 2] RX 263.98 Mbps (32997012 bytes)
[ 3] RX 430.51 Mbps (53813376 bytes) lost: 5
[ 1] TX 264.50 Mbps (33062912 bytes) cpu: 12%/0%
[ 2] TX 263.98 Mbps (32997376 bytes) cpu: 15%/33%
[ 2] RX 263.98 Mbps (32997012 bytes) cpu: 15%/33%
[ 3] RX 430.51 Mbps (53813376 bytes) lost: 5 cpu: 18%/45%
[ 4] RX 450.00 Mbps (56250000 bytes) cpu: 72%/85% !
```
| Field | Meaning |
@@ -249,6 +250,8 @@ btest -c 192.168.88.1 -r -P 3000
| `Mbps` | Megabits per second |
| `bytes` | Raw bytes transferred in this interval |
| `lost: N` | UDP packets lost in this interval (UDP mode only) |
| `cpu: L%/R%` | Local CPU / Remote CPU usage percentage |
| `!` | Warning: CPU usage exceeds 70% on either side |
## Complete CLI Reference