Skip to content

Commit 2a8b926

Browse files
committed
telemetry improves
1 parent ad3abf2 commit 2a8b926

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

mytoncore/functions.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,29 @@ def is_host_virtual():
481481
return {'virtual': None, 'product_name': None}
482482

483483

484+
def do_beacon_ping(host, count, timeout):
485+
args = ['ping', '-c', str(count), '-W', str(timeout), host]
486+
process = subprocess.run(args, stdin=subprocess.PIPE,
487+
stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=timeout)
488+
output = process.stdout.decode("utf-8")
489+
avg = output.split('\n')[-1].split('=')[1].split('/')[1]
490+
return float(avg)
491+
492+
493+
def get_pings_values():
494+
return {
495+
'beacon-eu-01.toncenter.com': do_beacon_ping('beacon-eu-01.toncenter.com', 1, 3),
496+
'beacon-apac-01.toncenter.com': do_beacon_ping('beacon-apac-01.toncenter.com', 1, 3)
497+
}
498+
499+
500+
def get_validator_disk_name():
501+
process = subprocess.run("df -h /var/ton-work/ | sed -n '2 p' | awk '{print $1}'", stdin=subprocess.PIPE,
502+
stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=3, shell=True)
503+
output = process.stdout.decode("utf-8")
504+
return output.strip()
505+
506+
484507
def Telemetry(local, ton):
485508
sendTelemetry = local.db.get("sendTelemetry")
486509
if sendTelemetry is not True:
@@ -507,6 +530,8 @@ def Telemetry(local, ton):
507530
data["dbStats"] = get_db_stats()
508531
data["nodeArgs"] = get_node_args()
509532
data["cpuInfo"] = {'cpuName': get_cpu_name(), 'virtual': is_host_virtual()}
533+
data["validatorDiskName"] = get_validator_disk_name()
534+
data["pings"] = get_pings_values()
510535
elections = local.try_function(ton.GetElectionEntries)
511536
complaints = local.try_function(ton.GetComplaints)
512537

0 commit comments

Comments
 (0)