add psi-top
This commit is contained in:
parent
e5947f1ee2
commit
ff16461a56
@ -325,7 +325,9 @@ print_proc_table = False
|
|||||||
|
|
||||||
extra_table_info = cgroup_v1
|
extra_table_info = cgroup_v1
|
||||||
|
|
||||||
print_victim_info = True
|
print_victim_info = False
|
||||||
|
|
||||||
|
# print_victim_cmdline
|
||||||
|
|
||||||
max_ancestry_depth = 1
|
max_ancestry_depth = 1
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ from time import sleep
|
|||||||
x = []
|
x = []
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
x.append('#' * 9999999)
|
x.append('#' * 99999)
|
||||||
sleep(0.1)
|
sleep(0.1)
|
||||||
system('sleep 99 &')
|
system('sleep 9999 &')
|
||||||
|
|
||||||
|
78
trash/psi-top
Executable file
78
trash/psi-top
Executable file
@ -0,0 +1,78 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
from ctypes import CDLL
|
||||||
|
from time import sleep
|
||||||
|
|
||||||
|
"""
|
||||||
|
Execute the command
|
||||||
|
find /sys/fs/cgroup -name memory.pressure
|
||||||
|
to find available memory.pressue files (except /proc/pressure/memory).
|
||||||
|
(actual for cgroup2)
|
||||||
|
"""
|
||||||
|
|
||||||
|
psi_path = '/proc/pressure/memory'
|
||||||
|
|
||||||
|
|
||||||
|
def mlockall():
|
||||||
|
|
||||||
|
MCL_CURRENT = 1
|
||||||
|
MCL_FUTURE = 2
|
||||||
|
MCL_ONFAULT = 4
|
||||||
|
|
||||||
|
libc = CDLL('libc.so.6', use_errno=True)
|
||||||
|
|
||||||
|
result = libc.mlockall(
|
||||||
|
MCL_CURRENT | MCL_FUTURE | MCL_ONFAULT
|
||||||
|
)
|
||||||
|
if result != 0:
|
||||||
|
result = libc.mlockall(
|
||||||
|
MCL_CURRENT | MCL_FUTURE
|
||||||
|
)
|
||||||
|
if result != 0:
|
||||||
|
print('WARNING: cannot lock all memory')
|
||||||
|
else:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
mlockall()
|
||||||
|
|
||||||
|
|
||||||
|
def psi_path_to_metrics(psi_path):
|
||||||
|
|
||||||
|
with open(psi_path) as f:
|
||||||
|
psi_list = f.readlines()
|
||||||
|
# print(psi_list)
|
||||||
|
some_list, full_list = psi_list[0].split(' '), psi_list[1].split(' ')
|
||||||
|
#print(some_list, full_list)
|
||||||
|
some_avg10 = some_list[1].split('=')[1]
|
||||||
|
some_avg60 = some_list[2].split('=')[1]
|
||||||
|
some_avg300 = some_list[3].split('=')[1]
|
||||||
|
|
||||||
|
full_avg10 = full_list[1].split('=')[1]
|
||||||
|
full_avg60 = full_list[1].split('=')[1]
|
||||||
|
full_avg300 = full_list[1].split('=')[1]
|
||||||
|
|
||||||
|
return (some_avg10, some_avg60, some_avg300,
|
||||||
|
full_avg10, full_avg60, full_avg300)
|
||||||
|
|
||||||
|
|
||||||
|
print('Path to PSI file: {}\n'.format(psi_path))
|
||||||
|
|
||||||
|
|
||||||
|
print(' avg10 avg60 avg300 avg10 avg60 avg300')
|
||||||
|
|
||||||
|
while True:
|
||||||
|
(some_avg10, some_avg60, some_avg300,
|
||||||
|
full_avg10, full_avg60, full_avg300) = psi_path_to_metrics(psi_path)
|
||||||
|
|
||||||
|
print('some {} {} {} | full {} {} {}'.format(
|
||||||
|
some_avg10.rjust(6),
|
||||||
|
some_avg60.rjust(6),
|
||||||
|
some_avg300.rjust(6),
|
||||||
|
full_avg10.rjust(6),
|
||||||
|
full_avg60.rjust(6),
|
||||||
|
full_avg300.rjust(6)))
|
||||||
|
|
||||||
|
sleep(2)
|
Loading…
Reference in New Issue
Block a user