查看网卡中断绑定情况的脚本

发布时间:2020-07-13 19:04:04 作者:kinda22
来源:网络 阅读:1380
#!/usr/bin/ruby
cpunum = ` cat /proc/cpuinfo |grep processor|wc -l`.to_i 

before = {}
while true
  file = File.readlines('/proc/interrupts')
  puts "ifname        cpu0       cpu1     cpu2    cpu3    cpu4    cpu5    cpu6    cpu7    cpu8    cpu9    cpu10    cpu11 "
  file.each do |i|
    if i.include?("TxRx") 
      lines = i.split(" ")


      print "#{lines[-1]}:  #{lines[1].to_i - before["#{lines[-1]}-1"].to_i} \t"
      print "#{lines[2].to_i - before["#{lines[-1]}-2"].to_i} \t"
      print "#{lines[3].to_i - before["#{lines[-1]}-3"].to_i} \t"
      print "#{lines[4].to_i - before["#{lines[-1]}-4"].to_i} \t"
      print "#{lines[5].to_i - before["#{lines[-1]}-5"].to_i} \t"
      print "#{lines[6].to_i - before["#{lines[-1]}-6"].to_i} \t"
      print "#{lines[7].to_i - before["#{lines[-1]}-7"].to_i} \t"
      if cpunum == 8
        puts "#{lines[8].to_i - before["#{lines[-1]}-8"].to_i} \t"
      elsif cpunum == 12
        print "#{lines[8].to_i - before["#{lines[-1]}-8"].to_i} \t"
        print "#{lines[9].to_i - before["#{lines[-1]}-9"].to_i} \t"
        print "#{lines[10].to_i - before["#{lines[-1]}-10"].to_i} \t"
        print "#{lines[11].to_i - before["#{lines[-1]}-11"].to_i} \t"
        puts "#{lines[12].to_i - before["#{lines[-1]}-12"].to_i}"
      end

      before["#{lines[-1]}-1"] = lines[1]
      before["#{lines[-1]}-2"] = lines[2]
      before["#{lines[-1]}-3"] = lines[3]
      before["#{lines[-1]}-4"] = lines[4]
      before["#{lines[-1]}-5"] = lines[5]
      before["#{lines[-1]}-6"] = lines[6]
      before["#{lines[-1]}-7"] = lines[7]
      before["#{lines[-1]}-8"] = lines[8]
      if cpunum == 12
        before["#{lines[-1]}-9"] = lines[9]
        before["#{lines[-1]}-10"] = lines[10]
        before["#{lines[-1]}-11"] = lines[11]
        before["#{lines[-1]}-12"] = lines[12]
      end
    end
  end
  puts 
  
  sleep 2
end


推荐阅读:
  1. SylixOS Zynq平台私有中断绑定
  2. Linux中查看网卡中断的命令是什么

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

ruby

上一篇:VSAN存储结构介绍及数据恢复方法概述

下一篇:Python-数据类型

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》