summaryrefslogtreecommitdiff
path: root/src/Linux:Checking_CPU_Core_Usage.ascii
blob: edb06e89746e0933755b3f1227786a41a5528dfd (plain)
    1 Linux:Checking CPU Core Usage
    2 =============================
    3 :author: Aaron Ball
    4 :email: nullspoon@iohq.net
    5 
    6 
    7 == {doctitle}
    8 
    9 This is mostly for my own future reference. Today I needed to to check the
   10 resource consumption of an application on a currently bare metal system so I
   11 could get a good idea how to spec out its new virtual home.  Now, in Linux,
   12 checking cpu consumption is easy, but I wanted to check the _per core_ usage.
   13 The reason in this case was no one knew if this application was multithreaded
   14 (likely not if the application's stability is indicative of its code quality)
   15 and how well if it was. Giving a machine multiple threads to run a single
   16 threaded application is a bit pointless. That said, I found two ways to check
   17 per core usage that didn't involve installing additional packages on the system
   18 (http://hisham.hm/htop/[htop], I'm looking at you).
   19 
   20 [[mpstat]]
   21 mpstat
   22 ~~~~~~
   23 
   24 Mpstat is a really cool program I happened upon today in my searches. It
   25 basically reports on every live stat you could ever want on a CPU.
   26 
   27 ----
   28 mpstat -P ALL 2 10
   29 ----
   30 That will report _all_ stats on all cpus every _2_ seconds, _10_ times.
   31 
   32 
   33 [[top]]
   34 top
   35 ~~~
   36 
   37 I'd prefer not using something that's interractive so I can more easily use the
   38 data with other programs (like tr, cut, grep, etc), which is why I included
   39 this one second. With top, if you press the *1* key while it's running, it will
   40 print per-core cpu stats.
   41 
   42 ----
   43 Tasks: 188 total, 1 running, 187 sleeping, 0 stopped, 0 zombie
   44 Cpu0 : 0.3%us, 0.0%sy, 0.0%ni, 99.7%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
   45 Cpu1 : 0.0%us, 0.0%sy, 0.0%ni, 97.0%id, 3.0%wa, 0.0%hi, 0.0%si, 0.0%st
   46 Cpu2 : 0.0%us, 0.0%sy, 0.0%ni,100.0%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
   47 Cpu3 : 0.0%us, 0.0%sy, 0.0%ni,100.0%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
   48 Mem: 4086584k total, 3951260k used, 135324k free, 24532k buffers Swap:
   49 8388600k total, 4203824k used, 4184776k free, 103416k cached
   50 ----
   51 
   52 Category:Linux
   53 
   54 
   55 // vim: set syntax=asciidoc:

Generated by cgit