A monitor for cgminer instances. It periodically captures device, status and summary information to MongoDB. It also provides a Rails engine to allow querying cgminer log information from within a Rails application. See cgminer_manager for an example of this type of integration.
- cgminer_api_client (~> 0.2.5)
- mongoid (= 4.0.0)
- rails (= 4.2.11)
- rake (~> 10.0)
Add the following to your Gemfile
:
gem 'cgminer_monitor', '~> 0.2.23'
$ gem install cgminer_monitor
$ git clone [email protected]:jramos/cgminer_monitor.git
Copy config/mongoid.yml.example
to config/mongoid.yml
and update as necessary.
production:
sessions:
default:
database: cgminer_monitor
hosts:
- localhost:27017
Copy config/miners.yml.example
to config/miners.yml
and update with the IP addresses (and optional ports and timeouts) of your cgminer instances. E.g.
# connect to localhost on the default port (4028) with the default timeout (5 seconds)
- host: 127.0.0.1
# connect to 192.168.1.1 on a non-standard port (1234) with a custom timeout (1 second)
- host: 192.168.1.1
port: 1234
timeout: 1
See cgminer_api_client for more information.
After configuring mongoid, be sure to create the indexes for the log documents.
$ rake cgminer_monitor:create_indexes
$ cgminer_monitor start
$ cgminer_monitor stop
$ cgminer_monitor restart
$ cgminer_monitor status
$ cgminer_monitor version
Update your config/routes.rb
file to mount the engine API endpoints:
mount CgminerMonitor::Engine => '/'
Checks the status of the cgminer_monitor process. Response status
element will either be "running
" or "stopped
".
/cgminer_monitor/api/v1/ping.json
Example response:
{
"timestamp": 1407879277,
"status": "running"
}
Each endpoint returns the previous hour's worth of data as a JSON array of data points.
Endpoints:
/cgminer_monitor/api/v1/graph_data/local_hashrate.json
/cgminer_monitor/api/v1/graph_data/miner_hashrate.json?miner_id=<miner-id>
Data point response format:
[
timestamp,
hashrate_5s,
hashrate_avg,
device_error_rate,
device_rejected_rate,
pool_rejected_rate,
pool_stale_rate
]
Endpoints:
/cgminer_monitor/api/v1/graph_data/local_temperature.json
/cgminer_monitor/api/v1/graph_data/miner_temperature.json?miner_id=<miner-id>
Data point response format:
[
timestamp,
min_temp,
avg_temp,
max_temp
]
Endpoints:
/cgminer_monitor/api/v1/graph_data/local_availability.json
/cgminer_monitor/api/v1/graph_data/miner_availability.json?miner_id=<miner-id>
Data point response format:
[
timestamp,
num_available,
num_configured
]
There's a cron script that monitors the status of cgminer_monitor and restarts it when it discovers it is not running.
Add the following to /etc/crontab
:
*/3 * * * * <user> cd <application root>; bundle exec cgminer_monitor-monitor
- Fork it ( https://github.com/jramos/cgminer_monitor/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
If you find this application useful, please consider donating.
BTC: 18HFFqZv2KJMHPNwPes839PJd5GZc4cT3U
Code released under the MIT license.