arvicco-avalon 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -2,23 +2,35 @@
2
2
 
3
3
  Helper scripts for Bitcoin and Avalon miners management...
4
4
 
5
+ ## Description
6
+
7
+ Congrats, you've got a few Avalon miners. It's all nice and dandy, but now you need to keep an eye on them to make sure they are always online and their valuable hashes are not wasted. This set of scripts is written to do just that. You run a monitor scipt non-stop and it keeps an eye on your Avalons, your (private) pool and your Internet connection, and alerts you as soon as there are any problems. The scripts should work on OSX and Linux (Windows users, move on).
8
+
5
9
  ## Usage
6
10
 
7
11
  Scripts:
8
12
 
9
- $ bin/monitor [environment]
13
+ $ monitor [environment]
10
14
 
11
- - Monitors all the nodes (miners, pools, Internet connections) that are listed in config/monitor.yml file. Sounds alarm is anything is wrong with the monitored nodes. TODO: takes action to correct errors found (like restarting the miners etc).
15
+ - Monitors all the nodes (miners, pools, Internet connections) that are listed in config/monitor.yml file. Sounds alarm is anything is wrong with the monitored nodes. TODO: takes action to correct errors found (like restarting the failing miners etc).
12
16
 
13
- $ mtgox_tx
17
+ $ mtgox_tx
14
18
 
15
19
  - Transcodes raw transaction from base64 (mtgox) to hex (blockchain) format
16
20
 
21
+ ## Installation
22
+
23
+ You need Ruby 1.9 to install the scripts. Once the Ruby is installed, it's just:
24
+
25
+ $ gem install arvicco-avalon
26
+
27
+ You need to be able to ssh with public keys (that is no password required) into any Pool or Bitcoind node for monitor to work. How to do it is beyound the scope of this Readme, just google it. You also need to create ~/.avalon/monitor.yml config file, see below.
28
+
17
29
  ## Configuration
18
30
 
19
- Sample monitor config file for production environment below. Modify it, add your own nodes to be monitored (for Avalon miners, you have to set their IP address and min hashrate in Gh/s):
31
+ Sample monitor config file for production environment below. Modify it, add your own nodes to be monitored (for Avalon miners, you have to indicate their IP address and min hashrate in Gh/s):
20
32
 
21
- ------- config/monitor.yml --------
33
+ ------- ~/.avalon/monitor.yml --------
22
34
  # Prod configuration (default)
23
35
  prod:
24
36
  :bitcoind:
@@ -1,16 +1,18 @@
1
1
  module Avalon
2
2
  # Global Config
3
3
  class Config
4
+ extend Utils # Helper methods
4
5
 
5
6
  def self.load env
6
- config_file = [
7
- File.expand_path('../../../config/monitor.yml', __FILE__),
8
- File.expand_path('~/.avalon/monitor.yml', __FILE__),
9
- ].find {|f| File.exist?(f)}
7
+ config_file = find_file( '../../../config/monitor.yml', '~/.avalon/monitor.yml')
10
8
 
11
9
  raise "No config file: #{config_file}" unless File.exist? config_file
12
10
 
13
11
  @config = YAML::load_file(config_file)[env]
12
+ @config[:environment] = env
13
+ @config[:block_file] = find_file( '../../../config/blocks.yml',
14
+ '~/.avalon/blocks.yml') || '~/.avalon/blocks.yml'
15
+
14
16
  end
15
17
 
16
18
  def self.[] key
@@ -6,7 +6,7 @@ module Avalon
6
6
  @ip = ip
7
7
  @update_frequency = frequency
8
8
  @update_num = 0
9
- @block_file = File.expand_path('../../../config/blocks.yml', __FILE__)
9
+ @block_file = Avalon::Config[:block_file]
10
10
  @blocks = load_blocks || {}
11
11
  super()
12
12
  end
@@ -40,6 +40,7 @@ module Avalon
40
40
  @num = ip.split('.').last.to_i
41
41
  @min_speed = min_speed * 1000 # Gh/s to Mh/s
42
42
  @fails = 0
43
+ @status_fails_to_alarm = Avalon::Config[:status_fails_to_alarm]
43
44
  super()
44
45
  end
45
46
 
@@ -71,7 +72,7 @@ module Avalon
71
72
  def report
72
73
  if data[:ping].nil?
73
74
  @fails += 1
74
- if @fails >= Avalon::Config[:status_fails_to_alarm] || 1
75
+ if @fails >= @status_fails_to_alarm || 1
75
76
  alarm "Miner #{@num} did not respond to status query"
76
77
  end
77
78
  else
@@ -5,13 +5,14 @@ module Avalon
5
5
  @system = `uname -a`.match(/^\w*/).to_s
6
6
  end
7
7
 
8
+ def find_file *locations
9
+ locations.map {|loc| File.expand_path(loc,__FILE__)}.find {|f| File.exist?(f)}
10
+ end
11
+
8
12
  # Helper method: play a sound file
9
13
  def play tune
10
- file = [ tune,
11
- File.expand_path("../../../sound/#{tune}", __FILE__),
12
- File.expand_path("~/sound/#{tune}", __FILE__),
13
- File.expand_path("/System/Library/Sounds/#{tune}"),
14
- ].find {|f| File.exist?(f)}
14
+ file = find_file( tune, "../../../sound/#{tune}",
15
+ "~/.avalon/sound/#{tune}", "/System/Library/Sounds/#{tune}")
15
16
 
16
17
  case system
17
18
  when 'Darwin'
@@ -1,3 +1,3 @@
1
1
  module Avalon
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: arvicco-avalon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-06-06 00:00:00.000000000 Z
12
+ date: 2013-06-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: faraday