#!/usr/bin/perl -w # diffint -- look at /proc/interrupts twice and print the differences # -- useful for getting a quick summary of what devices are active use strict; my $SLEEP = 30; sub get_ints () { my $x = shift; my %ih; open PI, ") { if ($line =~ /^\s+([0-9]+):\s+([0-9]+)\s+XT-PIC\s+([0-9A-Za-z\-\/\ ]+)\s+$/) { $ih{$3} = $2; #printf "$3 $2\n"; } } close PI; return %ih; } my %ints_before; my %ints_after; %ints_before = get_ints (); system "sleep $SLEEP"; %ints_after = get_ints (); print "interrupts per second:\n"; foreach my $a (sort keys %ints_after) { my $n = 1.0 * $ints_after{$a} - $ints_before{$a}; $n /= $SLEEP; print " $a : $n\n"; }