vmstatに日付を付ける

perlでやっている人がいたので真似てみた。

$stdout.sync = true

while l = ARGF.gets
  puts Time.now.strftime('%F %R ') + l
end


~/work$ vmstat 3 | ruby append_time.rb
2008-04-30 10:41 procs -----------memory---------- ---swap-- -----io---- --system-- ----cpu----
2008-04-30 10:41 r b swpd free buff cache si so bi bo in cs us sy id wa
2008-04-30 10:41 1 0 0 179088 8596 41092 0 0 15 9 102 13 30 1 69 0
2008-04-30 10:41 0 0 0 178704 8596 41092 0 0 0 3 101 14 29 0 71 0