Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

vmstat and column

I want to use column utility to format output of iostat in aligned columns.

I want to run something like:

vmstat 1 10 | column -t

But the output appers only after 10 sec (vmstat completes its work) and not each second.

Any ideas?

like image 596
dimba Avatar asked Jul 15 '10 20:07

dimba


2 Answers

try this:

vmstat -w 1 5

this works fine in vm, but when in physic machine which has large memory the columu of cpu maybe not looks as better as in vm.

like image 76
NOZUONOHIGH Avatar answered Oct 02 '22 05:10

NOZUONOHIGH


The reason this happens is that column waits to gather as much input as possible on which to base its column guesses. It has no way of knowing that the data pattern repeats every second.

You can approximate what you want to do by running this:

for i in 0 1 2 3 4 5 6 7 8 9; do iostat | column -t; sleep 1; done

EDIT

Thanks to a couple of suggestions from Dennis:

for i in {0..9} ; do iostat 1 1 | column -t; sleep 1; done

The only difference from the original is that the first header line is repeated every second. Some footwork with sed or grep could take care of that.

like image 21
Carl Smotricz Avatar answered Oct 02 '22 07:10

Carl Smotricz