Skip to content

Commit 7d008d8

Browse files
committed
Fixed incorrect hashrate reporting. A bit of a hack for now, but can be cleaned up and carefully tested in a bit
1 parent 5c5e90e commit 7d008d8

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

ppagent/main.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from string import Template
1212
from os.path import expanduser
1313

14-
version = '0.3.3'
14+
version = '0.3.4'
1515

1616
logger = logging.getLogger("ppagent")
1717
config_home = expanduser("~/.ppagent/")
@@ -136,19 +136,19 @@ def collect(self):
136136
self.queue.append([self.worker, 'thresholds', self.thresholds, now])
137137
self.sent_thresholds = True
138138

139+
mhs = []
139140
# if it's time to run, and we have status defined
140141
if ('status' in self.collectors or
141-
'temp' in self.collectors or
142-
'hashrate' in self.collectors):
143-
ret = self.call_devs()
144-
mhs, temps, details = ret
142+
'temp' in self.collectors or
143+
'hashrate' in self.collectors) and now >= self.collectors['status']['next_run']:
144+
mhs, temps, details = self.call_devs()
145145

146146
if 'status' in self.collectors and now >= self.collectors['status']['next_run']:
147147
conf = self.collectors['status']
148148
gpus = [{} for _ in temps]
149149
output = {"type": "cgminer", "gpus": gpus, "pool": self.pool_stat()}
150150
# if it failed to connect we should just skip collection
151-
if ret is None:
151+
if details is None:
152152
return
153153
if conf['temperature']:
154154
for i, temp in enumerate(temps):
@@ -224,10 +224,12 @@ def call_devs(self):
224224
# difference since last run, as opposed to reporting cgminers avg
225225
# megahash or 5s megahash
226226
if self.last_devs and len(self.last_devs) == len(data['DEVS']):
227-
mhs = [round(now['Total MH'] - last['Total MH'], 3)
227+
diff = time.time() - self._last_dev
228+
mhs = [round((now['Total MH'] - last['Total MH']) / diff, 3)
228229
for now, last in zip(data['DEVS'], self.last_devs)]
229230
else:
230231
mhs = []
232+
self._last_dev = time.time()
231233
self.last_devs = data['DEVS']
232234
return mhs, temps, details
233235

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
requires.append('argparse')
1919

2020
setup(name='ppagent',
21-
version='0.3.2',
21+
version='0.3.4',
2222
description='A statistics collection agent for powerpool mining server',
2323
author='Isaac Cook',
2424
long_description=README,

0 commit comments

Comments
 (0)