| 24 | | VERSION="0.2" |
|---|
| 25 | | |
|---|
| 26 | | class IRQ: |
|---|
| 27 | | def __init__(self): |
|---|
| 28 | | self.number = None |
|---|
| 29 | | self.scheduling_class = None |
|---|
| 30 | | self.scheduling_priority = None |
|---|
| 31 | | self.process_id = None |
|---|
| 32 | | self.drivers = [] |
|---|
| 33 | | self.cpu_counts = [] |
|---|
| 34 | | def __str__(self): |
|---|
| 35 | | s = " IRQ %4s: PID: %5s, count: %18s, Sched %4s (priority %4s), drivers: %s" % \ |
|---|
| 36 | | (self.number, self.process_id, self.cpu_counts, |
|---|
| 37 | | self.scheduling_class, self.scheduling_priority, |
|---|
| 38 | | self.drivers) |
|---|
| 39 | | return s |
|---|
| 40 | | |
|---|
| 41 | | class SoftIRQ: |
|---|
| 42 | | def __init__(self): |
|---|
| 43 | | self.name = None |
|---|
| 44 | | self.fullname = None |
|---|
| 45 | | self.scheduling_class = None |
|---|
| 46 | | self.scheduling_priority = None |
|---|
| 47 | | self.process_id = None |
|---|
| 48 | | self.cpu_counts = [] |
|---|
| 49 | | def __str__(self): |
|---|
| 50 | | s = " SoftIRQ %12s: PID %6s, Sched %4s (priority %4s), name: %s" % \ |
|---|
| 51 | | (self.name, self.process_id ,self.scheduling_class, self.scheduling_priority, self.fullname) |
|---|
| 52 | | return s |
|---|
| | 24 | LISTIRQINFO_VERSION="0.3" |
|---|
| 59 | | print "" |
|---|
| 60 | | print "Interrupt list utility " + VERSION |
|---|
| 61 | | print "==========================" |
|---|
| 62 | | print "(C) 2008 Pieter Palmers" |
|---|
| 63 | | print "" |
|---|
| | 31 | class IRQ: |
|---|
| | 32 | def __init__(self): |
|---|
| | 33 | self.number = None |
|---|
| | 34 | self.scheduling_class = None |
|---|
| | 35 | self.scheduling_priority = None |
|---|
| | 36 | self.process_id = None |
|---|
| | 37 | self.drivers = [] |
|---|
| | 38 | self.cpu_counts = [] |
|---|
| | 39 | def __str__(self): |
|---|
| | 40 | s = " IRQ %4s: PID: %5s, count: %18s, Sched %4s (priority %4s), drivers: %s" % \ |
|---|
| | 41 | (self.number, self.process_id, self.cpu_counts, |
|---|
| | 42 | self.scheduling_class, self.scheduling_priority, |
|---|
| | 43 | self.drivers) |
|---|
| | 44 | return s |
|---|
| 71 | | IRQs = {} |
|---|
| 72 | | for line in outtext.splitlines(): |
|---|
| 73 | | match_obj = compile_obj.search(line) |
|---|
| 74 | | if match_obj: |
|---|
| 75 | | irq = IRQ() |
|---|
| 76 | | irq.process_id = int(match_obj.group(1)) |
|---|
| 77 | | irq.number = int(match_obj.group(2)) |
|---|
| 78 | | irq.scheduling_class = match_obj.group(3) |
|---|
| 79 | | if match_obj.group(4) != '-': |
|---|
| 80 | | irq.scheduling_priority = int(match_obj.group(4)) |
|---|
| 81 | | else: |
|---|
| 82 | | irq.scheduling_priority = None |
|---|
| 83 | | IRQs[irq.number] = irq |
|---|
| | 64 | def load(self): |
|---|
| | 65 | # get PID info |
|---|
| | 66 | (exitstatus, outtext) = commands.getstatusoutput('ps -eLo pid,cmd,class,rtprio | grep IRQ') |
|---|
| | 67 | |
|---|
| | 68 | rawstr = r"""([0-9]+) +\[IRQ-([0-9]+)\] +([A-Z]{2}) +([-0-9]+)""" |
|---|
| | 69 | compile_obj = re.compile(rawstr) |
|---|
| | 70 | |
|---|
| | 71 | IRQs = {} |
|---|
| | 72 | for line in outtext.splitlines(): |
|---|
| | 73 | match_obj = compile_obj.search(line) |
|---|
| | 74 | if match_obj: |
|---|
| | 75 | irq = IRQ() |
|---|
| | 76 | irq.process_id = int(match_obj.group(1)) |
|---|
| | 77 | irq.number = int(match_obj.group(2)) |
|---|
| | 78 | irq.scheduling_class = match_obj.group(3) |
|---|
| | 79 | if match_obj.group(4) != '-': |
|---|
| | 80 | irq.scheduling_priority = int(match_obj.group(4)) |
|---|
| | 81 | else: |
|---|
| | 82 | irq.scheduling_priority = None |
|---|
| | 83 | IRQs[irq.number] = irq |
|---|
| | 84 | |
|---|
| | 85 | (exitstatus, outtext) = commands.getstatusoutput('ps -eLo pid,cmd,class,rtprio | grep softirq') |
|---|
| | 86 | |
|---|
| | 87 | rawstr = r"""([0-9]+) +\[softirq-(.*)\] +([A-Z]+) +([-0-9]+)""" |
|---|
| | 88 | compile_obj = re.compile(rawstr) |
|---|
| | 89 | |
|---|
| | 90 | softIRQs = {} |
|---|
| | 91 | for line in outtext.splitlines(): |
|---|
| | 92 | match_obj = compile_obj.search(line) |
|---|
| | 93 | if match_obj: |
|---|
| | 94 | irq = SoftIRQ() |
|---|
| | 95 | irq.process_id = int(match_obj.group(1)) |
|---|
| | 96 | irq.name = "%s-%s" % (match_obj.group(2),irq.process_id) |
|---|
| | 97 | irq.fullname = "softirq-%s" % match_obj.group(2) |
|---|
| | 98 | irq.scheduling_class = match_obj.group(3) |
|---|
| | 99 | if match_obj.group(4) != '-': |
|---|
| | 100 | irq.scheduling_priority = int(match_obj.group(4)) |
|---|
| | 101 | else: |
|---|
| | 102 | irq.scheduling_priority = None |
|---|
| | 103 | softIRQs[irq.name] = irq |
|---|
| | 104 | |
|---|
| | 105 | # get irq info |
|---|
| | 106 | (exitstatus, outtext) = commands.getstatusoutput('cat /proc/interrupts') |
|---|
| | 107 | lines = outtext.splitlines() |
|---|
| | 108 | nb_cpus = len(lines[0].split()) |
|---|
| | 109 | str0 = "([0-9]+): +"; |
|---|
| | 110 | str_cpu = "([0-9]+) +" |
|---|
| | 111 | str1="([\w\-]+) +([\w\-, :]+)" |
|---|
| | 112 | |
|---|
| | 113 | rawstr = str0; |
|---|
| | 114 | for i in range(nb_cpus): |
|---|
| | 115 | rawstr += str_cpu |
|---|
| | 116 | rawstr += str1 |
|---|
| | 117 | compile_obj = re.compile(rawstr) |
|---|
| | 118 | |
|---|
| | 119 | for line in outtext.splitlines(): |
|---|
| | 120 | match_obj = compile_obj.search(line) |
|---|
| | 121 | if match_obj: |
|---|
| | 122 | irq_number = int(match_obj.group(1)) |
|---|
| | 123 | if not irq_number in IRQs.keys(): |
|---|
| | 124 | IRQs[irq_number] = IRQ() |
|---|
| | 125 | IRQs[irq_number].number = irq_number |
|---|
| | 126 | |
|---|
| | 127 | irq = IRQs[irq_number] |
|---|
| | 128 | cpu_counts = [] |
|---|
| | 129 | for i in range(nb_cpus): |
|---|
| | 130 | cpu_counts.append(int(match_obj.group(1 + 1))) |
|---|
| | 131 | irq.cpu_counts = cpu_counts |
|---|
| | 132 | irq.type = match_obj.group(nb_cpus + 2) |
|---|
| | 133 | drivers = match_obj.group(nb_cpus + 3).split(',') |
|---|
| | 134 | for driver in drivers: |
|---|
| | 135 | irq.drivers.append(driver.strip()) |
|---|
| | 136 | |
|---|
| | 137 | IRQs[irq.number] = irq |
|---|
| 90 | | softIRQs = {} |
|---|
| 91 | | for line in outtext.splitlines(): |
|---|
| 92 | | match_obj = compile_obj.search(line) |
|---|
| 93 | | if match_obj: |
|---|
| 94 | | irq = SoftIRQ() |
|---|
| 95 | | irq.process_id = int(match_obj.group(1)) |
|---|
| 96 | | irq.name = "%s-%s" % (match_obj.group(2),irq.process_id) |
|---|
| 97 | | irq.fullname = "softirq-%s" % match_obj.group(2) |
|---|
| 98 | | irq.scheduling_class = match_obj.group(3) |
|---|
| 99 | | if match_obj.group(4) != '-': |
|---|
| 100 | | irq.scheduling_priority = int(match_obj.group(4)) |
|---|
| 101 | | else: |
|---|
| 102 | | irq.scheduling_priority = None |
|---|
| 103 | | softIRQs[irq.name] = irq |
|---|
| | 147 | for irq in sortedDictValues(self.IRQs): |
|---|
| | 148 | s += str(irq) + "\n" |
|---|
| 119 | | for line in outtext.splitlines(): |
|---|
| 120 | | match_obj = compile_obj.search(line) |
|---|
| 121 | | if match_obj: |
|---|
| 122 | | irq_number = int(match_obj.group(1)) |
|---|
| 123 | | if not irq_number in IRQs.keys(): |
|---|
| 124 | | IRQs[irq_number] = IRQ() |
|---|
| 125 | | IRQs[irq_number].number = irq_number |
|---|
| 126 | | |
|---|
| 127 | | irq = IRQs[irq_number] |
|---|
| 128 | | cpu_counts = [] |
|---|
| 129 | | for i in range(nb_cpus): |
|---|
| 130 | | cpu_counts.append(int(match_obj.group(1 + 1))) |
|---|
| 131 | | irq.cpu_counts = cpu_counts |
|---|
| 132 | | irq.type = match_obj.group(nb_cpus + 2) |
|---|
| 133 | | drivers = match_obj.group(nb_cpus + 3).split(',') |
|---|
| 134 | | for driver in drivers: |
|---|
| 135 | | irq.drivers.append(driver.strip()) |
|---|
| | 158 | if __name__== '__main__': |
|---|