Beispiel #1
0
        workers = {}
        num = 0
        for n in dat3:
            w = {
              'rate': n["KHS"],
              'temp': 0,
              'watt': 0,
              'fan' : 0,
              'num' : n["GPU"] 
            }
            workers[num] = w
            num = num + 1

        for n in workers:
            w = workers[n]
            miner.dispatch_worker(w['num'], rigname, cfg['algo'], [w['rate'], w['temp'], w['watt'], w['fan']])
        miner.dispatch_miner(miner.get_master(), 'rigpass', rigname, software, cfg['algo'], uptime, pools, cfg['factor'], cfg['units'])

    except NameError, e:
        collectd.info('error parsing json for {0}:  {1}'.format(cfg['software'], e))
        return

    return

def readvals():
    for rig in cfg['rigs']:
        collectd.info('reading: {0} @ {1}'.format(rig['rigname'], rig['url']))
        readvals_claymore(rig['url'], rig['rigname'])

if __name__ == '__main__':
    readvals_claymore('localhost:4068', 'miner3')
    try:
        if j == '':
            return
        software = j['version']
        uptime = j['connection']['uptime']
        pool = j['connection']['pool']
        num = 0
        hashrate = j['hashrate']
        for n in hashrate['threads']:
            rate = n[0]
            if rate == None:
                rate = n[1]


#            collectd.info('dispatching: {0} @ {1}'.format('worker' + str(num), str(rate)))
            miner.dispatch_worker(num, rigname, cfg['algo'],
                                  [str(rate), 0, 0, 0])
            num = num + 1
        r = requests.post(miner.get_master(),
                          json={
                              "password": "******",
                              "rigname": rigname,
                              "uptime": uptime,
                              "software": software,
                              "algo": cfg['algo'],
                              "pool": pool,
                              "factor": 1,
                              "unit": 'sol'
                          })
    except NameError, e:
        collectd.info('error parsing json for {0}:  {1}'.format(
            cfg['software'], e))
def readvals_bminer(url, rigname):
    try:
        j = miner.GetData_JsonRpc(url)
    except ValueError, e:
        collectd.info('error getting restapi for {0}:  {1}'.format(cfg['software'], e))
        return

    try:
      software = "dstm " + j['version']
      uptime = j['uptime']
      pool = j['server']
      num = 0
      num_miners = len(j['result'])
      miners = j['result']
      for x in miners:
        miner.dispatch_worker(num, rigname, cfg['algo'], [x['avg_sol_ps'], x['temperature'], x['avg_power_usage'], 0])
        num = num + 1
      miner.dispatch_miner(miner.get_master(), 'rigpass', rigname, software, cfg['algo'], uptime, pool, 1, 'sol')
    except:
      collectd.info('error processing for ' + url);
      print 'error processing'
    return

def readvals():
    for rig in cfg['rigs']:
        collectd.info('reading: {0} @ {1}'.format(rig['rigname'], rig['url']))
        readvals_bminer(rig['url'], rig['rigname'])

if __name__ == "__main__":
    print "main"
    readvals_bminer('http://192.168.50.18:2222', 'miner')
        return

    end_time = time.time()

    software = "bminer " + j['version']
    uptime = end_time - start_time
    pool = ''
    num = 0
    num_miners = len(j['miners'])
    miners = j['miners']
    for x in miners:
        m = miners[x]
        device = m['device']
        solver = m['solver']
        miner.dispatch_worker(num, rigname, cfg['algo'], [
            solver['solution_rate'], device['temperature'], device['power'], 0
        ])
        num = num + 1
    miner.dispatch_miner(miner.get_master(), 'rigpass', rigname, software,
                         cfg['algo'], uptime, pool, 1, 'sol')
    return


def readvals():
    for rig in cfg['rigs']:
        collectd.info('reading: {0} @ {1}'.format(rig['rigname'], rig['url']))
        readvals_bminer(rig['url'], rig['rigname'])


collectd.register_config(readconf)
collectd.register_read(readvals, int(cfg['interval']))