brigade-monitor 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/brigade/monitor.rb +1 -0
- data/lib/brigade/monitor/fetcher.rb +195 -0
- data/lib/brigade/monitor/monitor.rb +6 -136
- data/lib/brigade/monitor/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 42913c81a6ba2f818d06b683394046a5091d36f4
|
4
|
+
data.tar.gz: 31e2ab33dcf8c8aa0e78dd8a80ee92065ab2c034
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ab39369247971c1dc5a2132f9314f9de68b63fa85cf77fb24e6b0fd8a654da11808baa36ce1b8a9ce7fcacfa62e39ef3dc2e2b4925298a6f54b136a2d7b2c7d7
|
7
|
+
data.tar.gz: d7ba654623249a30bdad40f1e6e86e526e79e49c5836b1865266408951e0d6f658582f6a986915bb7614b9a33d08a3b772426a04f0dd2289a4fa5577c160393b
|
data/lib/brigade/monitor.rb
CHANGED
@@ -0,0 +1,195 @@
|
|
1
|
+
module Brigade
|
2
|
+
module Monitor
|
3
|
+
|
4
|
+
class Fetcher
|
5
|
+
|
6
|
+
def initialize(client, name, logger)
|
7
|
+
@client = client
|
8
|
+
@name = name
|
9
|
+
@log = logger
|
10
|
+
end
|
11
|
+
|
12
|
+
def get_update
|
13
|
+
version = @client.version
|
14
|
+
summary = @client.summary
|
15
|
+
devs = @client.devs
|
16
|
+
pools = @client.pools
|
17
|
+
|
18
|
+
# XXX check status replies on each command?
|
19
|
+
|
20
|
+
update = host_info(summary, version)
|
21
|
+
|
22
|
+
devs.body.each do |dev|
|
23
|
+
if dev.has_key? 'GPU'
|
24
|
+
update[:gpus] << gpu_info(dev)
|
25
|
+
elsif dev.has_key? 'ASC'
|
26
|
+
update[:asics] << asic_info(dev)
|
27
|
+
elsif dev.has_key? 'PGA'
|
28
|
+
update[:fpgas] << fpga_info(dev)
|
29
|
+
else
|
30
|
+
@log.warn("Skipped unknown device: #{dev}")
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
pools.body.each do |pool|
|
35
|
+
update[:pools] << pool_info(pool)
|
36
|
+
end
|
37
|
+
|
38
|
+
@log.debug("Built update: #{update}")
|
39
|
+
update
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def host_info(summary, version)
|
45
|
+
sum = summary.body[0]
|
46
|
+
ver = version.body[0]
|
47
|
+
{
|
48
|
+
host: @name,
|
49
|
+
uptime: sum['Elapsed'],
|
50
|
+
mhash_average: sum['MHS av'],
|
51
|
+
mhash_current: sum['MHS 5s'],
|
52
|
+
found_blocks: sum['Found Blocks'],
|
53
|
+
getworks: sum['Getworks'],
|
54
|
+
accepted: sum['Accepted'],
|
55
|
+
rejected: sum['Rejected'],
|
56
|
+
hardware_errors: sum['Hardware Errors'],
|
57
|
+
utility: sum['Utility'],
|
58
|
+
discarded: sum['Discarded'],
|
59
|
+
stale: sum['Stale'],
|
60
|
+
get_failures: sum['Get Failures'],
|
61
|
+
local_work: sum['Local Work'],
|
62
|
+
remote_failures: sum['Remote Failures'],
|
63
|
+
network_blocks: sum['Network Blocks'],
|
64
|
+
total_mhash: sum['Total MH'],
|
65
|
+
work_utility: sum['Work Utility'],
|
66
|
+
difficulty_accepted: sum['Difficulty Accepted'],
|
67
|
+
difficulty_rejected: sum['Difficulty Rejected'],
|
68
|
+
difficulty_stale: sum['Difficulty Stale'],
|
69
|
+
best_share: sum['Best Share'],
|
70
|
+
device_hardware_percent: sum['Device Hardware%'],
|
71
|
+
device_rejected_percent: sum['Device Rejected%'],
|
72
|
+
pool_rejected_percent: sum['Pool Rejected%'],
|
73
|
+
pool_stale_percent: sum['Pool Stale%'],
|
74
|
+
api_version: ver['API'],
|
75
|
+
cgminer_version: ver['CGMiner'],
|
76
|
+
sgminer_version: ver['SGMiner'],
|
77
|
+
asics: [],
|
78
|
+
fpgas: [],
|
79
|
+
gpus: [],
|
80
|
+
pools: [],
|
81
|
+
agent: {
|
82
|
+
name: 'brigade-monitor-gem',
|
83
|
+
platform: RUBY_PLATFORM,
|
84
|
+
version: Brigade::Monitor::VERSION
|
85
|
+
}
|
86
|
+
}
|
87
|
+
end
|
88
|
+
|
89
|
+
def asic_info(device)
|
90
|
+
{
|
91
|
+
index: device['ASC'],
|
92
|
+
temperature: device['Temperature'],
|
93
|
+
enabled: device['Enabled'] == 'Y',
|
94
|
+
status: device['Status'],
|
95
|
+
uptime: device['Device Elapsed'],
|
96
|
+
mhash_average: device['MHS av'],
|
97
|
+
mhash_current: device['MHS 5s'],
|
98
|
+
accepted: device['Accepted'],
|
99
|
+
rejected: device['Rejected'],
|
100
|
+
hardware_errors: device['Hardware Errors'],
|
101
|
+
utility: device['Utility'],
|
102
|
+
rejected_percent: device['Device Rejected%'],
|
103
|
+
last_share_pool: device['Last Share Pool'],
|
104
|
+
last_share_time: device['Last Share Time'],
|
105
|
+
total_mhash: device['Total MH'],
|
106
|
+
diff1_work: device['Diff1 Work'],
|
107
|
+
difficulty_accepted: device['Difficulty Accepted'],
|
108
|
+
difficulty_rejected: device['Difficulty Rejected'],
|
109
|
+
last_share_difficulty: device['Last Share Difficulty'],
|
110
|
+
last_valid_work: device['Last Valid Work'],
|
111
|
+
}
|
112
|
+
end
|
113
|
+
|
114
|
+
def fpga_info(device)
|
115
|
+
{
|
116
|
+
index: device['PGA'],
|
117
|
+
temperature: device['Temperature'],
|
118
|
+
enabled: device['Enabled'] == 'Y',
|
119
|
+
status: device['Status'],
|
120
|
+
uptime: device['Device Elapsed'],
|
121
|
+
mhash_average: device['MHS av'],
|
122
|
+
mhash_current: device['MHS 5s'],
|
123
|
+
accepted: device['Accepted'],
|
124
|
+
rejected: device['Rejected'],
|
125
|
+
hardware_errors: device['Hardware Errors'],
|
126
|
+
utility: device['Utility'],
|
127
|
+
rejected_percent: device['Device Rejected%'],
|
128
|
+
last_share_pool: device['Last Share Pool'],
|
129
|
+
last_share_time: device['Last Share Time'],
|
130
|
+
total_mhash: device['Total MH'],
|
131
|
+
frequency: device['Frequency'],
|
132
|
+
diff1_work: device['Diff1 Work'],
|
133
|
+
difficulty_accepted: device['Difficulty Accepted'],
|
134
|
+
difficulty_rejected: device['Difficulty Rejected'],
|
135
|
+
last_share_difficulty: device['Last Share Difficulty'],
|
136
|
+
last_valid_work: device['Last Valid Work'],
|
137
|
+
}
|
138
|
+
end
|
139
|
+
|
140
|
+
def gpu_info(device)
|
141
|
+
{
|
142
|
+
index: device['GPU'],
|
143
|
+
temperature: device['Temperature'],
|
144
|
+
fan_speed: device['Fan Speed'],
|
145
|
+
fan_percent: device['Fan Percent'],
|
146
|
+
gpu_clock: device['GPU Clock'],
|
147
|
+
memory_clock: device['Memory Clock'],
|
148
|
+
gpu_voltage: device['GPU Voltage'],
|
149
|
+
gpu_activity: device['GPU Activity'],
|
150
|
+
powertune: device['Powertune'],
|
151
|
+
enabled: device['Enabled'] == 'Y',
|
152
|
+
status: device['Status'],
|
153
|
+
uptime: device['Device Elapsed'],
|
154
|
+
mhash_average: device['MHS av'],
|
155
|
+
mhash_current: device['MHS 5s'],
|
156
|
+
accepted: device['Accepted'],
|
157
|
+
rejected: device['Rejected'],
|
158
|
+
hardware_errors: device['Hardware Errors'],
|
159
|
+
utility: device['Utility'],
|
160
|
+
intensity: device['Intensity'],
|
161
|
+
rejected_percent: device['Device Rejected%'],
|
162
|
+
last_share_pool: device['Last Share Pool'],
|
163
|
+
last_share_time: device['Last Share Time'],
|
164
|
+
total_mhash: device['Total MH'],
|
165
|
+
diff1_work: device['Diff1 Work'],
|
166
|
+
difficulty_accepted: device['Difficulty Accepted'],
|
167
|
+
difficulty_rejected: device['Difficulty Rejected'],
|
168
|
+
last_share_difficulty: device['Last Share Difficulty'],
|
169
|
+
last_valid_work: device['Last Valid Work'],
|
170
|
+
}
|
171
|
+
end
|
172
|
+
|
173
|
+
def pool_info(pool)
|
174
|
+
{
|
175
|
+
index: pool['POOL'],
|
176
|
+
url: pool['URL'],
|
177
|
+
status: pool['Status'],
|
178
|
+
priority: pool['Priority'],
|
179
|
+
quota: pool['Quota'],
|
180
|
+
longpoll: pool['Long Poll'] == 'Y',
|
181
|
+
getworks: pool['Getworks'],
|
182
|
+
accepted: pool['Accepted'],
|
183
|
+
rejected: pool['Rejected'],
|
184
|
+
works: pool['Works'],
|
185
|
+
discarded: pool['Discarded'],
|
186
|
+
stale: pool['Stale'],
|
187
|
+
active: pool['Stratum Active'],
|
188
|
+
rejected_percent: pool['Pool Rejected%']
|
189
|
+
}
|
190
|
+
end
|
191
|
+
|
192
|
+
end
|
193
|
+
|
194
|
+
end
|
195
|
+
end
|
@@ -7,7 +7,11 @@ module Brigade
|
|
7
7
|
|
8
8
|
def initialize(key, miners, logger)
|
9
9
|
@key = key
|
10
|
-
@miners = miners
|
10
|
+
@miners = miners.map do |m|
|
11
|
+
fetcher = Brigade::Monitor::Fetcher.new(m[:client], m[:name], logger)
|
12
|
+
{ fetcher: fetcher }.merge(m)
|
13
|
+
end
|
14
|
+
puts @miners.inspect
|
11
15
|
@log = logger
|
12
16
|
end
|
13
17
|
|
@@ -22,7 +26,7 @@ module Brigade
|
|
22
26
|
@log.debug("Beginning miner: #{miner}")
|
23
27
|
|
24
28
|
begin
|
25
|
-
updates << get_update
|
29
|
+
updates << miner[:fetcher].get_update
|
26
30
|
rescue Net::OpenTimeout => e
|
27
31
|
@log.warn("Net::OpenTimeout building update for #{miner[:name]} (#{e})")
|
28
32
|
# XXX put something in the update to indicate it barfed
|
@@ -60,140 +64,6 @@ module Brigade
|
|
60
64
|
end
|
61
65
|
end
|
62
66
|
|
63
|
-
def get_update(miner)
|
64
|
-
version = miner[:client].version
|
65
|
-
summary = miner[:client].summary
|
66
|
-
devs = miner[:client].devs
|
67
|
-
pools = miner[:client].pools
|
68
|
-
|
69
|
-
# XXX check status replies on each command?
|
70
|
-
|
71
|
-
update = {
|
72
|
-
host: miner[:name],
|
73
|
-
uptime: summary.body[0]['Elapsed'],
|
74
|
-
mhash: summary.body[0]['MHS av'],
|
75
|
-
rejected_percent: summary.body[0]['Pool Rejected%'],
|
76
|
-
api_version: version.body[0]['API'],
|
77
|
-
cgminer_version: version.body[0]['CGMiner'],
|
78
|
-
sgminer_version: version.body[0]['SGMiner'],
|
79
|
-
asics: [],
|
80
|
-
fpgas: [],
|
81
|
-
gpus: [],
|
82
|
-
pools: [],
|
83
|
-
agent: {
|
84
|
-
name: 'brigade-monitor-gem',
|
85
|
-
platform: RUBY_PLATFORM,
|
86
|
-
version: Brigade::Monitor::VERSION
|
87
|
-
}
|
88
|
-
}
|
89
|
-
|
90
|
-
devs.body.each do |dev|
|
91
|
-
if dev.has_key? 'GPU'
|
92
|
-
update[:gpus] << {
|
93
|
-
index: dev['GPU'],
|
94
|
-
temperature: dev['Temperature'],
|
95
|
-
fan_speed: dev['Fan Speed'],
|
96
|
-
fan_percent: dev['Fan Percent'],
|
97
|
-
gpu_clock: dev['GPU Clock'],
|
98
|
-
memory_clock: dev['Memory Clock'],
|
99
|
-
gpu_voltage: dev['GPU Voltage'],
|
100
|
-
gpu_activity: dev['GPU Activity'],
|
101
|
-
powertune: dev['Powertune'],
|
102
|
-
enabled: dev['Enabled'] == 'Y',
|
103
|
-
status: dev['Status'],
|
104
|
-
uptime: dev['Device Elapsed'],
|
105
|
-
mhash_average: dev['MHS av'],
|
106
|
-
mhash_current: dev['MHS 5s'],
|
107
|
-
accepted: dev['Accepted'],
|
108
|
-
rejected: dev['Rejected'],
|
109
|
-
hardware_errors: dev['Hardware Errors'],
|
110
|
-
utility: dev['Utility'],
|
111
|
-
intensity: dev['Intensity'],
|
112
|
-
rejected_percent: dev['Device Rejected%'],
|
113
|
-
last_share_pool: dev['Last Share Pool'],
|
114
|
-
last_share_time: dev['Last Share Time'],
|
115
|
-
total_mhash: dev['Total MH'],
|
116
|
-
diff1_work: dev['Diff1 Work'],
|
117
|
-
difficulty_accepted: dev['Difficulty Accepted'],
|
118
|
-
difficulty_rejected: dev['Difficulty Rejected'],
|
119
|
-
last_share_difficulty: dev['Last Share Difficulty'],
|
120
|
-
last_valid_work: dev['Last Valid Work'],
|
121
|
-
}
|
122
|
-
elsif dev.has_key? 'ASC'
|
123
|
-
update[:asics] << {
|
124
|
-
index: dev['ASC'],
|
125
|
-
temperature: dev['Temperature'],
|
126
|
-
enabled: dev['Enabled'] == 'Y',
|
127
|
-
status: dev['Status'],
|
128
|
-
uptime: dev['Device Elapsed'],
|
129
|
-
mhash_average: dev['MHS av'],
|
130
|
-
mhash_current: dev['MHS 5s'],
|
131
|
-
accepted: dev['Accepted'],
|
132
|
-
rejected: dev['Rejected'],
|
133
|
-
hardware_errors: dev['Hardware Errors'],
|
134
|
-
utility: dev['Utility'],
|
135
|
-
rejected_percent: dev['Device Rejected%'],
|
136
|
-
last_share_pool: dev['Last Share Pool'],
|
137
|
-
last_share_time: dev['Last Share Time'],
|
138
|
-
total_mhash: dev['Total MH'],
|
139
|
-
diff1_work: dev['Diff1 Work'],
|
140
|
-
difficulty_accepted: dev['Difficulty Accepted'],
|
141
|
-
difficulty_rejected: dev['Difficulty Rejected'],
|
142
|
-
last_share_difficulty: dev['Last Share Difficulty'],
|
143
|
-
last_valid_work: dev['Last Valid Work'],
|
144
|
-
}
|
145
|
-
elsif dev.has_key? 'PGA'
|
146
|
-
update[:fpgas] << {
|
147
|
-
index: dev['PGA'],
|
148
|
-
temperature: dev['Temperature'],
|
149
|
-
enabled: dev['Enabled'] == 'Y',
|
150
|
-
status: dev['Status'],
|
151
|
-
uptime: dev['Device Elapsed'],
|
152
|
-
mhash_average: dev['MHS av'],
|
153
|
-
mhash_current: dev['MHS 5s'],
|
154
|
-
accepted: dev['Accepted'],
|
155
|
-
rejected: dev['Rejected'],
|
156
|
-
hardware_errors: dev['Hardware Errors'],
|
157
|
-
utility: dev['Utility'],
|
158
|
-
rejected_percent: dev['Device Rejected%'],
|
159
|
-
last_share_pool: dev['Last Share Pool'],
|
160
|
-
last_share_time: dev['Last Share Time'],
|
161
|
-
total_mhash: dev['Total MH'],
|
162
|
-
frequency: dev['Frequency'],
|
163
|
-
diff1_work: dev['Diff1 Work'],
|
164
|
-
difficulty_accepted: dev['Difficulty Accepted'],
|
165
|
-
difficulty_rejected: dev['Difficulty Rejected'],
|
166
|
-
last_share_difficulty: dev['Last Share Difficulty'],
|
167
|
-
last_valid_work: dev['Last Valid Work'],
|
168
|
-
}
|
169
|
-
else
|
170
|
-
@log.warn("Skipped unknown device: #{dev}")
|
171
|
-
end
|
172
|
-
end
|
173
|
-
|
174
|
-
pools.body.each do |pool|
|
175
|
-
update[:pools] << {
|
176
|
-
index: pool['POOL'],
|
177
|
-
url: pool['URL'],
|
178
|
-
status: pool['Status'],
|
179
|
-
priority: pool['Priority'],
|
180
|
-
quota: pool['Quota'],
|
181
|
-
longpoll: pool['Long Poll'] == 'Y',
|
182
|
-
getworks: pool['Getworks'],
|
183
|
-
accepted: pool['Accepted'],
|
184
|
-
rejected: pool['Rejected'],
|
185
|
-
works: pool['Works'],
|
186
|
-
discarded: pool['Discarded'],
|
187
|
-
stale: pool['Stale'],
|
188
|
-
active: pool['Stratum Active'],
|
189
|
-
rejected_percent: pool['Pool Rejected%']
|
190
|
-
}
|
191
|
-
end
|
192
|
-
|
193
|
-
@log.debug("Built update: #{update}")
|
194
|
-
update
|
195
|
-
end
|
196
|
-
|
197
67
|
end
|
198
68
|
|
199
69
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: brigade-monitor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nick Veys
|
@@ -169,6 +169,7 @@ files:
|
|
169
169
|
- brigade-monitor.gemspec
|
170
170
|
- lib/brigade/monitor.rb
|
171
171
|
- lib/brigade/monitor/api.rb
|
172
|
+
- lib/brigade/monitor/fetcher.rb
|
172
173
|
- lib/brigade/monitor/monitor.rb
|
173
174
|
- lib/brigade/monitor/version.rb
|
174
175
|
- sample-config.yaml
|