From: hyokeun.jeon Date: Mon, 2 Aug 2021 13:10:14 +0000 (+0900) Subject: Rollback mis-commited changes X-Git-Tag: accepted/tizen/devbase/tools/20210903.085151~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7e809092567a4b24103a427b512aa9bb05995f62;p=tools%2Fgbs.git Rollback mis-commited changes Change-Id: Ibb937161e5047f72e3a126e9e39a99f14968fca7 --- diff --git a/bsr/bsr/utility/monitoring.py b/bsr/bsr/utility/monitoring.py index 6649e87..312b728 100755 --- a/bsr/bsr/utility/monitoring.py +++ b/bsr/bsr/utility/monitoring.py @@ -36,10 +36,11 @@ class Monitoring: values = [] if os.path.isfile(target_file): - with open(target_file, 'r') as cpu_rec: - for item in cpu_rec.readlines()[1:]: - tstamp, usage = item.strip().split(',') - values.append([int(tstamp), float(usage)]) + with open(target_file, 'r') as hw_rec: + for item in hw_rec.readlines()[1:]: + tstamp, cpu_usage, mem_usage = item.strip().split(',') + values.append([int(tstamp), \ + round(float(cpu_usage), 2), round(float(mem_usage), 2)]) return values @@ -50,10 +51,17 @@ class Monitoring: stringed_command = """import time, psutil while True: - with open('__DEST__', 'a') as wf: - wf.write('{},{}\\n'.format(int(time.time()), psutil.cpu_percent(interval=5))) - if sum(1 for line in open('__DEST__')) > 7200: - break + with open('__DEST__', 'a') as wf: + wf.write('{},{},{}\\n'.format(int(time.time()), + round(psutil.cpu_percent(interval=5), 2), + round(float(psutil.virtual_memory().used)/1024/1024/1024, 2))) + if sum(1 for line in open('__DEST__')) > 17280: + break + try: + if len([x.name() for x in psutil.process_iter() if 'depanneur' in x.name()]) <= 0: + break + except Exception as err: + pass """.replace('__DEST__', target_file) pid = subprocess.Popen(['python', '-c', stringed_command]).pid