Compare commits

..

No commits in common. "cf33dc92f338a1e4721ce9993a9433204828bda9" and "e18e94bb2323e391ba8235294a61129b9ad9cb7a" have entirely different histories.

4 changed files with 2 additions and 65 deletions

1
.gitignore vendored
View File

@ -2,7 +2,6 @@
!psi-alerts.sh
!psi-alerts@.service
!psi-monitor.service
!psi-monitor.sh
!psi-by-example
!.gitignore
!CONFIGURE.md

View File

@ -89,7 +89,7 @@ print_stats () {
pidstat -ul --human
;;
IO)
sudo iotop --batch --only --iter=10
sudo iotop --batch --only --iter=1
printf "\n\n"
pidstat -dl --human
;;

@ -1 +1 @@
Subproject commit e09aacd35fed5cf8c9cc7441eab4578e70bdb04b
Subproject commit 08c476910fc09144cf8df631b72f3c8e063112a9

View File

@ -1,62 +0,0 @@
#!/usr/bin/env zsh
#
# Pressure Stall Information monitor
#
# Copyright © 2023 Trey Blancher $(base64 -d <<< dHJleUBibGFuY2hlci5uZXQK)
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <https://www.gnu.org/licenses/>.
#
# Submodules may be distributed under a separate software license; see the
# LICENSE file within each submodule.
#
# This script monitors the three pressure stall information files
# /proc/pressure{cpu,io,memory} and reports if any resource is above threshold
# for the "some" values. It takes an optional single argument, the threshold at
# which to alert. If this is not supplied, it defaults to a threshold of 30.0
# percent.
#
local cpu="/proc/pressure/cpu"
local cpu_ctr=0
local io="/proc/pressure/io"
local io_ctr=0
local mem="/proc/pressure/memory"
local mem_ctr=0
local threshold=30.0
if [[ -n "${1}" ]]; then
threshold=${1}
fi
# main loop
while true; do
local cpu_pct=$(grep 'some' ${cpu} | awk '{print $2}' | awk -F'=' '{print $2}')
local io_pct=$(grep 'some' ${io} | awk '{print $2}' | awk -F'=' '{print $2}')
local mem_pct=$(grep 'some' ${mem} | awk '{print $2}' | awk -F'=' '{print $2}')
if (( cpu_pct > threshold )); then
cpu_ctr=$(( ${cpu_ctr} + 1 ))
printf "CPU PSI event %d triggered.\n" ${cpu_ctr}
fi
if (( io_pct > threshold )); then
io_ctr=$(( ${io_ctr} + 1 ))
printf "IO PSI event %d triggered.\n" ${io_ctr}
fi
if (( mem_pct > threshold )); then
mem_ctr=$(( ${mem_ctr} + 1 ))
printf "MEM PSI event %d triggered.\n" ${mem_ctr}
fi
sleep 10
done