Skip to content

Instantly share code, notes, and snippets.

@chapmanjacobd
Last active July 13, 2024 06:23
Show Gist options
  • Save chapmanjacobd/d64dc2b57beabbd2e198bd571c37bea8 to your computer and use it in GitHub Desktop.
Save chapmanjacobd/d64dc2b57beabbd2e198bd571c37bea8 to your computer and use it in GitHub Desktop.
plot /proc/pressure/memory
# https://github.com/rfjakob/earlyoom/blob/c759f1bef2b50d0e0b249bff650e730655c98c0e/contrib/oomstat/overload.txt
import matplotlib.pyplot as plt
import pandas as pd
from xklb.utils import processes
df = pd.read_csv(StringIO(processes.cmd('cb').stdout.replace('|',' ')), delim_whitespace=True)
df.set_index('Time', inplace=True)
df = df.apply(pd.to_numeric)
ax = df.plot(subplots=True, figsize=(10, 6), marker='o')
for i, ax in enumerate(ax):
ax.set_title(df.columns[i])
ax.set_xlabel('Time (s)')
ax.set_ylabel(df.columns[i])
plt.tight_layout()
plt.show()