88import requests
99import subprocess
1010
11- from mytoncore .mytoncore import MyTonCore , Dec2HexAddr
12- from mytoncore .tonblocksscanner import TonBlocksScanner
11+ from mytoncore .mytoncore import MyTonCore
12+ from mytoncore .utils import parse_db_stats
1313from mypylib .mypylib import (
1414 b2mb ,
1515 get_timestamp ,
@@ -419,6 +419,47 @@ def GetValidatorProcessInfo():
419419# end define
420420
421421
422+ def get_db_stats ():
423+ result = {
424+ 'rocksdb' : {
425+ 'ok' : True ,
426+ 'message' : '' ,
427+ 'data' : {}
428+ },
429+ 'celldb' : {
430+ 'ok' : True ,
431+ 'message' : '' ,
432+ 'data' : {}
433+ },
434+ }
435+ rocksdb_stats_path = '/var/ton-work/db/db_stats.txt'
436+ celldb_stats_path = '/var/ton-work/db/celldb/db_stats.txt'
437+ if os .path .exists (rocksdb_stats_path ):
438+ try :
439+ result ['rocksdb' ]['data' ] = parse_db_stats (rocksdb_stats_path )
440+ except Exception as e :
441+ result ['rocksdb' ]['ok' ] = False
442+ result ['rocksdb' ]['message' ] = f'failed to fetch db stats: { e } '
443+ else :
444+ result ['rocksdb' ]['ok' ] = False
445+ result ['rocksdb' ]['message' ] = 'db stats file is not exists'
446+ # end if
447+
448+ if os .path .exists (celldb_stats_path ):
449+ try :
450+ result ['celldb' ]['data' ] = parse_db_stats (celldb_stats_path )
451+ except Exception as e :
452+ result ['celldb' ]['ok' ] = False
453+ result ['celldb' ]['message' ] = f'failed to fetch db stats: { e } '
454+ else :
455+ result ['celldb' ]['ok' ] = False
456+ result ['celldb' ]['message' ] = 'db stats file is not exists'
457+ # end if
458+
459+ return result
460+ # end define
461+
462+
422463def Telemetry (local , ton ):
423464 sendTelemetry = local .db .get ("sendTelemetry" )
424465 if sendTelemetry is not True :
@@ -442,6 +483,7 @@ def Telemetry(local, ton):
442483 data ["swap" ] = GetSwapInfo ()
443484 data ["uname" ] = GetUname ()
444485 data ["vprocess" ] = GetValidatorProcessInfo ()
486+ data ["dbStats" ] = get_db_stats ()
445487 elections = local .try_function (ton .GetElectionEntries )
446488 complaints = local .try_function (ton .GetComplaints )
447489
0 commit comments