-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdd-test.sh
executable file
·70 lines (50 loc) · 1.82 KB
/
dd-test.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/bash -l
# ====================================================================================
# Name: dd-test.sh
# Description: Script to run a simple dd benchmark and append results to a csv file
# Author: Nick Southorn
# Last mod: 05/04/19
# Updated help file
# ====================================================================================
# TODO
# * Pre-flight checks, system info
# * Add usage section
# * Add function to plot from csv file using gnuplot
# ====================================================================================
set -eu
echo $@
if [[ $# -le 1 ]]; then
echo -e "*** ERROR ***\n"
echo -e "\nUSAGE: Please provide the following arguements: "
echo -e "dd-test.sh <BLOCKSIZE> <BLOCKCOUNT> "
echo -e "For example:\n "
echo -e "dd-test.sh 1M 500 \n "
exit 2
fi
echo Running on $HOSTNAME
BLOCKSIZE=$1
BLOCKCOUNT=$2
TESTDIR=/data/dd-test
mkdir -p $TESTDIR
cd $TESTDIR
testfile=test.$(hostname).$$
echo "Testing in $PWD using filename $testfile"
logfile=dd.$$.log
echo $(date +"%Y-%m-%d,%H%M%S") Running dd
dd if=/dev/zero of=$testfile bs=$BLOCKSIZE count=$BLOCKCOUNT conv=fdatasync 2>&1 | tee $logfile
echo $(date +"%Y-%m-%d,%H%M%S") Finished dd
rm $testfile
if grep -q "GB/s" $logfile; then
rate=$(grep "GB/s" $logfile | sed 's# GB/s$##'| sed 's#^.* s, ##')
rate=$(echo "$rate*1000" | bc)
else
rate=$(grep "MB/s" $logfile | sed 's# MB/s$##'| sed 's#^.* s, ##')
fi
rm $logfile
# Append to csv file in the following format
# Date, Time, Blocksize, Blockcount, Rate, Hostname
echo $(date +"%Y-%m-%d,%H%M%S"),$rate,$HOSTNAME >> dd-rate.$HOSTNAME.csv
echo $(date +"%Y-%m-%d,%H%M%S") Done
# ====================================================================================
# END OF FILE
# ====================================================================================