监视Solaris Sparc中的核心利用率

时间:2015-03-17 01:13:27

标签: python shell scripting

我正在尝试使用以下命令读取Sparc HW计数器:

cpustat -c Instr_cnt .1

此命令将永远运行(一段时间,直到被用户中断)。示例输出为:

   time cpu event      pic1   
  1.011   0  tick      6450 
  1.011   1  tick      9681 
  1.011   2  tick      2015 
  1.012   3  tick       535 
  1.012   4  tick       615 
  1.012   5  tick      7513 
  1.012   6  tick       615 
  1.013   7  tick      5187 
  1.013   8  tick       615 
  1.013   9  tick       615 
  1.013  10  tick       615 
  1.014  11  tick     60077 
  1.014  12  tick       438 
  1.014  13  tick       615 
  1.014  14  tick       615 
  1.015  15  tick       615 
  1.015  16  tick       615 
  1.015  17  tick       438 
  1.016  18  tick       615 
  1.016  19  tick       615 
^C

现在我试图将每4个cpu放在一个核心(每个核心有4个cpus),在pic1中添加数字并取平均值。一旦平均值达到某个阈值数,我想做一些负载平衡。

我认为逻辑是:将第2行中的所有元素放在一个数组中,然后再添加它们中的每一个。 寻找类似的输出:

**Core#      Average# of Inst   Utilization (#ofInst/cpu_cycle_perSec)**
   Core_0         xxxxxxxx            10%
   Core_1         xxxxxxxx            20%
    and so on....

我是编码的新手,如果有人能帮助我做一些简单的指导,那就太好了。这可以在shell / python中完成。

提前致谢。

0 个答案:

没有答案