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
29 changes: 28 additions & 1 deletion mytonctrl/mytonctrl.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
GetSwapInfo,
GetBinGitHash,
)
from mytoncore.telemetry import is_host_virtual
from mytonctrl.migrate import run_migrations
from mytonctrl.utils import GetItemFromList, timestamp2utcdatetime, fix_git_config

Expand Down Expand Up @@ -237,7 +238,7 @@ def check_installer_user(local):
#end define


def PreUp(local, ton):
def PreUp(local: MyPyClass, ton: MyTonCore):
CheckMytonctrlUpdate(local)
check_installer_user(local)
check_vport(local, ton)
Expand Down Expand Up @@ -454,8 +455,34 @@ def check_disk_usage(local, ton):
print_warning(local, "disk_usage_warning")
#end define

def check_sync(local, ton):
validator_status = ton.GetValidatorStatus()
if not validator_status.is_working or validator_status.out_of_sync >= 20:
print_warning(local, "sync_warning")
#end define

def check_validator_balance(local, ton):
if ton.using_validator():
validator_wallet = ton.GetValidatorWallet()
validator_account = local.try_function(ton.GetAccount, args=[validator_wallet.addrB64])
if validator_account is None:
local.add_log(f"Failed to check validator wallet balance", "warning")
return
if validator_account.balance < 100:
print_warning(local, "validator_balance_warning")
#end define

def check_vps(local, ton):
if ton.using_validator():
data = local.try_function(is_host_virtual)
if data and data["virtual"]:
color_print(f"Virtualization detected: {data['product_name']}")

def warnings(local, ton):
check_disk_usage(local, ton)
check_sync(local, ton)
check_validator_balance(local, ton)
check_vps(local, ton)
#end define

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