improve output

This commit is contained in:
Alexey Avramov 2020-06-27 01:33:54 +09:00
parent ac2572190c
commit 6c62443718

View File

@ -3,7 +3,7 @@
import os
from ctypes import CDLL
from time import sleep, monotonic, process_time
from time import sleep, monotonic
from operator import itemgetter
from sys import stdout, stderr, argv, exit
from re import search
@ -807,12 +807,12 @@ def signal_handler(signum, frame):
print_stat_dict()
m = monotonic() - m0
pt = process_time() - pt0
pt_percent = pt / m * 100
log('CPU time since monitoring has started: {} ({}%); exit.'.format(
format_time(pt), round(pt_percent, 3)))
m = monotonic() - start_time
user_time, system_time = os.times()[0:2]
p_time = user_time + system_time
p_percent = p_time / m * 100
log('Process time: {}s (average: {}%); exit.'.format(
round(p_time, 2), round(p_percent, 2)))
exit()
@ -2364,8 +2364,7 @@ def implement_corrective_action(
zram_info,
psi_info):
log('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>'
'>>>>>>>>>>>>>>')
log(separator_in)
debug_corrective_action = True
@ -2425,8 +2424,7 @@ def implement_corrective_action(
sleep(over_sleep)
log('<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<'
'<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<')
log(separator_out)
return psi_t0
@ -2436,8 +2434,7 @@ def implement_corrective_action(
log('Sleep {}s'.format(over_sleep))
sleep(over_sleep)
log('<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<'
'<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<')
log(separator_out)
return psi_t0
@ -2489,8 +2486,7 @@ def implement_corrective_action(
else:
log('Thresholds is not exceeded now')
log('<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<'
'<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<')
log(separator_out)
return psi_t0
for i in mem_info_list:
@ -2498,8 +2494,7 @@ def implement_corrective_action(
if new_threshold is None or new_threshold == 'WARN':
log('Thresholds is not exceeded now')
log('<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<'
'<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<')
log(separator_out)
return psi_t0
threshold = new_threshold
@ -2523,8 +2518,7 @@ def implement_corrective_action(
log('Sleep {}s'.format(over_sleep))
sleep(over_sleep)
log('<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<'
'<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<')
log(separator_out)
return psi_t0
@ -2537,8 +2531,7 @@ def implement_corrective_action(
else:
sleep(over_sleep)
log('<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<'
'<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<')
log(separator_out)
return psi_t0
@ -2766,8 +2759,7 @@ def implement_corrective_action(
log('Sleep {}s'.format(over_sleep))
sleep(over_sleep)
log('<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<'
'<<<<<<<<<<<<<<<<<')
log(separator_out)
return psi_t0
@ -3082,9 +3074,13 @@ except ValueError:
detailed_rss = False
# print('It is not Linux 4.5+')
config = os.path.abspath(config)
log('config: ' + config)
separator_in = '>>' + '=' * 75 + '>>'
separator_out = '<<' + '=' * 75 + '<<'
###############################################################################
@ -3849,10 +3845,6 @@ if ZFS:
ZFS = False
m0 = monotonic()
pt0 = process_time()
while True:
(masf_threshold, masf_info, mem_available, hard_threshold_min_swap_kb,