I am trying to read the Sparc HW counter using the following command:
cpustat -c Instr_cnt .1
This command will be running forever (for some time until interrupted by user). Sample output is:
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
\
I am trying to get every 4 cpu's in a core (each core has 4 cpus), add the number in pic1 and average them. Once the average reaches some threshold number, I want to do some load balancing. I think the logic is: put all the elements from line 2 in an array, and then add every 4 of them. Looking for an output like:
**Core# Average# of Inst Utilization (#ofInst/cpu_cycle_perSec)**
Core_0 xxxxxxxx 10%
Core_1 xxxxxxxx 20%
and so on....
I am novice in coding and if anyone could help me with some simple direction to do this, that would be great. This can be done in shell/python.
Thanks in advance.