/usr/share/libffado2/python/listirqinfo.py is in ffado-tools 2.2.1-3.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | #!/usr/bin/python
#
#
# Copyright (C) 2008 Pieter Palmers
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 3 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
import os
import commands
import re
LISTIRQINFO_VERSION="0.3"
def sortedDictValues(adict):
items = adict.items()
items.sort()
return [value for key, value in items]
class IRQ:
def __init__(self):
self.number = None
self.scheduling_class = None
self.scheduling_priority = None
self.process_id = None
self.drivers = []
self.cpu_counts = []
def __str__(self):
s = " IRQ %4s: PID: %5s, count: %18s, Sched %4s (priority %4s), drivers: %s" % \
(self.number, self.process_id, self.cpu_counts,
self.scheduling_class, self.scheduling_priority,
self.drivers)
return s
class SoftIRQ:
def __init__(self):
self.name = None
self.fullname = None
self.scheduling_class = None
self.scheduling_priority = None
self.process_id = None
self.cpu_counts = []
def __str__(self):
s = " SoftIRQ %12s: PID %6s, Sched %4s (priority %4s), name: %s" % \
(self.name, self.process_id ,self.scheduling_class, self.scheduling_priority, self.fullname)
return s
class IRQInfo:
def __init__(self):
self.softIRQs = {}
self.IRQs = {}
def load(self):
# get PID info
(exitstatus, outtext) = commands.getstatusoutput('ps -eLo pid,cmd,class,rtprio | grep IRQ')
rawstr = r"""([0-9]+) +\[IRQ-([0-9]+)\] +([A-Z]{2}) +([-0-9]+)"""
compile_obj = re.compile(rawstr)
IRQs = {}
for line in outtext.splitlines():
match_obj = compile_obj.search(line)
if match_obj:
irq = IRQ()
irq.process_id = int(match_obj.group(1))
irq.number = int(match_obj.group(2))
irq.scheduling_class = match_obj.group(3)
if match_obj.group(4) != '-':
irq.scheduling_priority = int(match_obj.group(4))
else:
irq.scheduling_priority = None
IRQs[irq.number] = irq
(exitstatus, outtext) = commands.getstatusoutput('ps -eLo pid,cmd,class,rtprio | grep softirq')
rawstr = r"""([0-9]+) +\[softirq-(.*)\] +([A-Z]+) +([-0-9]+)"""
compile_obj = re.compile(rawstr)
softIRQs = {}
for line in outtext.splitlines():
match_obj = compile_obj.search(line)
if match_obj:
irq = SoftIRQ()
irq.process_id = int(match_obj.group(1))
irq.name = "%s-%s" % (match_obj.group(2),irq.process_id)
irq.fullname = "softirq-%s" % match_obj.group(2)
irq.scheduling_class = match_obj.group(3)
if match_obj.group(4) != '-':
irq.scheduling_priority = int(match_obj.group(4))
else:
irq.scheduling_priority = None
softIRQs[irq.name] = irq
# get irq info
(exitstatus, outtext) = commands.getstatusoutput('cat /proc/interrupts')
lines = outtext.splitlines()
nb_cpus = len(lines[0].split())
str0 = "([0-9]+): +";
str_cpu = "([0-9]+) +"
str1="([\w\-]+) +([\w\-, :]+)"
rawstr = str0;
for i in range(nb_cpus):
rawstr += str_cpu
rawstr += str1
compile_obj = re.compile(rawstr)
for line in outtext.splitlines():
match_obj = compile_obj.search(line)
if match_obj:
irq_number = int(match_obj.group(1))
if not irq_number in IRQs.keys():
IRQs[irq_number] = IRQ()
IRQs[irq_number].number = irq_number
irq = IRQs[irq_number]
cpu_counts = []
for i in range(nb_cpus):
cpu_counts.append(int(match_obj.group(i + 2)))
irq.cpu_counts = cpu_counts
irq.type = match_obj.group(nb_cpus + 2)
drivers = match_obj.group(nb_cpus + 3).split(',')
for driver in drivers:
irq.drivers.append(driver.strip())
IRQs[irq.number] = irq
self.softIRQs = softIRQs
self.IRQs = IRQs
def __str__(self):
s = ""
s += "Hardware Interrupts:\n"
s += "--------------------\n"
for irq in sortedDictValues(self.IRQs):
s += str(irq) + "\n"
s += "\n"
s += "Software Interrupts:\n"
s += "--------------------\n"
for irq in sortedDictValues(self.softIRQs):
s += str(irq) + "\n"
return s
if __name__== '__main__':
print ""
print "Interrupt list utility " + LISTIRQINFO_VERSION
print "=========================="
print "(C) 2008 Pieter Palmers"
print ""
info = IRQInfo()
info.load()
print str(info)
print ""
|