|
11 | 11 | from string import Template |
12 | 12 | from os.path import expanduser |
13 | 13 |
|
14 | | -version = '0.3.3' |
| 14 | +version = '0.3.4' |
15 | 15 |
|
16 | 16 | logger = logging.getLogger("ppagent") |
17 | 17 | config_home = expanduser("~/.ppagent/") |
@@ -136,19 +136,19 @@ def collect(self): |
136 | 136 | self.queue.append([self.worker, 'thresholds', self.thresholds, now]) |
137 | 137 | self.sent_thresholds = True |
138 | 138 |
|
| 139 | + mhs = [] |
139 | 140 | # if it's time to run, and we have status defined |
140 | 141 | 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() |
145 | 145 |
|
146 | 146 | if 'status' in self.collectors and now >= self.collectors['status']['next_run']: |
147 | 147 | conf = self.collectors['status'] |
148 | 148 | gpus = [{} for _ in temps] |
149 | 149 | output = {"type": "cgminer", "gpus": gpus, "pool": self.pool_stat()} |
150 | 150 | # if it failed to connect we should just skip collection |
151 | | - if ret is None: |
| 151 | + if details is None: |
152 | 152 | return |
153 | 153 | if conf['temperature']: |
154 | 154 | for i, temp in enumerate(temps): |
@@ -224,10 +224,12 @@ def call_devs(self): |
224 | 224 | # difference since last run, as opposed to reporting cgminers avg |
225 | 225 | # megahash or 5s megahash |
226 | 226 | 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) |
228 | 229 | for now, last in zip(data['DEVS'], self.last_devs)] |
229 | 230 | else: |
230 | 231 | mhs = [] |
| 232 | + self._last_dev = time.time() |
231 | 233 | self.last_devs = data['DEVS'] |
232 | 234 | return mhs, temps, details |
233 | 235 |
|
|
0 commit comments