Skip to content

Commit ad3abf2

Browse files
committed
add cpu info to telemetry
1 parent e834549 commit ad3abf2

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

mytoncore/functions.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
thr_sleep,
2121
Dict
2222
)
23+
from mytoninstaller.node_args import get_node_args
2324

2425

2526
def Init(local):
@@ -460,6 +461,26 @@ def get_db_stats():
460461
# end define
461462

462463

464+
def get_cpu_name():
465+
with open('/proc/cpuinfo') as f:
466+
for line in f:
467+
if line.strip():
468+
if line.rstrip('\n').startswith('model name'):
469+
return line.rstrip('\n').split(':')[1].strip()
470+
return None
471+
472+
473+
def is_host_virtual():
474+
try:
475+
with open('/sys/class/dmi/id/product_name') as f:
476+
product_name = f.read().strip().lower()
477+
if 'virtual' in product_name or 'kvm' in product_name or 'qemu' in product_name or 'vmware' in product_name:
478+
return {'virtual': True, 'product_name': product_name}
479+
return {'virtual': False, 'product_name': product_name}
480+
except FileNotFoundError:
481+
return {'virtual': None, 'product_name': None}
482+
483+
463484
def Telemetry(local, ton):
464485
sendTelemetry = local.db.get("sendTelemetry")
465486
if sendTelemetry is not True:
@@ -484,6 +505,8 @@ def Telemetry(local, ton):
484505
data["uname"] = GetUname()
485506
data["vprocess"] = GetValidatorProcessInfo()
486507
data["dbStats"] = get_db_stats()
508+
data["nodeArgs"] = get_node_args()
509+
data["cpuInfo"] = {'cpuName': get_cpu_name(), 'virtual': is_host_virtual()}
487510
elections = local.try_function(ton.GetElectionEntries)
488511
complaints = local.try_function(ton.GetComplaints)
489512

0 commit comments

Comments
 (0)