Linux – Alternative to /proc/interrupts

interruptslinuxnetworking

I would like to obtain information about interrupts assigned to my network cards. Is there any other way, than /proc/interrupts?

Best Answer

There are two common interfaces to kernel information ( other than syscalls ) and they are implemented as filesystems. Those two filesystems are /proc and /sys. sys is a little more organized than proc and newer, but not as user friendly. So it is a little bit better for programmers and to avoid parsing.

If you want the information from the sys filesystem (which lspci parses (see somefile that is outputted by strace -o somefile lspci)):

$ lspci | grep -i network
00:19.0 Ethernet controller: Intel Corporation 82566DC Gigabit Network Connection (rev 02)
$ cat /sys/devices/pci0000:00/0000:00:19.0/irq
2299

Notice the 00:19 relationship between the two commands. The number returned by the irq file will be the same as first column of /proc/interrupts for the relevant device.

If you want more information on the sys filesystem look at the documentation included with the kernel source, for example the text files in /usr/src/linux-source-2.6.27/Documentation/filesystems

Update:

Is there a way to connect the output with interface name?

Sure, if you play around with sys, you will find there are lots of symbolic links that point to other locations in sys. For example, in /sys/class/net:

[kbrandt@kb: /sys/class/net] ls -l
lrwxrwxrwx 1 root root 0 2009-11-02 11:01 eth0 -> ../../devices/pci0000:00/0000:00:19.0/net/eth0
lrwxrwxrwx 1 root root 0 2009-11-02 11:01 lo -> ../../devices/virtual/net/lo
lrwxrwxrwx 1 root root 0 2009-11-02 11:01 pan0 -> ../../devices/virtual/net/pan0
lrwxrwxrwx 1 root root 0 2009-11-02 11:01 vmnet1 -> ../../devices/virtual/net/vmnet1
lrwxrwxrwx 1 root root 0 2009-11-02 11:01 vmnet8 -> ../../devices/virtual/net/vmnet8

So to get the irq for eth0, you can just:

cat /sys/class/net/eth0/../../irq