Total CPU utilization returned by "top" command
I searched this form to get an answer for my question below. But could not find.
I am looking for a "top" command option which returns the total "CPU"% used on Linux server.
Details below - ( This is a Vmware server )
[sam@mytestserver mother]$ uname -a
Linux mytestserver 2.4.21-57.ELvmnix #1 Wed Oct 15 19:00:05 PDT 2008 i686 athlon i386 GNU/Linux
[mother@mytestserver sam]$ /usr/bin/top n 1 d 2 b -p 1 | sed 's/cpu0/CPU/'
09:37:29 up 122 days, 11:39, 3 users, load average: 0.48, 0.26, 0.20
1 processes: 1 sleeping, 0 running, 0 zombie, 0 stopped
CPU states: cpu user nice system irq softirq iowait idle
total 3.7% 0.0% 0.0% 0.0% 0.0% 0.0% 96.2%
Mem: 268568k av, 255628k used, 12940k free, 0k shrd, 2404k buff
186084k actv, 27668k in_d, 3152k in_c
Swap: 4192956k av, 350180k used, 3842776k free 52548k cached
PID USER PRI NI SIZE RSS SHARE STAT %CPU %MEM TIME CPU COMMAND
1 root 15 0 492 460 436 S 0.0 0.1 0:40 0 init
Is it possible to create a single line "top" command which returns the total CPU utiliztion% only?
This link seems to have some good information on alternate ways to read CPU utilization, though it may use packages your distribution doesn't use.
If you run `man top` there are flags which you can set to pass the data to other programs -- such as a perl or bash script to parse out the data you want. Alternatively, if you want the load average, there are built-in commands to return that as well.
|All times are GMT -5. The time now is 11:41 AM.|