воскресенье, 11 сентября 2011 г.

Storm Interrupt detector


#!/bin/bash
echo "Try to detect storm interrupt..."
get_inter() {
 cpu_cnt=`cat /proc/interrupts|head -1|wc -w`
 read awkcpu <<< $(for i in `seq 2 1 $((cpu_cnt+1))`; do echo -n "\$$i\"\\\t\""; done)
 x=`awk "{print $awkcpu }" <<< "$(grep "^ *[0-9]" <<< "$(cat /proc/interrupts)")"`
 echo $x|tr ' ' '\n'
}
read -a arx <<< $(get_inter)
sleep 2
read -a ary <<< $(get_inter)
itcnt=$(($(wc -l <<< "$(get_inter)")-1))
for ((i=0;i<=$itcnt;i++))
do
 [ '20000' -lt "$((${ary[$i]}-${arx[$i]}))"] || exit 1
done
exit 1

Комментариев нет:

Отправить комментарий