Skip to content

Instantly share code, notes, and snippets.

@jamescoxon
Created February 1, 2022 16:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jamescoxon/88ff7061244c4209c8eaa016fac36064 to your computer and use it in GitHub Desktop.
Save jamescoxon/88ff7061244c4209c8eaa016fac36064 to your computer and use it in GitHub Desktop.
import time
import requests
import datetime
from dashing import *
url_address = 'http://localhost:7076'
time_out = 5
ui = HSplit(
VSplit(
HGauge(val=0, title="Count", border_color=5),
HGauge(title="Unchecked", val=0, border_color=5),
HGauge(title="Cemented", val=0, border_color=5)
),
VSplit(
Text('Nano Node Monitor\n https://github.com/jamescoxon/', border_color=2),
Log(title='logs', border_color=5),
HChart(title='Count delta/sec',border_color=2, color=2),
HChart(title='Unchecked delta/sec',border_color=2, color=2),
HChart(title='Cemented delta/sec',border_color=2, color=2),
# HBrailleChart(border_color=2, color=2),
# HBrailleFilledChart(border_color=2, color=2),
),
title='Nano Node Monitor',
)
log = ui.items[1].items[1]
hchart_count = ui.items[1].items[2]
hchart_unchecked = ui.items[1].items[3]
hchart_cemented = ui.items[1].items[4]
# bfchart = ui.items[1].items[5]
log.append("0 -----")
log.append("1 Nano Node")
log.append("2 -----")
prev_count = 0
prev_unchecked = 0
prev_cemented = 0
diff_count = 0
diff_unchecked = 0
diff_cemented = 0
while True:
prev_time = time.time()
data = requests.post(url_address, json = {"action":"block_count"}, timeout=time_out)
block_count = data.json()
current_count = int(block_count['count'])
ui.items[0].items[0].value = int(current_count) / 1500000
if prev_count > 0:
diff_count = current_count - prev_count
hchart_count.append(diff_count / 100)
prev_count = current_count
current_unchecked = int(block_count['unchecked'])
ui.items[0].items[1].value = int(current_unchecked) / 1500000
if prev_unchecked > 0:
diff_unchecked = current_unchecked - prev_unchecked
hchart_unchecked.append(diff_unchecked / 100)
prev_unchecked = current_unchecked
current_cemented = int(block_count['cemented'])
ui.items[0].items[2].value = int(current_cemented) / 1500000
if prev_cemented > 0:
diff_cemented = current_cemented - prev_cemented
hchart_cemented.append(diff_cemented / 100)
prev_cemented = current_cemented
t = int(time.time())
if t != prev_time:
log.append("{} {} {} {} {}".format(t, current_count, current_unchecked, diff_unchecked, current_cemented))
ui.display()
time.sleep(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment