bit-learn¶
Auto-generates configuration files by detecting hardware and prompting for test parameters.
Environment Variables (with defaults)¶
BIT_CONFIG_PATH- Directory containing configuration files (default:/etc/bit)
Usage¶
This will interactively generate:
- Hardware whitelists (PCI, USB devices)
- Resource thresholds (disk usage, CPU, memory)
- Test frequencies for CBIT tests
- Expected states for interfaces
All prompts have sensible defaults - press Enter to accept all defaults, or type custom values when prompted.
What bit-learn Generates¶
Creates configuration files for all tests (PBIT + CBIT + FBIT):
Creating config files in /etc/bit
✓ Created pbit_cpu_usage.toml with threshold 42%
✓ Created cbit_cpu_usage.toml with threshold 32%, frequency 30s
✓ Created pbit_disk_usage.toml
✓ Created cbit_disk_usage.toml
✓ Created pbit_ethernet.toml with 2 interfaces
✓ Created cbit_ethernet.toml with frequency 30s
...
✓ Created pbit_usb_whitelist.toml (15 devices detected)
✓ Created cbit_usb_whitelist.toml
✓ Created pbit_pci_whitelist.toml (28 devices detected)
✓ Created cbit_pci_whitelist.toml
Interactive Prompts¶
CPU Tests¶
=== PBIT CPU Usage Configuration ===
Measuring current CPU usage...
Current CPU usage: 32.2%
Set CPU usage threshold in % (usage at boot must be below this) [42]: ⏎
=== CBIT CPU Usage Monitoring Configuration ===
Measuring current CPU usage...
Current CPU usage: 22.3%
Set CPU usage threshold in % (continuous monitoring alert threshold) [32]: ⏎
Set monitoring frequency in seconds (how often to check) [30]: ⏎
Set number of samples to average per check [5]: ⏎
Why these defaults? - PBIT threshold (42%) is higher than current usage with headroom - CBIT threshold (32%) is tighter for ongoing monitoring - Frequency (30s) balances responsiveness with overhead
Disk Tests¶
pbit_disk_usage: Set disk usage threshold in % for disk /dev/sda1 [80]: ⏎
pbit_disk_usage: Set disk usage threshold in % for disk /dev/shm [80]: ⏎
Auto-detection: - Scans mounted filesystems - Identifies root disk and /dev/shm - Suggests 80% threshold (industry standard)
Network Tests¶
=== PBIT Ethernet Interface Configuration ===
Discovering network interfaces...
Found: eth0 [up] - 1000 Mbps
Found: docker0 [down] - unknown Mbps
✓ Created pbit_ethernet.toml with 2 interfaces
Auto-detection:
- Uses ip link to discover interfaces
- Detects link speed
- Records current UP/DOWN state
Temperature Tests¶
Detecting thermal sensors...
Detected 8 thermal sensor(s)
Core 0 : 43.0°C
pbit_temperature: Set threshold for 'Core 0' in °C [85]: ⏎
Core 1 : 42.0°C
pbit_temperature: Set threshold for 'Core 1' in °C [85]: ⏎
Auto-detection:
- Reads from /sys/class/thermal/
- Shows current temperatures
- Suggests safe thresholds (85°C for CPUs)
USB/PCI Whitelist Tests¶
# USB devices detected automatically
pbit_usb_whitelist.toml file created (detected 15 devices)
# PCI devices detected automatically
pbit_pci_whitelist.toml file created (detected 28 devices)
Auto-detection:
- Executes lsusb and lspci commands
- Parses vendor IDs, device IDs, and descriptions
- Creates whitelist of currently connected devices
GPIO/CAN/Serial Tests¶
# GPIO
Warning: No accessible GPIO pins found
pbit_gpio.toml file created (empty config)
# CAN
Detecting CAN interfaces...
No CAN interfaces found
pbit_can.toml file created (empty config with examples)
# Serial
pbit_serial_ports.toml file created
Graceful handling: - Tests pass when hardware isn't present - Creates empty configs with helpful comments - Includes examples for manual addition
Configuration Patterns¶
Auto-Detected¶
bit-learn automatically discovers:
| Test | Detection Method | Command Used |
|---|---|---|
| CPU cores | sysinfo crate | nproc equivalent |
| Disks | df command | df / |
| Network | ip command | ip link show |
| Temperature | sysfs | /sys/class/thermal/ |
| USB devices | lsusb | lsusb |
| PCI devices | lspci | lspci -mm -nn |
| GPIO | sysfs | /sys/class/gpio/ |
| CAN | sysfs | /sys/class/net/can* |
| Serial ports | sysfs | /sys/class/tty/ |
Prompted Values¶
bit-learn prompts for:
| Setting | Default | Purpose |
|---|---|---|
| CPU threshold | 42% (PBIT), 32% (CBIT) | Resource limit |
| Memory threshold | 90% | Memory usage limit |
| Disk threshold | 80% | Disk usage limit |
| Temperature threshold | 85°C (CPU), 75°C (other) | Thermal limit |
| CBIT frequency | 30-60s (varies by test) | Monitoring interval |
| Power limits | Auto-detected ranges | Voltage/power bounds |
Configuration Validation¶
After running bit-learn, validate the generated configs:
# Check all configs were created
ls -1 /etc/bit/*.toml | wc -l
# Inspect specific config
cat /etc/bit/pbit_ethernet.toml
# Test with bit-inspect
bit-inspect
Common Workflows¶
Initial Setup¶
After Hardware Change¶
Production Update¶
# Backup existing
sudo cp -r /etc/bit /etc/bit.$(date +%Y%m%d)
# Regenerate
bit-learn
# Review changes
diff -r /etc/bit.$(date +%Y%m%d) /etc/bit
# Test before enabling service
bit-manager -o
# If OK, restart service
sudo systemctl restart bit_manager
Troubleshooting¶
See Troubleshooting Guide for common issues with bit-learn.
Default Values Reference¶
Resource Thresholds¶
| Test | Default | Reasoning |
|---|---|---|
| CPU usage (PBIT) | Current + 10% | Boot-time headroom |
| CPU usage (CBIT) | Current + 10% | Runtime tolerance |
| Memory usage | 90% | Standard limit |
| Disk usage | 80% | Industry standard |
| Swap usage | 50% | Conservative |
Temperature Thresholds¶
| Component | Default | Safe Max |
|---|---|---|
| CPU cores | 85°C | 90°C |
| GPU | 75°C | 85°C |
| Other sensors | 75°C | Varies |
CBIT Frequencies¶
| Test Type | Default | Range |
|---|---|---|
| Resource (CPU/mem/disk) | 30s | 10-300s |
| Temperature | 60s | 30-300s |
| Logs (dmesg/syslog) | 60s | 30-600s |
| Security (whitelist) | 5s | 5-60s |
| Config monitoring | 300s | 60-3600s |
Next Steps¶
- Configuration Guide - Manually edit configs
- Running Tests - Execute configured tests
- bit-inspect - Inspect generated configurations
- Test Types - Understand what each test does