-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathksm
More file actions
executable file
·29 lines (25 loc) · 691 Bytes
/
ksm
File metadata and controls
executable file
·29 lines (25 loc) · 691 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/env python3
# fmt: off
#%# family=auto
#%# capabilities=autoconf
# fmt: on
import os
import sys
KSM_DIR = "/sys/kernel/mm/ksm/"
KEYS = ("shared", "sharing", "unshared", "volatile")
if "autoconf" in sys.argv:
if os.path.exists(KSM_DIR):
print("yes")
else:
print(f"no ({KSM_DIR} not found)")
elif "config" in sys.argv:
print("graph_title Kernel shared memory")
print("graph_category system")
print("graph_info kernel shared memory")
for key in KEYS:
print(f"{key}.label {key}")
else:
os.chdir(KSM_DIR)
for key in KEYS:
with open(f"pages_{key}") as handle:
print(f"{key}.value {handle.read().strip()}")