mirror of
https://github.com/lalanza808/monero.fail.git
synced 2026-01-21 07:11:11 -05:00
remove nodes if all the health checks are failed
This commit is contained in:
parent
b0df1f66c4
commit
76f95cd01c
2 changed files with 13 additions and 0 deletions
|
|
@ -201,6 +201,11 @@ def check():
|
|||
node.datetime_checked = now
|
||||
node.save()
|
||||
hc.save()
|
||||
if node.get_failed_checks().count() == node.get_all_checks().count() and node.get_all_checks().count() > 0:
|
||||
print('this node fails all of its health checks - deleting it!')
|
||||
for _hc in node.get_all_checks():
|
||||
_hc.delete_instance()
|
||||
node.delete_instance()
|
||||
|
||||
@app.cli.command("get_peers")
|
||||
def get_peers():
|
||||
|
|
|
|||
|
|
@ -23,6 +23,14 @@ class Node(Model):
|
|||
datetime_failed = DateTimeField(default=None, null=True)
|
||||
fail_reason = CharField(null=True)
|
||||
|
||||
def get_failed_checks(self):
|
||||
hcs = HealthCheck.select().where(HealthCheck.node == self, HealthCheck.health == False)
|
||||
return hcs
|
||||
|
||||
def get_all_checks(self):
|
||||
hcs = HealthCheck.select().where(HealthCheck.node == self)
|
||||
return hcs
|
||||
|
||||
class Meta:
|
||||
database = db
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue