mirror of
https://github.com/lalanza808/monero.fail.git
synced 2025-08-12 09:30:09 -04:00
add health endpoint for a pal
This commit is contained in:
parent
b36e815cd6
commit
e98e553357
1 changed files with 29 additions and 0 deletions
|
@ -99,6 +99,35 @@ def nodes_json():
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@app.route("/health.json")
|
||||||
|
def health_json():
|
||||||
|
data = {}
|
||||||
|
nodes = Node.select().where(
|
||||||
|
Node.validated == True
|
||||||
|
)
|
||||||
|
for node in nodes:
|
||||||
|
if node.crypto not in data:
|
||||||
|
data[node.crypto] = {}
|
||||||
|
_d = {
|
||||||
|
"available": node.available,
|
||||||
|
"last_height": node.last_height,
|
||||||
|
"datetime_entered": node.datetime_entered,
|
||||||
|
"datetime_checked": node.datetime_checked,
|
||||||
|
"datetime_failed": node.datetime_failed,
|
||||||
|
"checks": [c.health for c in node.get_all_checks()]
|
||||||
|
}
|
||||||
|
nettype = "clear"
|
||||||
|
if node.is_tor:
|
||||||
|
nettype = "onion"
|
||||||
|
elif node.web_compatible:
|
||||||
|
if "web_compatible" not in data[node.crypto]:
|
||||||
|
data[node.crypto]["web_compatible"] = {}
|
||||||
|
data[node.crypto]["web_compatible"][node.url] = _d
|
||||||
|
if nettype not in data[node.crypto]:
|
||||||
|
data[node.crypto][nettype] = {}
|
||||||
|
data[node.crypto][nettype][node.url] = _d
|
||||||
|
return jsonify(data)
|
||||||
|
|
||||||
@app.route("/haproxy.cfg")
|
@app.route("/haproxy.cfg")
|
||||||
def haproxy():
|
def haproxy():
|
||||||
crypto = request.args.get('chain') or 'monero'
|
crypto = request.args.get('chain') or 'monero'
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue