-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfio-detect
executable file
·80 lines (68 loc) · 1.44 KB
/
fio-detect
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
69
70
71
72
73
74
75
76
77
78
79
80
#!/bin/sh
#
#-
# Copyright (c) 2018 StorPool.
# All rights reserved.
#
# This file is meant to be either sourced by a shell script or executed
# with the SP_FIO_DETECT_PRINT environment variable set to a true value
# (1, y, Yes, T, true, etc).
#
# If sourcing it from a shell script, the SP_FIO_DETECT_PRINT variable
# MUST be either unset or set to a non-true value! In that case,
# the SP_FIO_MAJOR, SP_FIO_EXT, and SP_FIO_PARAMS variables will be
# defined and exported in the environment.
fio_detect()
{
local ver
if [ -z "$SP_FIO_MAJOR" ]; then
ver="$(fio --version | cut -d- -f2 | cut -d. -f1)"
case "$ver" in
2|3)
export SP_FIO_MAJOR="$ver"
;;
*)
echo "Could not determine the fio tool's version\n" 1>&2
exit 1
;;
esac
fi
if [ -z "$SP_FIO_EXT" ]; then
case "$SP_FIO_MAJOR" in
2)
export SP_FIO_EXT='log'
;;
3)
export SP_FIO_EXT='json'
;;
*)
echo "Invalid SP_FIO_MAJOR value '$SP_FIO_MAJOR'" 1>&2
exit 1
;;
esac
fi
if [ -z "$SP_FIO_PARAMS" ]; then
case "$SP_FIO_MAJOR" in
2)
export SP_FIO_PARAMS=''
;;
3)
export SP_FIO_PARAMS='--output-format=json+'
;;
*)
echo "Invalid SP_FIO_MAJOR value '$SP_FIO_MAJOR'" 1>&2
exit 1
;;
esac
fi
}
fio_detect
case "$SP_FIO_DETECT_PRINT" in
[1-9]*|T*|t*|Y*|y*)
echo "SP_FIO_MAJOR=$SP_FIO_MAJOR"
echo "SP_FIO_EXT=$SP_FIO_EXT"
echo "SP_FIO_PARAMS=$SP_FIO_PARAMS"
;;
*)
;;
esac