top -b -n 1

Tod Merley todbot88 at gmail.com
Tue Dec 25 10:56:28 UTC 2007


On Dec 23, 2007 6:09 AM, Peter Lauri <peterlauri at gmail.com> wrote:
> -d is just giving the "Delay Time" so it is not giving me what I need. I
> need top to just output the current status to STDOUT and after that exit.
> The only way to do that is to go with the -b option, but that one seams to
> be "averaging" the values instead of giving the current status.
>
> So to move out of the "top box": how can I get a "snap shot" of the current
> CPU load?
>
> /Peter
>
>
>
>
> On Dec 23, 2007 1:18 AM, John Summerfield < debian at herakles.homelinux.org>
> wrote:
> >
> > -d
> > but be realistic, you don't want top dominating the system.
> >
> >
> > --
> >
> > Cheers
> > John
> >
> > -- spambait
> > 1aaaaaaa at coco.merseine.nu  Z1aaaaaaa at coco.merseine.nu
> > -- Advice
> > http://webfoot.com/advice/email.top.php
> > http://www.catb.org/~esr/faqs/smart-questions.html
> > http://support.microsoft.com/kb/555375
> >
> > You cannot reply off-list:-)
> >
> > --
> > fedora-list mailing list
> > fedora-list at redhat.com
> > To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
> >
>
>
> --
> fedora-list mailing list
> fedora-list at redhat.com
> To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
>

Hi Peter Lauri!

Thanks! You moved me to find a cool tool.  In the sysstat package is a
command called sar. Please note the following session:
----------------------------------------------------------------------------------
[tod at localhost ~]$ sar -u 1 5
Linux 2.6.23.8-34.fc7 (localhost.localdomain)   12/25/2007

02:46:47 AM     CPU     %user     %nice   %system   %iowait    %steal     %idle
02:46:48 AM     all      7.07      0.00      2.02      0.00      0.00     90.91
02:46:49 AM     all     85.00      0.00      4.00      0.00      0.00     11.00
02:46:50 AM     all      8.00      0.00      3.00      0.00      0.00     89.00
02:46:51 AM     all      7.00      0.00      1.00      0.00      0.00     92.00
02:46:52 AM     all      6.00      0.00      3.00      0.00      0.00     91.00
Average:        all     22.65      0.00      2.61      0.00      0.00     74.75
[tod at localhost ~]$ sar -u 1 5
Linux 2.6.23.8-34.fc7 (localhost.localdomain)   12/25/2007

02:47:11 AM     CPU     %user     %nice   %system   %iowait    %steal     %idle
02:47:12 AM     all      8.00      0.00      2.00      0.00      0.00     90.00
02:47:13 AM     all      7.00      0.00      3.00      0.00      0.00     90.00
02:47:14 AM     all      7.00      0.00      3.00      0.00      0.00     90.00
02:47:15 AM     all      7.07      0.00      2.02      0.00      0.00     90.91
02:47:16 AM     all      6.93      0.00      2.97      0.00      0.00     90.10
Average:        all      7.20      0.00      2.60      0.00      0.00     90.20
[tod at localhost ~]$ sar -u 1 5 > cpu.txt
[tod at localhost ~]$ cat cpu.txt
Linux 2.6.23.8-34.fc7 (localhost.localdomain)   12/25/2007

02:47:35 AM     CPU     %user     %nice   %system   %iowait    %steal     %idle
02:47:36 AM     all      7.00      0.00      2.00      0.00      0.00     91.00
02:47:37 AM     all      7.92      0.00      2.97      0.99      0.00     88.12
02:47:38 AM     all      5.10      0.00      1.02      0.00      0.00     93.88
02:47:39 AM     all      4.95      0.00      1.98      0.00      0.00     93.07
02:47:40 AM     all      6.06      0.00      2.02      0.00      0.00     91.92
Average:        all      6.21      0.00      2.00      0.20      0.00     91.58
[tod at localhost ~]$
--------------------------------------------------------------------------
Actually you can cause the program to create a binary file and then
use it again to display the binary data normally.  You have full
control of interval.  You also have a lot of cool troubleshooting
options such as finding how much a specific process is using the CPU.

I found the package for my Fedora 7 using Applications > Add/Remove
Software, clicking the Search tab, and then entering sysstat.

Enjoy!

Tod




More information about the users mailing list