Debian Codegraph @

bin/ct-wr-iops

raw symbols SCIP
1 #!/bin/bashscip-shell filesystem . . `/bin/bash`.
2 source /usr/share/ceph-tools/_ct-commonscip-shell source . . `/usr/share/ceph-tools/_ct-common`.
3
4 # Default Values
5 INTERVAL=10 # 10 secondes
6 NB=180 # environ 30 minutes (10*180 secondes)
7 TOT=$(( INTERVAL * NB / 60 ))
8 MINI=20000
9 WIDTH=75
10 help_msgscip-shell shell ceph-tools 0.0.40 help_msg(). () {
11 printfscip-shell system . . printf. """
12 usage: $0 [-h] [-i|--interval INTERVAL] [-n|--number NUMBER] [-w|--width WIDTH]
13
14 Description Display semi-graphical progression of wr IOPS
15 -h, --help show this help message and exit
16 -i INTERVAL, --interval INTERVAL
17 Interval in seconds between each measurement (default: ${INTERVAL} seconds)
18 -n NUMBER, --number NUMBER
19 Number of measures before display (default : ${NB} measures -> ~${TOT} minutes)
20 -m MINI, --mini MINI
21 Minimum IOPS in bytes/second (default : ${MINI} IOPS)
22 -w WIDTH, --width
23 Widt of graph : (${WIDTH})
24
25 Example
26 $0 -i 10 -n 180 -m 20000
27 """
28 }
29
30
31 while [scip-shell system . . `[`. $# -gt 0 ] ; do
32 key="$1"
33 case $key in
34 -h|--help)
35 help_msgscip-shell shell ceph-tools 0.0.40 help_msg().
36 ct_on_exit 0
37 ;;
38 -i|--interval)
39 INTERVAL="$2"
40 shift 2
41 ;;
42 -n|--number)
43 NB="$2"
44 shift 2
45 ;;
46 -m|--mini)
47 MINI="$2"
48 shift 2
49 ;;
50 -w|--width)
51 WIDTH="$2"
52 shift 2
53 ;;
54 *)
55 echoscip-shell system . . echo. "Arg not found : '$key'"
56 ct_on_exit 1
57 esac
58 done
59
60 WIDTH=$((WIDTH-1))
61 FACT=$(($MINI/10))
62
63 get_wr_iopsscip-shell shell ceph-tools 0.0.40 get_wr_iops().() {
64 # Recupere les IOPS en ecriture
65 IOPS=$(ceph -s -f json 2>/dev/nullscip-shell filesystem . . `/dev/null`. | jqscip-shell system . . jq. ".pgmap.write_op_per_sec")
66 if [scip-shell system . . `[`. -z "$IOPS" ]
67 then
68 IOPS=0
69 fi
70 echoscip-shell system . . echo. $IOPS
71 }
72
73 printscip-shell shell ceph-tools 0.0.40 print().() {
74 # Formatage de la sortie : 11000/13000/14000 op/s wr (Min/Avg/Max): -----------==|=
75 GREEN="\e[32m"
76 RED="\e[31m"
77 YELLOW="\e[33m"
78 BOLD="\e[1m"
79 UNDER="\e[4m"
80 NORM="\e[0m"
81 IOMIN=$1
82 IOAVG=$2
83 IOMAX=$3
84 COLOR=$GREEN
85 if [scip-shell system . . `[`. $IOMIN -lt $MINI ]
86 then
87 COLOR=$YELLOW
88 fi
89 if [scip-shell system . . `[`. $IOAVG -lt $MINI ]
90 then
91 COLOR=$RED
92 fi
93 printfscip-shell system . . printf. "\r$(datescip-shell system . . date. +'%x %X') Min %'d, ${UNDER}Avg %'d${NORM}, ${BOLD}Max %'d${NORM} op/s wr: \t" $IOMIN $IOAVG $IOMAX
94 IOMIN=$((IOMIN/FACT))
95 printfscip-shell system . . printf. "${COLOR}"
96 for i in $(seqscip-shell system . . seq. 1 $IOMIN)
97 do
98 echoscip-shell system . . echo. -n "-"
99 done
100 IOAVG=$((IOAVG/FACT))
101 IOMAX=$((IOMAX/FACT))
102 (( IOMIN += 1 ))
103 for i in $(seqscip-shell system . . seq. $IOMIN $IOAVG)
104 do
105 echoscip-shell system . . echo. -n "="
106 done
107 (( IOMAX -= 1 ))
108 IOM=0
109 MAXI=0
110 if [scip-shell system . . `[`. $IOMAX -gt $WIDTH ]
111 then
112 IOM=$WIDTH
113 MAXI=1
114 else
115 IOM=$IOMAX
116 fi
117 echoscip-shell system . . echo. -n "|"
118 for i in $(seqscip-shell system . . seq. $IOAVG $IOM)
119 do
120 echoscip-shell system . . echo. -n "="
121 done
122 if [scip-shell system . . `[`. $MAXI -eq 1 ]
123 then
124 echoscip-shell system . . echo. -n "~"
125 fi
126 printfscip-shell system . . printf. "${NORM}"
127 }
128
129 # Boucle infinie
130 while [scip-shell system . . `[`. 1 ]
131 do
132 # Initialisation Variables
133 MIN=1000000000
134 MAX=0
135 TOTAL=0
136 NBT=0
137 for j in $(seqscip-shell system . . seq. 1 $NB)
138 do
139 I=$(get_wr_iopsscip-shell shell ceph-tools 0.0.40 get_wr_iops().)
140 if [scip-shell system . . `[`. $I -gt 0 ] && [scip-shell system . . `[`. $I -lt 10000000 ]
141 then
142 ((TOTAL += I))
143 ((NBT += 1))
144 AVG=$((TOTAL/NBT))
145 if [scip-shell system . . `[`. $I -lt $MIN ]
146 then
147 MIN=$I
148 fi
149 if [scip-shell system . . `[`. $I -gt $MAX ]
150 then
151 MAX=$I
152 fi
153 printscip-shell shell ceph-tools 0.0.40 print(). $MIN $AVG $MAX
154 fi
155 sleepscip-shell system . . sleep. $INTERVAL
156 done
157 echoscip-shell system . . echo.
158 done
159
160 ct_on_exit 0