#!/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 " $*) log= over_count=0 sudo -- iotop -qq -b "$@" | while read line do case "$line" in "Total DISK"*) if [ "$over" ] then log="$log 1" over= else log="$log 0" fi set -- $log while [ $# -gt 10 ] do shift done log=$* total=0 echo "log=$log" >&2 for n in $log do total=$((total+n)) done if [ "$total" -gt 5 ] then fireslay fi ;; "Current DISK"*) continue ;; *) set -- $line pct=${10%.*} if [ $pct -gt 90 ] then printf '[%d] %s%% %s\n' "$total" "${10}" "${12}" >&2 over=y fi ;; esac done