-#!/bin/sh
-vmstat 1 | while read LINE ; do
- echo "`date +s`: $LINE"
- [ "$1" ] && echo "`date +s`: $LINE" >> $1
+#!/bin/bash
+DELAY=1
+null() {
+ :
+}
+
+case "$1" in
+-q) echo "echo off"
+ ECHO="null"
+ shift ;;
+[1-9]*)
+ DELAY=$1
+ ECHO=echo
+ shift ;;
+*)
+ echo "echo on"
+ ECHO=echo
+esac
+
+vmstat $DELAY | while read LINE ; do
+ LINE="`date +%s`: $LINE"
+ $ECHO "$LINE"
+ [ "$1" ] && echo "$LINE" >> $1
done