#!/bin/sh if [ "$1" = -q ] then exec 2>/dev/null shift fi web_content_pids() { top -w512 -bn1 -o '%MEM' | sed -e '1,/^$/d' | { while read line do set -- $line [ "${12} ${13}" = "Web Content" ] || continue echo $1 done } } set -- $(web_content_pids | tac) set -- $(printf "\055\055pid=%s " $*) over_count=0 sudo -- iotop -qq -b "$@" | while read line do case "$line" in "Total DISK"*) if [ "$OVER" ] then over_count=$((over_count + 1)) if [ "$over_count" -gt 3 ] then fireslay fi over= else over_count=0 fi ;; "Current DISK"*) continue ;; *) set -- $line pct=${10%.*} if [ $pct -gt 90 ] then printf '[%d] %s%% %s\n' "$over_count" "${10}" "${12}" >&2 over=y fi ;; esac done