Adding date/time to line in vmstat

  • Follow


What am I missing here, would like to add date and/or time to line of output

vmstat 2 |awk '{now=strftime("%T/%m/%d/%y"); print now $0}'

%T/%m/%d/%y kthr      memory            page            disk          faults 
cpu
%T/%m/%d/%y r b w   swap  free  re  mf pi po fr de sr s0 s1 s2 s3   in   sy 
cs us sy id
%T/%m/%d/%y 0 0 0 12959104 6610240 28 49 15 2 1  0  0  0  0  0  0  390 1028 
622  3  1 96
%T/%m/%d/%y 0 0 0 13612432 7113680 310 29 2304 0 0 0 0 0  0  0  0  796  532 
561  0  2 98

Thanks in advance for your time.

John


0
Reply macka 10/24/2006 7:36:24 PM

macka wrote:
> What am I missing here, would like to add date and/or time to line of output
> vmstat 2 |awk '{now=strftime("%T/%m/%d/%y"); print now $0}'
> %T/%m/%d/%y kthr      memory            page            disk          faults
> cpu
> %T/%m/%d/%y r b w   swap  free  re  mf pi po fr de sr s0 s1 s2 s3   in   sy
> cs us sy id
> %T/%m/%d/%y 0 0 0 12959104 6610240 28 49 15 2 1  0  0  0  0  0  0  390 1028
> 622  3  1 96
> %T/%m/%d/%y 0 0 0 13612432 7113680 310 29 2304 0 0 0 0 0  0  0  0  796  532
> 561  0  2 98
> Thanks in advance for your time.

This isnt linux (that uses gawk but calls it awk). Write your own
strftime function
on an awk that supports functions or use gawk.

0
Reply gerryt 10/24/2006 8:03:09 PM


macka <macka@comcast.net> wrote:

> What am I missing here, would like to add date and/or time to line of output
> vmstat 2 |awk '{now=strftime("%T/%m/%d/%y"); print now $0}'

  You need 'gawk' instead of 'awk' here.
  You can do with regular shell, something like this:

vmstat 2 | while read line; do echo "`date +%T/%m/%d/%y`" "$line" ; done


-- 
Alex Zhilyakov
Network Manager, Accatel Inc.

0
Reply Alex 10/24/2006 8:55:50 PM

2 Replies
960 Views

(page loaded in 0.06 seconds)

Similiar Articles:













7/21/2012 4:35:37 AM


Reply: