This directory contains a test environment for Bitcoin mining using Koii nodes. The environment includes a Bitcoin miner, monitoring system, and test scripts.
- Runs a Bitcoin miner using cpuminer
- Provides health and metrics endpoints
- Collects and stores mining shares
- Exposes Prometheus metrics
- Prometheus for metrics collection
- Grafana for visualization
- Alert rules for mining performance
- Health checks and timeouts
miner.py: Main miner servicemonitor.py: Monitoring servicetest.py: Test runner
- Install dependencies:
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt- Build and start the environment:
docker-compose up --build- Run the test:
python scripts/test.py- Miner API: http://localhost:8080
- Prometheus: http://localhost:9090
- Grafana: http://localhost:3000 (admin/admin)
The following metrics are collected:
- Hash rate (H/s)
- CPU usage (%)
- Memory usage (MB)
- Shares submitted
- Valid shares
- Invalid shares
- Uptime
The following alerts are configured:
- Miner Down
- High CPU Usage
- High Memory Usage
- No Valid Shares
- High Invalid Share Rate
Logs are stored in the logs directory:
miner.log: Miner service logsmonitor.log: Monitoring service logstest.log: Test execution logs
Mining shares are stored in SQLite database:
- Location:
data/shares.db - Schema: See
miner.pyfor details
config/bitcoin.conf: Bitcoin Core configurationconfig/prometheus.yml: Prometheus configurationconfig/rules.yml: Alert rules
To stop and remove all containers:
docker-compose down -v