A worker service for managing and monitoring Avalon cryptocurrency mining devices. This implementation provides comprehensive control over Avalon miners, including the A1346 model, with support for monitoring, configuration, and remote management.
- Overview
- Object Model
- Features
- Requirements
- Installation
- Configuration
- Usage
- Data Collection
- Error Monitoring
- Alerts
- Mock Server
- Development
This worker extends the abstract miner worker framework to provide specific functionality for Avalon mining hardware. It implements the TCP-based Avalon protocol for device communication and provides a standardized interface for mining operations management.
The following is a fragment of MiningOS object model that contains the concrete classes representing Avalon miner workers (highlighted in blue), one generically representing any model of the brand, and one child class specifically representing model A1346. The rounded nodes reprsent abstract classes while the square nodes represent concrete classes:
---
title: Object Model of MiningOS
---
flowchart RL
bfx-wrk-base@{ shape: stadium, label: "*bfx-wrk-base*" }
tether-wrk-base@{ shape: stadium, label: "*tether-wrk-base*" }
tether-wrk-base--->bfx-wrk-base
miningos-tlp-wrk-thing@{ shape: stadium, label: "*miningos-tlp-wrk-thing*" }
miningos-tlp-wrk-thing--->tether-wrk-base
miningos-tpl-wrk-miner@{ shape: stadium, label: "*miningos-tpl-wrk-miner*" }
miningos-tpl-wrk-miner--->miningos-tlp-wrk-thing
miningos-wrk-miner-avalon["miningos-wrk-miner-avalon"]
miningos-wrk-miner-avalon--->miningos-tpl-wrk-miner
miningos-wrk-miner-avalon-a1346["miningos-wrk-miner-avalon-a1346"]
miningos-wrk-miner-avalon-a1346--->miningos-wrk-miner-avalon
style miningos-wrk-miner-avalon fill:#005,stroke-width:4px,color:white
style miningos-wrk-miner-avalon-a1346 fill:#005,stroke-width:4px,color:white
Check out miningos-tpl-wrk-miner for more information about parent classes.
- Device Management: Register, update, and remove Avalon miners
- Real-time Monitoring: Collect performance metrics and device status
- Pool Management: Configure and monitor mining pools
- Power Control: Sleep, normal, and high-performance modes
- Network Configuration: Static and DHCP network settings
- Temperature Monitoring: Chip-level temperature tracking
- Error Detection: Comprehensive error monitoring and alerting
- Reboot device
- Set LED status
- Configure fan speed
- Factory reset
- Update passwords
- Set Mining pool server urls
- Suspend/resume mining
- Node.js (>= 20.0)
- Clone the repository
- Install dependencies:
npm install
- Configure the worker using the example configuration files:
./setup-config.sh
Generic: https://github.com/tetherto/miningos-tpl-wrk-thing/blob/main/README.md#configuration
node worker.js --wtype=wrk-miner-rack-a1346 --env=production --rack=rack01The worker exposes RPC endpoints for miner management. To register a new Avalon miner:
{
"method": "registerThing",
"params": {
"opts": {
"address": "192.168.1.100",
"port": 4028,
"password": "root",
"timeout": 30000
},
"info": {
"serialNum": "AV123456",
"macAddress": "00:11:22:33:44:55",
"pos": "1",
"container": "container-01"
},
"tags": ["production", "site-1"]
}
}getRack: Get rack informationlistThings: List all managed minersregisterThing: Register a new minerupdateThing: Update miner configurationforgetThings: Remove minersqueryThing: Query individual miner methodsapplyThings: Apply operations to multiple minerstailLog: Retrieve historical data
Once registered, miners can be controlled through the queryThing RPC method:
// Reboot a miner
{
"method": "queryThing",
"params": {
"id": "miner-id",
"method": "reboot",
"params": []
}
}
// Set pools
{
"method": "queryThing",
"params": {
"id": "miner-id",
"method": "setPools",
"params": []
}
}
// Set power mode
{
"method": "queryThing",
"params": {
"id": "miner-id",
"method": "setPowerMode",
"params": ["high"] // "sleep", "normal", or "high"
}
}The worker automatically collects snapshots every 5 minutes (configurable) containing:
- Hashrate metrics (30s, 1m, 5m, 15m averages)
- Power consumption and efficiency
- Temperature readings (ambient, chip-level)
- Pool share statistics (accepted, rejected, stale)
- Uptime and error status
- Network settings
- Pool configurations
- Power mode
- LED status
- Firmware version
The system monitors for various error conditions:
- Pool Errors: Dead pools, connection failures
- Power Errors: PSU failures, short circuits
- Temperature Errors: Overheating conditions
- Hashboard Errors: Hardware failures, abnormal states
- Control Board Errors: Communication issues
Custom alerts can be configured, including:
- Chip Temperature Critical: Triggers when chip temperature exceeds threshold
- Standard miner alerts inherited from the base framework
A mock server is provided for testing without physical hardware:
node mock/server.js --type A1346The mock server simulates Avalon protocol responses for all supported commands.
npm test-
Create a new worker class extending
WrkMinerRack:class WrkMinerRackNewModel extends WrkMinerRack { getThingType() { return super.getThingType() + '-newmodel' } }
-
Update constants for model-specific parameters
-
Override methods as needed for model-specific behavior