From owner-freebsd-ports Fri Sep 3 5:12:55 1999 Delivered-To: freebsd-ports@freebsd.org Received: from boca.livius.net (boca.RO.EU.net [193.226.128.210]) by hub.freebsd.org (Postfix) with ESMTP id 2F5AE1501E for ; Fri, 3 Sep 1999 05:12:45 -0700 (PDT) (envelope-from ulianov@ns.csm.ro) Received: from gamma (gamma.netappi.com [193.226.162.223]) by boca.livius.net (8.9.2/8.9.1) with SMTP id PAA01740 for ; Fri, 3 Sep 1999 15:09:54 +0300 (EEST) (envelope-from ulianov@ns.csm.ro) Message-Id: <199909031209.PAA01740@boca.livius.net> From: "Vladimir COTFAS" To: freebsd-ports@FreeBSD.org Date: Fri, 3 Sep 1999 15:14:54 +0300 MIME-Version: 1.0 Content-type: Multipart/Mixed; boundary=Message-Boundary-5062 Subject: showints Reply-To: ulianov@ns.csm.ro X-mailer: Pegasus Mail for Win32 (v3.11) Sender: owner-freebsd-ports@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org --Message-Boundary-5062 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Content-description: Mail message body Hi, While being idle at my job I wrote a small Perl5 script that displays infos related to interrupts/devices. It gathers informations offered by dmesg, scanpci and vmstat in a form that is close to that of /proc/interrupts in Linux. I attached this script to the letter. It is BSD-copyrighted. Vlad --Message-Boundary-5062 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Content-description: Text from file 'showints' #!/usr/bin/perl $name = 'showints'; sub pciStuff{ my ($dev, $line, @devNames, @irqNumbers); $dev = 0; open(PCI, "scanpci -v |") or die "$name: can't fork: $!\n"; while(defined($line = )){ chomp($line); next if(length($line) < 1 || $line =~ /^Probing/ || $line =~ /^PCI says/ || $line =~ /^PCI probing/); $dev++ if($line =~ /^pci bus/); if($line =~ /^\ [A-Z]/){ $devNames[$dev] = $line; } if($line =~ /INT_LINE/){ my($irq); #print $line, "\n"; $_ = $line; /INT_LINE/; $_ = $'; $irq = (split(' ', $_))[0]; $irq =~ s/^0x//g; $irq =~ s/^0//g; if($irq eq 'a') { $irq = 10;} elsif($irq eq 'b') { $irq = 11;} elsif($irq eq 'c') { $irq = 12;} elsif($irq eq 'd') { $irq = 13;} elsif($irq eq 'e') { $irq = 14;} elsif($irq eq 'f') { $irq = 15;} $irqNumbers[$dev] = $irq; } } close(PCI); for($dev = 0; $dev <= $#devNames; $dev++){ $PCI_IRQS{$irqNumbers[$dev]} .= ':' . $devNames[$dev]; } } sub dmesgPCI_Stuff{ my ($ifc, $line); open(MSG, "dmesg |") or die "$name: can't fork: $!\n"; while(defined($line = )){ chomp($line); next unless($line =~ /pci/ && $line =~ /irq/); $_ = $line; /:/; $ifc = $`; $_ = $'; /irq\ /; $_ = (split(' ', $'))[0]; $IFC_by_IRQ{$_} .= ':' . $ifc; } close(MSG); } $n = 0; open(INT, "vmstat -i |") or die "$name: can't fork: $!\n"; while(defined($line = )){ next if($line =~ /^interrupt/ || $line =~ /^Total/); @foo = split(' ', $line); $irq = $foo[1]; $irq =~ s/^irq//g; $IRQS{$irq} = join(':', $foo[0], $foo[2], $foo[3]); } close(INT); pciStuff; dmesgPCI_Stuff; printf("%-10s \t%s\t%10s\t%s\t%s\n", 'Device', 'IRQ', 'Total', 'Rate', 'Description'); foreach $irq (sort {$a <=> $b} keys(%IRQS)){ @foo = split(':', $IRQS{$irq}); $ifc = $foo[0]; if($ifc eq 'pci' && defined($IFC_by_IRQ{$irq})){ my(@ifs); @ifs = split(':', $IFC_by_IRQ{$irq}); if($#ifs > 1){ $ifc = join('/', @ifs); $ifc =~ s/^\///g; }else{ $ifc = $ifs[1]; } } printf("%-10s \t%s\t%10s\t%4s", $ifc, $irq, $foo[1], $foo[2]); if($foo[0] eq 'pci' && defined($PCI_IRQS{$irq})){ my(@desc, $i); @desc = split(':', $PCI_IRQS{$irq}); print "\t", $desc[1]; if($#desc > 1) { # Oops! PCI shared IRQ's for($i = 2; $i <= $#desc; $i++){ print "/\n\t\t\t\t\t\t", $desc[$i]; } } } print "\n"; } --Message-Boundary-5062-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-ports" in the body of the message