CPU Usage command


Forum: Other Help Topics
Topic: CPU Usage command
started by: dialomar

Posted by dialomar on April 19 2006,00:20
Hi everyone,

I am looking for a command to get CPU usage in percentage. normally top command do that but not in DSL distribution.

There is CPU usage in Desktop but I don't know how to get this information. My aim is to get it from command line.

Thanks in advance.

Posted by dtf on April 19 2006,00:44
Not sure why you say top is not available.

top - 19:43:21 up  1:33,  1 user,  load average: 0.55, 0.19, 0.06
Tasks:  35 total,   2 running,  33 sleeping,   0 stopped,   0 zombie
Cpu(s):   0.3% user,   0.0% system,   0.0% nice,  99.7% idle
Mem:   1033392k total,   580992k used,   452400k free,    12424k buffers
Swap:   979956k total,        0k used,   979956k free,   493496k cached

 PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  Command          
 925 root      15   0 31748  14m 1540 S  0.3  1.4   0:31.57 Xvesa            
   1 root       8   0    72   72   48 S  0.0  0.0   0:04.61 init              
   2 root       9   0     0    0    0 S  0.0  0.0   0:00.02 keventd          
   3 root      18  19     0    0    0 S  0.0  0.0   0:00.00 ksoftirqd_CPU0    
   4 root       9   0     0    0    0 S  0.0  0.0   0:00.00 kswapd            
   5 root       9   0     0    0    0 S  0.0  0.0   0:00.00 bdflush          
   6 root       9   0     0    0    0 S  0.0  0.0   0:00.02 kupdated          
  12 root       9   0     0    0    0 S  0.0  0.0   0:00.00 khubd            
  17 root       9   0     0    0    0 S  0.0  0.0   0:00.00 knodemgrd_0      
 338 root       9   0   756  752  644 S  0.0  0.1   0:00.00 pump              
 376 root       9   0     0    0    0 S  0.0  0.0   0:00.10 kjournald        
 862 root       9   0  1784 1780 1120 S  0.0  0.2   0:00.07 bash              
 866 root       9   0  1420 1420  980 S  0.0  0.1   0:00.08 cupsd            
 881 dsl        9   0  1776 1772 1112 S  0.0  0.2   0:00.11 bash              
 907 dsl        9   0  1092 1084  940 S  0.0  0.1   0:00.03 startx            
 924 dsl        9   0   648  644  572 S  0.0  0.1   0:00.01 xinit            
 928 dsl        9   0  2060 2056 1496 S  0.0  0.2   0:00.36 fluxbox

Posted by dialomar on April 19 2006,11:40
Thanks for you reply,

top exist but it doesn't show me the load for the CPU (Total).
Here what top show me :

Mem: 44432K used, 82304K free, 0K shrd, 2084K buff, 23328K cached
Load average: 0.13, 0.14, 0.06    (State: S=sleeping R=running, W=waiting)

PID USER     STATUS   RSS  PPID %CPU %MEM COMMAND
 556 dsl      R        792   549  3.8  0.6 top
 502 root     S       8380   501  1.9  6.6 Xvesa
 535 dsl      S        884     1  0.9  0.6 torsmo
 514 dsl      S       2708     1  0.0  2.1 xtdesk
 506 dsl      S       2548   501  0.0  2.0 fluxbox
 457 root     S       1728     1  0.0  1.3 bash
 473 dsl      S       1716   457  0.0  1.3 bash
 518 dsl      S       1500   506  0.0  1.1 fluxter
 549 dsl      S       1500   547  0.0  1.1 bash
 547 dsl      S       1404     1  0.0  1.1 aterm
 519 dsl      S       1288   506  0.0  1.0 docked.lua
 488 dsl      S       1084   473  0.0  0.8 startx
 536 dsl      S       1024     1  0.0  0.8 dpid
 537 dsl      S        880   536  0.0  0.6 file.dpi
 539 dsl      S        880   537  0.0  0.6 file.dpi
 135 root     S        752     1  0.0  0.5 pump
 522 dsl      S        688   519  0.0  0.5 wmswallow
 501 dsl      S        644   488  0.0  0.5 xinit
   1 root     S         76     0  0.0  0.0 init

Posted by anaconda on April 19 2006,13:00
CPU total load% is shown in the upper right corner of your desktop.

I dont know how accurate it is, because sometimes it shows CPU usage 141%... eg. more than 100% which is weird..

Posted by dialomar on April 19 2006,13:35
Thanks,

But, there is any way to get cpu load from command line. I want to integrate it to script shell.

Posted by mikshaw on April 19 2006,14:55
The differences in top is probably a result of dtf using gnu-utils instead of the default Busybox.

One way to get cpu usage is with the command "cat /proc/loadavg" or "cat /proc/stat", although I'm not certain how to read them....

Powered by Ikonboard 3.1.2a
Ikonboard © 2001 Jarvis Entertainment Group, Inc.