Skip to content

Commit

Permalink
Fixed incorrect hashrate reporting. A bit of a hack for now, but can …
Browse files Browse the repository at this point in the history
…be cleaned up and carefully tested in a bit
  • Loading branch information
icook committed Mar 20, 2014
1 parent 5c5e90e commit 7d008d8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
16 changes: 9 additions & 7 deletions ppagent/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from string import Template
from os.path import expanduser

version = '0.3.3'
version = '0.3.4'

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

mhs = []
# if it's time to run, and we have status defined
if ('status' in self.collectors or
'temp' in self.collectors or
'hashrate' in self.collectors):
ret = self.call_devs()
mhs, temps, details = ret
'temp' in self.collectors or
'hashrate' in self.collectors) and now >= self.collectors['status']['next_run']:
mhs, temps, details = self.call_devs()

if 'status' in self.collectors and now >= self.collectors['status']['next_run']:
conf = self.collectors['status']
gpus = [{} for _ in temps]
output = {"type": "cgminer", "gpus": gpus, "pool": self.pool_stat()}
# if it failed to connect we should just skip collection
if ret is None:
if details is None:
return
if conf['temperature']:
for i, temp in enumerate(temps):
Expand Down Expand Up @@ -224,10 +224,12 @@ def call_devs(self):
# difference since last run, as opposed to reporting cgminers avg
# megahash or 5s megahash
if self.last_devs and len(self.last_devs) == len(data['DEVS']):
mhs = [round(now['Total MH'] - last['Total MH'], 3)
diff = time.time() - self._last_dev
mhs = [round((now['Total MH'] - last['Total MH']) / diff, 3)
for now, last in zip(data['DEVS'], self.last_devs)]
else:
mhs = []
self._last_dev = time.time()
self.last_devs = data['DEVS']
return mhs, temps, details

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
requires.append('argparse')

setup(name='ppagent',
version='0.3.2',
version='0.3.4',
description='A statistics collection agent for powerpool mining server',
author='Isaac Cook',
long_description=README,
Expand Down

0 comments on commit 7d008d8

Please sign in to comment.