Skip to content

Commit fe744ec

Browse files
authored
Merge pull request #267 from yungwine/warnings
Warnings
2 parents f9deb94 + 2f18f03 commit fe744ec

File tree

2 files changed

+48
-1
lines changed

2 files changed

+48
-1
lines changed

mytonctrl/mytonctrl.py

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
GetSwapInfo,
4040
GetBinGitHash,
4141
)
42+
from mytoncore.telemetry import is_host_virtual
4243
from mytonctrl.migrate import run_migrations
4344
from mytonctrl.utils import GetItemFromList, timestamp2utcdatetime, fix_git_config
4445

@@ -237,7 +238,7 @@ def check_installer_user(local):
237238
#end define
238239

239240

240-
def PreUp(local, ton):
241+
def PreUp(local: MyPyClass, ton: MyTonCore):
241242
CheckMytonctrlUpdate(local)
242243
check_installer_user(local)
243244
check_vport(local, ton)
@@ -454,8 +455,34 @@ def check_disk_usage(local, ton):
454455
print_warning(local, "disk_usage_warning")
455456
#end define
456457

458+
def check_sync(local, ton):
459+
validator_status = ton.GetValidatorStatus()
460+
if not validator_status.is_working or validator_status.out_of_sync >= 20:
461+
print_warning(local, "sync_warning")
462+
#end define
463+
464+
def check_validator_balance(local, ton):
465+
if ton.using_validator():
466+
validator_wallet = ton.GetValidatorWallet()
467+
validator_account = local.try_function(ton.GetAccount, args=[validator_wallet.addrB64])
468+
if validator_account is None:
469+
local.add_log(f"Failed to check validator wallet balance", "warning")
470+
return
471+
if validator_account.balance < 100:
472+
print_warning(local, "validator_balance_warning")
473+
#end define
474+
475+
def check_vps(local, ton):
476+
if ton.using_validator():
477+
data = local.try_function(is_host_virtual)
478+
if data and data["virtual"]:
479+
color_print(f"Virtualization detected: {data['product_name']}")
480+
457481
def warnings(local, ton):
458482
check_disk_usage(local, ton)
483+
check_sync(local, ton)
484+
check_validator_balance(local, ton)
485+
check_vps(local, ton)
459486
#end define
460487

461488
def CheckTonUpdate(local):

mytonctrl/resources/translate.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,26 @@
419419
"ru": "{green}Доступно обновление TON. {red}Пожалуйста, обновите его с помощью команды `upgrade`.{endc}",
420420
"zh_TW": "{green}TON 有可用更新. {red}請使用 `upgrade` 命令進行更新.{endc}"
421421
},
422+
"disk_usage_warning": {
423+
"en": "{red} Disk is almost full, clean the TON database immediately: https://docs.ton.org/participate/nodes/node-maintenance-and-security#database-grooming {endc}",
424+
"ru": "{red} Диск почти заполнен, немедленно очистите базу данных TON: https://docs.ton.org/participate/nodes/node-maintenance-and-security#database-grooming {endc}",
425+
"zh_TW": "{red} 磁盤幾乎滿了,立即清理 TON 數據庫: https://docs.ton.org/participate/nodes/node-maintenance-and-security#database-grooming {endc}"
426+
},
427+
"sync_warning": {
428+
"en": "{red} Node is out of sync. The displayed status is incomplete. {endc}",
429+
"ru": "{red} Нода не синхронизирована с сетью. Отображаемый статус не полный. {endc}",
430+
"zh_TW": "{red} 节点不与网络同步。顯示的狀態不完整。 {endc}"
431+
},
432+
"validator_balance_warning": {
433+
"en": "{red} Validator wallet balance is low. {endc}",
434+
"ru": "{red} Баланс кошелька валидатора низкий. {endc}",
435+
"zh_TW": "{red} 驗證者錢包餘額不足。 {endc}"
436+
},
437+
"vps_warning": {
438+
"en": "{red} Validator is running on a VPS. Use a dedicated server for better performance. {endc}",
439+
"ru": "{red} Валидатор работает на VPS. Используйте выделенный сервер (дедик) для лучшей производительности. {endc}",
440+
"zh_TW": "{red} 驗證者在 VPS 上運行。使用專用服務器以獲得更好的性能。 {endc}"
441+
},
422442
"vport_error": {
423443
"en": "{red}Error - UDP port of the validator is not accessible from the outside.{endc}",
424444
"ru": "{red}Ошибка - UDP порт валидатора недоступен извне.{endc}",

0 commit comments

Comments
 (0)