#!/usr/bin/ksh # # Usage: USEAGE="vmlog [-i interval] [-c count] [-l logfile]" # # Logfile - If not specified, this defaults to /var/adm/vmstat/vmlog # with the day of the month appended. This means that the # data will be kept for 31 days, and will be overwritten each # month much like SAR data is. # Interval - If not specified, this defaults to 300 seconds # Count - If not specified, this defaults to 1 day worth of # observations # # Version 1.0 # if [ $# -eq 1 ]; then echo $USAGE exit 1 fi while [ $# -ge 2 ]; do case $1 in -c) COUNT=$2 shift 2 ;; -i) INTERVAL=$2 shift 2 ;; -l) LOG=$2 shift 2 ;; *) echo $USAGE exit 1 ;; esac done if [ -z "$INTERVAL" ]; then INTERVAL=300 fi if [ -z "$COUNT" ]; then # Number of seconds in a day = 60x60*24=86400 COUNT=`expr 86400 / $INTERVAL` fi if [ -z "$LOG" ]; then LOG=`date +"/var/adm/vmstat/vmlog.%d"` else LOG=`date +"$LOG.%d"` fi # # Create the log dir if needed. DIR=`dirname $LOG` if [ ! -d $DIR ]; then mkdir $DIR fi vmstat -t $INTERVAL $COUNT > $LOG