LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-10-2009, 12:19 AM   #1
peroxide
LQ Newbie
 
Registered: Sep 2009
Posts: 5

Rep: Reputation: 0
CPU usage accuracy puzzlement


Hi fellas,

I'm trying to write a script to capture the CPU usage for a particular server. I have tried iostat, vmstat and top, but in batch mode they always give a consistent value. For example, if I just run 'iostat -c' once, it will return the same value, no matter how many times I run it. However, if I use 'iostat -c 1 5' for example, the first value returned will be that same value, but the remaining values will fluctuate wildly.
The same behaviour is also observed with vmstat and top -b.

Can anyone tell me whether this is normal behaviour?
 
Old 09-10-2009, 12:45 AM   #2
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Yes, it's absolutely normal behavior.

And, in fact, a good (and often stated) rule of thumb is to *always* use "-5" (or "-3", or whatever you prefer), then always *disregard* the first value:

http://perfhints.blogspot.com/2009/02/vmstat.html

Last edited by paulsm4; 09-10-2009 at 12:48 AM.
 
Old 09-10-2009, 08:06 AM   #3
salasi
Senior Member
 
Registered: Jul 2007
Location: Directly above centre of the earth, UK
Distribution: SuSE, plus some hopping
Posts: 4,052

Rep: Reputation: 881Reputation: 881Reputation: 881Reputation: 881Reputation: 881Reputation: 881Reputation: 881
I don't know about the others, but for vmstat this behaviour is described on the man page.
Quote:
The first report produced gives averages since the last reboot.
 
Old 09-10-2009, 11:21 PM   #4
peroxide
LQ Newbie
 
Registered: Sep 2009
Posts: 5

Original Poster
Rep: Reputation: 0
Thanks for the link, helped me loads.

 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
processes/CPU Usage/Mem Usage desktop wallpaper ceantuco Linux - Newbie 2 04-13-2009 02:14 PM
Why %CPU total not equal to cpu(s) usage? pii.ajah Linux - Server 2 12-02-2008 09:30 PM
getting realtime info on memory usage-cpu and harddrive usage steering Linux - Newbie 5 03-03-2005 09:43 PM
how to determine cpu usage, memory usage, I/O usage by a particular user logged on li rags2k Programming 4 08-21-2004 05:45 AM
Controlling CPU usage & memory usage Saravana babu Linux - Software 0 02-18-2004 06:55 AM


All times are GMT -5. The time now is 08:08 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration