Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions modules/alert_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ def __init__(self, ton, local, *args, **kwargs):
self.validator_module = None
self.inited = False
self.hostname = None
self.ip = None
self.token = None
self.chat_id = None
self.last_db_check = 0
Expand Down Expand Up @@ -113,6 +114,7 @@ def send_alert(self, alert_name: str, *args, **kwargs):
❗️ <b>MyTonCtrl Alert {alert_name}</b> ❗️

Hostname: <code>{self.hostname}</code>
Node IP: <code>{self.ip}</code>
Time: <code>{time_}</code> (<code>{int(time.time())}</code>)
Severity: <code>{alert.severity}</code>

Expand Down Expand Up @@ -140,6 +142,7 @@ def init(self):
from modules.validator import ValidatorModule
self.validator_module = ValidatorModule(self.ton, self.local)
self.hostname = get_hostname()
self.ip = self.ton.get_validator_engine_ip()
self.set_global_vars()
self.inited = True

Expand Down Expand Up @@ -206,6 +209,9 @@ def check_db_usage(self):
def check_validator_wallet_balance(self):
if not self.ton.using_validator():
return
validator_status = self.ton.GetValidatorStatus()
if not validator_status.is_working or validator_status.out_of_sync >= 20:
return
validator_wallet = self.ton.GetValidatorWallet()
validator_account = self.ton.GetAccount(validator_wallet.addrB64)
if validator_account.balance < 10:
Expand Down
9 changes: 8 additions & 1 deletion mytoncore/mytoncore.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
get_timestamp,
timestamp2datetime,
dec2hex,
Dict
Dict, int2ip
)


Expand Down Expand Up @@ -3793,6 +3793,13 @@ def GetNetworkName(self):
return "unknown"
#end define

def get_validator_engine_ip(self):
try:
config = self.GetValidatorConfig()
return int2ip(config['addrs'][0]['ip'])
except:
return None

def GetFunctionBuffer(self, name, timeout=10):
timestamp = get_timestamp()
buff = self.local.buffer.get(name)
Expand Down