fix psi support

This commit is contained in:
Alexey Avramov 2019-01-03 00:45:07 +09:00
parent 456ee150df
commit bff8e8ef75

18
nohang
View File

@ -9,7 +9,7 @@ from operator import itemgetter
# this is most slow import # this is most slow import
from argparse import ArgumentParser from argparse import ArgumentParser
from sys import stdout, stderr from sys import stdout
from signal import SIGKILL, SIGTERM from signal import SIGKILL, SIGTERM
sig_dict = {SIGKILL: 'SIGKILL', sig_dict = {SIGKILL: 'SIGKILL',
@ -751,7 +751,7 @@ def sleep_after_check_mem():
round(t_mem, 2), round(t_mem, 2),
round(t_swap, 2), round(t_swap, 2),
round(t_zram, 2))) round(t_zram, 2)))
stderr.flush() stdout.flush()
sleep(t) sleep(t)
except KeyboardInterrupt: except KeyboardInterrupt:
exit() exit()
@ -1712,30 +1712,28 @@ while True:
# Output avialable mem sizes # Output avialable mem sizes
if swap_total == 0 and mem_used_zram == 0: if swap_total == 0 and mem_used_zram == 0:
print('{}MemAvail: {} M, {} %'.format( print('{}MemAvail: {} M, {} %'.format(
avg_value,
human(mem_available, mem_len), human(mem_available, mem_len),
just_percent_mem(mem_available / mem_total), just_percent_mem(mem_available / mem_total)))
avg_value))
elif swap_total > 0 and mem_used_zram == 0: elif swap_total > 0 and mem_used_zram == 0:
print('{}MemAvail: {} M, {} % | SwapFree: {} M, {} %'.format( print('{}MemAvail: {} M, {} % | SwapFree: {} M, {} %'.format(
avg_value,
human(mem_available, mem_len), human(mem_available, mem_len),
just_percent_mem(mem_available / mem_total), just_percent_mem(mem_available / mem_total),
human(swap_free, swap_len), human(swap_free, swap_len),
just_percent_swap(swap_free / (swap_total + 0.1)), just_percent_swap(swap_free / (swap_total + 0.1))))
avg_value))
else: else:
print('{}MemAvail: {} M, {} % | SwapFree: {} M, {} % | Mem' print('{}MemAvail: {} M, {} % | SwapFree: {} M, {} % | Mem'
'UsedZram: {} M, {} %'.format( 'UsedZram: {} M, {} %'.format(
avg_value,
human(mem_available, mem_len), human(mem_available, mem_len),
just_percent_mem(mem_available / mem_total), just_percent_mem(mem_available / mem_total),
human(swap_free, swap_len), human(swap_free, swap_len),
just_percent_swap(swap_free / (swap_total + 0.1)), just_percent_swap(swap_free / (swap_total + 0.1)),
human(mem_used_zram, mem_len), human(mem_used_zram, mem_len),
just_percent_mem(mem_used_zram / mem_total), just_percent_mem(mem_used_zram / mem_total)))
avg_value))