Skip to content

Commit 74d8a54

Browse files
committed
/proc/softirqs sometimes report more cpus than actually is.
1 parent a609108 commit 74d8a54

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

irqtop

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ def read_table(tag, file)
6060
@cpus = []
6161
lines = IO.readlines(file)
6262
@cpus = lines[0].scan(/CPU\d+/)
63+
@icpus = @cpus if tag == 'i'
6364
lines[2..-1].each do |li|
6465
irq, stat, desc = li.match(/^\s*(\S+):((?:\s+\d+)+)(.*)$/).captures
6566
stat = stat.scan(/\d+/)
@@ -149,17 +150,17 @@ def show_interrupts
149150
maxlen = 7
150151
@irqs.reverse! if @reverse
151152
print "%s %*s " % [" ", maxlen, " "]
152-
@cpus.each { |c| print " %6s" % c }
153+
@icpus.each { |c| print " %6s" % c }
153154
puts
154155

155156
# load
156157
print "%*s: " % [maxlen + 2, "cpuUtil"]
157-
@cpus.each { |c| print " %6.1f" % @c[c] }
158+
@icpus.each { |c| print " %6.1f" % @c[c] }
158159
puts " total CPU utilization %"
159160

160161
# total
161162
print "%*s: " % [maxlen + 2, "irqTotal"]
162-
@cpus.each { |c| print " %6d" % @t[c] }
163+
@icpus.each { |c| print " %6d" % @t[c] }
163164
puts " total hardware IRQs"
164165

165166
rej = nil
@@ -168,7 +169,7 @@ def show_interrupts
168169
@irqs.each do |t, i, desc|
169170
next if t == rej
170171
print "%s %*s: " % [t.to_s, maxlen, i.slice(0, maxlen)]
171-
@cpus.each do |c|
172+
@icpus.each do |c|
172173
cpu = c[/\d+/].to_i
173174
aff = @aff[i.to_i]
174175
off = ((aff & 1 << cpu) ==0)? true : false if aff
@@ -200,6 +201,7 @@ def choplines(text)
200201
lines = text.split("\n").map {|e| e.slice(0, cols)}.slice(0, rows)
201202
text = lines.join("\n")
202203
text << "\n" * (rows - lines.size) if lines.size < rows
204+
text
203205
end
204206

205207
def show_help

0 commit comments

Comments
 (0)