vmstat's cpu stats on first line of output are always the same

Hello,

I'm seeing this problem with vmstat, where the first line of output always has the same CPU statistics. For example:

neked@nekedmachine:~$ date && vmstat
Fri Jul 24 06:57:08 EDT 2009
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
 0  0 130152 293444  23964 356264    0    0    13   125    0    2  7  7 82  4  0
neked@nekedmachine:~$ date && vmstat
Fri Jul 24 06:57:09 EDT 2009
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
 0  0 130152 293444  23964 356264    0    0    13   125    0    2  7  7 82  4  0
neked@nekedmachine:~$ date && vmstat
Fri Jul 24 06:57:11 EDT 2009
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
 2  0 130152 293352  23964 356264    0    0    13   125    0    2  7  7 82  4  0
neked@nekedmachine:~$ date && vmstat
Fri Jul 24 06:57:13 EDT 2009
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
 0  0 130152 293368  23968 356276    0    0    13   125    0    2  7  7 82  4  0

As you can see, CPU statistics are always context switch=0, user=7, system=7, idle=82, I/O wait = 4.

You could see this problem (on my machine which is CentOS 5, and on another machine which Debian Lenny) by typing:

watch -n 1 vmstat

However, the problem goes away if you let vmstat update itself at intervals, i.e.:

neked@nekedmachine:~$ vmstat -n 1
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
 0  0 130152 284248  25264 357732    0    0    13   125    0    2  7  7 82  4  0
 0  0 130152 284248  25264 357732    0    0     0     0 1010  304  1  8 91  0  0
 0  0 130152 284248  25264 357768    0    0     0     0 1030  233  0  1 99  0  0
 0  0 130152 284248  25264 357768    0    0     0     0 1022  235  0  1 99  0  0
 0  0 130152 284248  25264 357772    0    0     0    12 1024  237  0  2 98  0  0
 0  0 130152 284248  25276 357760    0    0     0   744 1024  217  1  2 97  0  0

But you can still see that the first line of vmstat's output above shows the same symptoms.

What explains this? How do I avoid it?

---------- Post updated at 07:32 AM ---------- Previous update was at 07:13 AM ----------

Uhhh... to answer my own inquiry, I should've RTFM. From vmstat's manpage:

       The first report produced gives averages since the last reboot.   Addi-
       tional  reports  give information on a sampling period of length delay.
       The process and memory reports are instantaneous in either case.

I'll leave this post up there as a cautionary tale for those who ask before doing proper research.