#!/bin/bash basedir="/opt/sas/tmp" lockfile="$basedir/cfsbench.lck" bs="1M" count="1000" usage () { echo "Usage: $0 {server|client}" exit 1 } case $1 in "clean") rm $basedir/cfsbench*.bin -vf ;; "server") echo "Dropping cache" sync ; echo 3 > /proc/sys/vm/drop_caches echo "Touching lockfile. Clients should start now." touch $lockfile watch 'df -h /opt/sas/tmp; ls -lh /opt/sas/tmp; echo "Press Ctrl+c to stop"' rm $lockfile -vf ;; "client-write") outfile="$basedir/cfsbench-$(hostname).bin" infile="/dev/zero" echo "Starting client" sync ; echo 3 > /proc/sys/vm/drop_caches while true; do sleep 0.1 ls $basedir > /dev/null echo -n . [[ -f $lockfile ]] && sleep 3 && echo "Starting thread..." && dd if=$infile of=$outfile bs=$bs count=$count && time sync && exit 0 done ;; "client-read") outfile="/dev/null" infile="$basedir/cfsbench-$(hostname).bin" echo "Starting client" sync ; echo 3 > /proc/sys/vm/drop_caches while true; do sleep 0.1 ls $basedir > /dev/null echo -n . [[ -f $lockfile ]] && sleep 3 && echo "Starting thread..." && dd if=$infile of=$outfile bs=$bs count=$count && time sync && exit 0 done ;; *) usage ;; esac