Skip to content

Instantly share code, notes, and snippets.

@d3m3vilurr
Last active June 23, 2021 14:19
Show Gist options
  • Save d3m3vilurr/8602741 to your computer and use it in GitHub Desktop.
Save d3m3vilurr/8602741 to your computer and use it in GitHub Desktop.
make wafflepool personal stat graph

wafflepool monitor It just quick and dirty code.

Requirements

  • python-rrdtool
  • requests

Install

Just clone this, and add minutely cronjob

Demo

http://waffle.suod.kr/

<html>
<head>
<title>WAFFLEPOOL EXCHANGE MONITOR</title>
<meta http-equiv="refresh" content="60" />
</head>
<body>
<a href="monitor.html">RETURN</a>
<div>
<h2>EXCHANGE 6H:</h2>
<img src="exchanges-6h.png" alt="6H exchanges graph" /></a>
</div>
<div>
<h2>EXCHANGE 1D:</h2>
<img src="exchanges-1d.png" alt="1D exchanges graph" /></a>
</div>
<div>
<h2>EXCHANGE 1W:</h2>
<img src="exchanges-1w.png" alt="1W exchanges graph" /></a>
</div>
<div>
<h2>EXCHANGE 1M:</h2>
<img src="exchanges-1m.png" alt="1M exchanges graph" /></a>
</div>
</body>
</html>
# -*- coding: utf-8 -*-
import os
import requests
import rrdtool
import time
import datetime
import json
def parse():
url = 'http://wafflepool.com/tmp_api?address=<YOUR_BTC_ADDRESS>'
res = requests.get(url)
data = res.json()
return dict(hash=int(data['hash_rate'])/1000./1000.,
paid=data['balances']['sent'],
converted=data['balances']['confirmed'],
unexchanged=data['balances']['unconverted'])
def create_rrd():
if os.path.exists('wafflepool.rrd'):
return
rrdtool.create('wafflepool.rrd',
'--step', '60',
['DS:hashrate:GAUGE:600:0:U',
'DS:converted:GAUGE:600:0:U',
'DS:paid:GAUGE:600:0:U',
'DS:unexchanged:GAUGE:600:0:U',
'DS:unpaid:GAUGE:600:0:U'],
'RRA:AVERAGE:0.5:1:600',
'RRA:AVERAGE:0.5:6:700',
'RRA:AVERAGE:0.5:24:775',
'RRA:AVERAGE:0.5:288:797',
'RRA:LAST:0.5:1:600',
'RRA:LAST:0.5:6:700',
'RRA:LAST:0.5:24:775',
'RRA:LAST:0.5:288:797')
def update_rrd(data):
unpaid = float(data['converted']) + float(data['unexchanged'])
fields = (str(x) for x in ('N', data['hash'], data['converted'],
data['paid'], data['unexchanged'], unpaid))
rrdtool.update('wafflepool.rrd', str(':'.join(fields)))
def create_graph():
now = str(datetime.datetime.now()).split('.')[0]
for x in ['-6h', '-1d', '-1w', '-1m']:
rrdtool.graph('hashrate%s.png' % x,
'--end', 'now',
'--start', x,
'--vertical-label', 'Hash Rate (MH/s)',
'--title', 'Hash Rate',
'--lower-limit', '0',
'--width', '720',
'--height', '180',
'--watermark', now,
'DEF:hr=wafflepool.rrd:hashrate:AVERAGE',
'DEF:hr30m=wafflepool.rrd:hashrate:AVERAGE:step=1800',
'DEF:hr1h=wafflepool.rrd:hashrate:AVERAGE:step=3600',
'DEF:hr6h=wafflepool.rrd:hashrate:AVERAGE:step=21600',
'AREA:hr#3FD212:Hash Rate',
'LINE2:hr30m#FF9900:Hash Rate (30m)',
'LINE2:hr1h#DC3912:Hash Rate (1h)',
'LINE2:hr6h#3366CC:Hash Rate (6h)',
'COMMENT:\\n',
'GPRINT:hr:MIN:MIN\: %4.2lf MH/s',
'COMMENT: ',
'GPRINT:hr:AVERAGE:AVG\: %4.2lf MH/s',
'COMMENT: ',
'GPRINT:hr:MAX:MAX\: %4.2lf MH/s\\r')
rrdtool.graph('exchanges%s.png' % x,
'--end', 'now',
'--start', x,
'--vertical-label', 'mBTC',
'--title', 'Approx Balances',
'--lower-limit', '0',
'--width', '720',
'--height', '180',
'--watermark', now,
'DEF:converted=wafflepool.rrd:converted:LAST',
'CDEF:mconverted=converted,1000,*',
'DEF:unexchanged=wafflepool.rrd:unexchanged:AVERAGE',
'CDEF:munexchanged=unexchanged,1000,*',
'DEF:last_unexchanged=wafflepool.rrd:unexchanged:LAST',
'CDEF:unpaid=converted,unexchanged,+',
'CDEF:last_unpaid=converted,last_unexchanged,+',
'CDEF:munpaid=unpaid,1000,*',
'AREA:munpaid#3FD212:Total',
'AREA:munexchanged#FF9900:Unexchanged',
'LINE2:mconverted#DC3912:Converted',
'COMMENT:\\n',
'GPRINT:converted:LAST:CURRENT CONVERTED\: %0.8lf BTC\\r',
'COMMENT:\\n',
'GPRINT:last_unexchanged:LAST:CURRENT UNEXCHANGED\: %0.8lf BTC\\r',
'COMMENT:\\n',
'GPRINT:last_unpaid:LAST:CURRENT TOTAL\: %0.8lf BTC\\r')
rrdtool.graph('payout%s.png' % x,
'--end', 'now',
'--start', x,
'--vertical-label', 'mBTC',
'--title', 'Payout Balances',
#'--lower-limit', '0',
'--width', '720',
'--height', '180',
'--watermark', now,
'DEF:paid=wafflepool.rrd:paid:LAST',
'DEF:converted=wafflepool.rrd:converted:LAST',
'DEF:unexchanged=wafflepool.rrd:unexchanged:AVERAGE',
'DEF:last_unexchanged=wafflepool.rrd:unexchanged:LAST',
'CDEF:unpaid=converted,unexchanged,+',
'CDEF:last_unpaid=converted,last_unexchanged,+',
'CDEF:mpaid=paid,1000,*',
'CDEF:total_balances=paid,unpaid,+',
'CDEF:last_total_balances=paid,last_unpaid,+',
'CDEF:total_converted=paid,converted,+',
'CDEF:mtotal_balances=total_balances,1000,*',
'CDEF:mtotal_converted=total_converted,1000,*',
'AREA:mtotal_balances#3FD212:Unexchanged',
'AREA:mtotal_converted#DC3912:Exchanged',
'AREA:mpaid#3366CC:Payout',
'COMMENT:\\n',
'GPRINT:last_unpaid:LAST:CURRENT UNPAID\: %0.8lf BTC\\r',
'COMMENT:\\n',
'GPRINT:paid:LAST:CURRENT PAID\: %0.8lf BTC\\r',
'COMMENT:\\n',
'GPRINT:last_total_balances:LAST:CURRENT APPROX TOTAL\: %0.8lf BTC\\r')
if __name__ == '__main__':
data = parse()
create_rrd()
update_rrd(data)
create_graph()
<html>
<head>
<title>WAFFLEPOOL HASHRATE MONITOR</title>
<meta http-equiv="refresh" content="60" />
</head>
<body>
<a href="monitor.html">RETURN</a>
<div>
<h2>HASHRATE 6H:</h2>
<img src="hashrate-6h.png" alt="6H hashrate graph" /></a>
</div>
<div>
<h2>HASHRATE 1D:</h2>
<img src="hashrate-1d.png" alt="1D hashrate graph" /></a>
</div>
<div>
<h2>HASHRATE 1W:</h2>
<img src="hashrate-1w.png" alt="1W hashrate graph" /></a>
</div>
<div>
<h2>HASHRATE 1M:</h2>
<img src="hashrate-1m.png" alt="1M hashrate graph" /></a>
</div>
</body>
</html>
<html>
<head>
<title>WAFFLEPOOL MONITOR</title>
<meta http-equiv="refresh" content="60" />
</head>
<body>
<div>
<h2>HASH RATE:</h2>
<a href="hashrate.html"><img src="hashrate-6h.png" alt="6H hashrate graph" /></a>
</div>
<div>
<h2>EXCHANGE:</h2>
<a href="exchange.html"><img src="exchanges-6h.png" alt="6H exchange graph" /></a>
</div>
<div>
<h2>PAYOUT:</h2>
<a href="payout.html"><img src="payout-6h.png" alt="6H payout graph" /></a>
</div>
</body>
</html>
<html>
<head>
<title>WAFFLEPOOL PAYOUT MONITOR</title>
<meta http-equiv="refresh" content="60" />
</head>
<body>
<a href="monitor.html">RETURN</a>
<div>
<h2>PAYOUT 6H:</h2>
<img src="payout-6h.png" alt="6H payout graph" /></a>
</div>
<div>
<h2>PAYOUT 1D:</h2>
<img src="payout-1d.png" alt="1D payout graph" /></a>
</div>
<div>
<h2>PAYOUT 1W:</h2>
<img src="payout-1w.png" alt="1W payout graph" /></a>
</div>
<div>
<h2>PAYOUT 1M:</h2>
<img src="payout-1m.png" alt="1M payout graph" /></a>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment