|
39 | 39 | GetSwapInfo, |
40 | 40 | GetBinGitHash, |
41 | 41 | ) |
| 42 | +from mytoncore.telemetry import is_host_virtual |
42 | 43 | from mytonctrl.migrate import run_migrations |
43 | 44 | from mytonctrl.utils import GetItemFromList, timestamp2utcdatetime, fix_git_config |
44 | 45 |
|
@@ -237,7 +238,7 @@ def check_installer_user(local): |
237 | 238 | #end define |
238 | 239 |
|
239 | 240 |
|
240 | | -def PreUp(local, ton): |
| 241 | +def PreUp(local: MyPyClass, ton: MyTonCore): |
241 | 242 | CheckMytonctrlUpdate(local) |
242 | 243 | check_installer_user(local) |
243 | 244 | check_vport(local, ton) |
@@ -454,8 +455,34 @@ def check_disk_usage(local, ton): |
454 | 455 | print_warning(local, "disk_usage_warning") |
455 | 456 | #end define |
456 | 457 |
|
| 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 | + |
457 | 481 | def warnings(local, ton): |
458 | 482 | check_disk_usage(local, ton) |
| 483 | + check_sync(local, ton) |
| 484 | + check_validator_balance(local, ton) |
| 485 | + check_vps(local, ton) |
459 | 486 | #end define |
460 | 487 |
|
461 | 488 | def CheckTonUpdate(local): |
|
0 commit comments