Skip to content

Instantly share code, notes, and snippets.

@taoky
Created March 20, 2024 13:14
Show Gist options
  • Save taoky/e09705904a3644167d59ae8b0786d051 to your computer and use it in GitHub Desktop.
Save taoky/e09705904a3644167d59ae8b0786d051 to your computer and use it in GitHub Desktop.
Show I/O PSI of cgroups
#!/bin/bash
CGROUP_PATH="/sys/fs/cgroup"
# Function to show IO PSI if avg10 is not 0 for a given cgroup
show_io_psi_if_needed() {
local cgroup_path=$1
local psi_file="${cgroup_path}/io.pressure"
if [ -f "${psi_file}" ]; then
# Check if avg10 is not 0
if grep -qv "avg10=0." "${psi_file}"; then
echo "PSI for IO in ${cgroup_path}:"
cat "${psi_file}"
fi
fi
}
# Function to recursively check and show IO PSI if avg10 is not 0
check_and_show_io_recursive() {
local base_path=$1
for cgroup in $(find "$base_path" -type d); do
show_io_psi_if_needed "${cgroup}"
done
}
# Main
if [ -d "${CGROUP_PATH}" ]; then
echo "Checking IO PSI for cgroups under ${CGROUP_PATH} where avg10 is not 0.00"
check_and_show_io_recursive "${CGROUP_PATH}"
else
echo "Cgroup v2 hierarchy not found at ${CGROUP_PATH}"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment