Skip to content

Instantly share code, notes, and snippets.

@joemiller
Created July 21, 2016 19:16
Show Gist options
  • Save joemiller/d30e95aec5ceb53175d293c2de00e6b4 to your computer and use it in GitHub Desktop.
Save joemiller/d30e95aec5ceb53175d293c2de00e6b4 to your computer and use it in GitHub Desktop.
watch /proc/softirqs and print deltas of each metric at an interval
#!/usr/bin/ruby
# CPU0 CPU1 CPU2 CPU3 CPU4 CPU5 CPU6 CPU7 CPU8 CPU9 CPU10 CPU11 CPU12 CPU13 CPU14
# HI: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
# TIMER: 2344143 2305156 2295889 2278479 2274008 2260063 2237324 2245718 0 0 0 0 0 0 0
# NET_TX: 11309569 76523 76961 77020 77086 76261 78908 76016 0 0 0 0 0 0 0
# NET_RX: 11442620 47843 49607 48089 48989 45698 49201 41453 0 0 0 0 0 0 0
# BLOCK: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
#BLOCK_IOPOLL: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
# TASKLET: 129524 1042 1140 1240 1029 1074 1203 1114 0 0 0 0 0 0 0
# SCHED: 409281 357909 325891 313242 310618 305667 302294 298887 0 0 0 0 0 0 0
# HRTIMER: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
# RCU: 1311479 1266743 1259308 1248418 1245865 1240926 1223763 1233068 0 0 0 0 0 0 0
prev = Hash.new(0)
loop do
File.read('/proc/softirqs').each_line do |l|
l.chomp!
if l =~ /:/
d = l.split
name = d.delete_at(0)
total = d.inject(0){|sum,x| sum + x.to_i }
diff = total - prev[name]
printf "%-20s: %d\n", name, diff
prev[name] = total
end
end
printf "\n"
sleep 3
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment