#!/bin/bash

interval="${1:-5}"

echo "Interrupts per second:"
while true
do
  sum=0
  while read line
  do
    for word in $line
    do
      if [ "${word#[0-9]}" != "$word" -a "${word%[0-9]}" != "$word" ]; then
        sum="$((sum + word))"
      fi
    done
  done </proc/interrupts
  if [ "$prev" != "" ]; then
    echo $(((sum-prev)/interval))
  fi
  prev="$sum"
  sleep "$interval"
done
