The workaround is to use awk to generate timestamp and print vmstat output plus data:
# vmstat 1 | awk '{now=strftime("%Y-%m-%d %T "); print now $0}'
2013-06-26 21:47:41 procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------
2013-06-26 21:47:41 r b swpd free buff cache si so bi bo in cs us sy id wa st
2013-06-26 21:47:41 1 0 0 385944 71768 517152 0 0 96 28 1018 118 3 5 89 3 0
2013-06-26 21:47:42 0 0 0 385944 71768 517152 0 0 0 0 1008 65 0 1 99 0 0
2013-06-26 21:47:43 0 0 0 385944 71768 517152 0 0 0 0 1023 73 0 0 100 0 0
However if you're using iostat on system where -t switch is not available you may use the same trick we did with vmstat.
You can use '-t' option with vmstat also. Here is the example
ReplyDelete[root@CTSINGTOHP16 VMIOstats]# vmstat -t
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------ ---timestamp---
r b swpd free buff cache si so bi bo in cs us sy id wa st
0 0 24264 31029508 1423452 25305228 0 0 0 2 0 0 0 0 100 0 0 2014-04-25 11:22:37 IST
'-t' option is available on Linux only. If you are working on Solaris you need to use the above trick.
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteI had some issues running that awk on old Solaris box, so I made a short script to do similar work:
ReplyDelete#!/bin/bash
while true; do
VMSTAT=`vmstat 1 2 | tail -1`
DATE=`date`
echo "$DATE $VMSTAT"
sleep 1
done
how to run this command in background?
ReplyDelete