Skip to content

Commit 8b916ad

Browse files
committed
add node ip to alerting
1 parent e44a055 commit 8b916ad

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

modules/alert_bot.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ def __init__(self, ton, local, *args, **kwargs):
8383
self.validator_module = None
8484
self.inited = False
8585
self.hostname = None
86+
self.ip = None
8687
self.token = self.ton.local.db.get("BotToken")
8788
self.chat_id = self.ton.local.db.get("ChatId")
8889
self.last_db_check = None
@@ -113,6 +114,7 @@ def send_alert(self, alert_name: str, *args, **kwargs):
113114
❗️ <b>MyTonCtrl Alert {alert_name}</b> ❗️
114115
115116
Hostname: <code>{self.hostname}</code>
117+
Node IP: <code>{self.ip}</code>
116118
Time: <code>{time_}</code> (<code>{int(time.time())}</code>)
117119
Severity: <code>{alert.severity}</code>
118120
@@ -138,6 +140,7 @@ def init(self):
138140
from modules.validator import ValidatorModule
139141
self.validator_module = ValidatorModule(self.ton, self.local)
140142
self.hostname = get_hostname()
143+
self.ip = self.ton.get_validator_engine_ip()
141144
self.set_global_vars()
142145
self.inited = True
143146

mytoncore/mytoncore.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
get_timestamp,
3131
timestamp2datetime,
3232
dec2hex,
33-
Dict
33+
Dict, int2ip
3434
)
3535

3636

@@ -3791,6 +3791,13 @@ def GetNetworkName(self):
37913791
return "unknown"
37923792
#end define
37933793

3794+
def get_validator_engine_ip(self):
3795+
try:
3796+
config = self.GetValidatorConfig()
3797+
return int2ip(config['addrs'][0]['ip'])
3798+
except:
3799+
return None
3800+
37943801
def GetFunctionBuffer(self, name, timeout=10):
37953802
timestamp = get_timestamp()
37963803
buff = self.local.buffer.get(name)

0 commit comments

Comments
 (0)