11#!/usr/bin/env python3
22# -*- coding: utf_8 -*-l
33import os
4- import re
54import sys
65import psutil
76import time
87import json
98import requests
109import subprocess
1110
12- from mytoncore .mytoncore import MyTonCore , Dec2HexAddr
13- from mytoncore .tonblocksscanner import TonBlocksScanner
11+ from mytoncore .mytoncore import MyTonCore
12+ from mytoncore .utils import parse_db_stats
1413from mypylib .mypylib import (
1514 b2mb ,
1615 get_timestamp ,
@@ -420,24 +419,6 @@ def GetValidatorProcessInfo():
420419# end define
421420
422421
423- def parse_db_stats (path : str ):
424- with open (path ) as f :
425- lines = f .readlines ()
426- result = {}
427- for line in lines :
428- s = line .strip ().split (maxsplit = 1 )
429- items = re .findall (r"(\S+)\s:\s(\S+)" , s [1 ])
430- if len (items ) == 1 :
431- item = items [0 ]
432- if float (item [1 ]) > 0 :
433- result [s [0 ]] = float (item [1 ])
434- else :
435- if any (float (v ) > 0 for k , v in items ):
436- result [s [0 ]] = {}
437- result [s [0 ]] = {k : float (v ) for k , v in items }
438- return result
439-
440-
441422def get_db_stats ():
442423 result = {
443424 'rocksdb' : {
@@ -462,6 +443,8 @@ def get_db_stats():
462443 else :
463444 result ['rocksdb' ]['ok' ] = False
464445 result ['rocksdb' ]['message' ] = 'db stats file is not exists'
446+ # end if
447+
465448 if os .path .exists (celldb_stats_path ):
466449 try :
467450 result ['celldb' ]['data' ] = parse_db_stats (celldb_stats_path )
@@ -471,7 +454,10 @@ def get_db_stats():
471454 else :
472455 result ['celldb' ]['ok' ] = False
473456 result ['celldb' ]['message' ] = 'db stats file is not exists'
457+ # end if
458+
474459 return result
460+ # end define
475461
476462
477463def Telemetry (local , ton ):
@@ -497,7 +483,7 @@ def Telemetry(local, ton):
497483 data ["swap" ] = GetSwapInfo ()
498484 data ["uname" ] = GetUname ()
499485 data ["vprocess" ] = GetValidatorProcessInfo ()
500- data ["db " ] = get_db_stats ()
486+ data ["dbStats " ] = get_db_stats ()
501487 elections = local .try_function (ton .GetElectionEntries )
502488 complaints = local .try_function (ton .GetComplaints )
503489
0 commit comments