Find core used from CPU utilization?

0

I have average and peak CPU utilization(in percentage) of a linux server with me . Mainly couple of web apps are deployed on the machine. I need to decide what AWS machine suits me based on that. AWS provides the machine costing based on CPU cores.

Now I need to find out the average and peak core utilization from CPU utilization , Can I deduce core utilization from CPU utilization based on some formula ? If not how can I find average and peak core utilization on linux server over a period of time ?

user3198603

Posted 2018-09-25T05:02:44.810

Reputation: 429

Are you talking about the system load averages? Like w and uptime provide? – Xen2050 – 2018-09-25T05:20:25.330

No, I am talking about the CPU utilization and cores utilized over a period of time on the server – user3198603 – 2018-09-25T06:04:56.710

If you do have that raw data just average the values to get the average and look for the highest value to get the peak? – Seth – 2018-09-25T06:37:28.687

Side note: AWS EC2 instance pricing is based on vCPU count, not core count. A vCPU is a hyperththread, not a physical core. The two are not identical, though probably close enough for your purposes. – Michael - sqlbot – 2018-09-25T11:26:32.037

Answers

1

Places where you can find core usage :

  • The perf command might have some useful counters
  • The top command when typing 1
  • The htop utility provides visual feedback
  • The command mpstat -P ALL 1 provides a display that renews every second. You may also direct the output to a text file and parse it using some utility.

harrymc

Posted 2018-09-25T05:02:44.810

Reputation: 306 093

0

You could monitor /proc/stat and watch for averages & max values. This answer has a bash script for your inspiration, and your man proc should be similar to this:

/proc/stat
  kernel/system statistics.  Varies with architecture.  Common entries
  include:

  cpu  3357 0 4313 1362393
        The amount of time, measured in units of USER_HZ (1/100ths of
        a second on most architectures, use  sysconf(_SC_CLK_TCK)  to
        obtain  the  right  value),  that the system spent in various
        states:

        user   (1) Time spent in user mode.

        nice   (2) Time spent in user mode with low priority (nice).

        system (3) Time spent in system mode.

        idle   (4) Time spent in the idle task.  This value should be
               USER_HZ  times  the  second  entry in the /proc/uptime
               pseudo-file.

        iowait (since Linux 2.5.41)
               (5) Time waiting for I/O to complete.

        irq (since Linux 2.6.0-test4)
               (6) Time servicing interrupts.

        softirq (since Linux 2.6.0-test4)
               (7) Time servicing softirqs.

        steal (since Linux 2.6.11)
               (8) Stolen time, which is  the  time  spent  in  other
               operating  systems when running in a virtualized envi‐
               ronment

        guest (since Linux 2.6.24)
               (9) Time spent running a virtual CPU for guest operat‐
               ing systems under the control of the Linux kernel.

        guest_nice (since Linux 2.6.33)
               (10) Time spent running a niced guest (virtual CPU for
               guest operating systems under the control of the Linux
               kernel).

[Source: man & Get per-core CPU load in shell script]

Xen2050

Posted 2018-09-25T05:02:44.810

Reputation: 12 097