File tree Expand file tree Collapse file tree 1 file changed +1
-24
lines changed Expand file tree Collapse file tree 1 file changed +1
-24
lines changed Original file line number Diff line number Diff line change @@ -4,36 +4,13 @@ FILEPATH=${TEXTFILE_PATH:=/shared_vol/scrape.txt}
44INTERVAL=${COLLECT_INTERVAL:= 10}
55PROVISIONERS=${PROVISIONER_WHITELIST:= openebs.io/ local}
66
7- # # calculate_pv_capacity obtains the size of a PV in bytes
8- function calculate_pv_capacity(){
9- if [[ ${size_in_spec} =~ " i" ]]; then
10- unit=$( echo " ${size_in_spec: -2} " )
11- else
12- unit=$( echo " ${size_in_spec: -1} " )
13- fi
14-
15- case " ${unit} " in
16-
17- g|gi) echo $(( 1024 * 1024 * 1024 * $(echo $1 | tr - d ${unit} )) )
18- ;;
19- m|mi) echo $(( 1024 * 1024 * $(echo $1 | tr - d ${unit} )) )
20- ;;
21- k|ki) echo $(( 1024 * $(echo $1 | tr - d ${unit} )) )
22- ;;
23- b|bi) echo $1 | tr -d ${unit}
24- ;;
25- * ) echo 0
26- ;;
27- esac
28- }
29-
307# # collect_pv_capacity_metrics collects the PV capacity metrics
318function collect_pv_capacity_metrics(){
329 for i in ${pv_list[@]}
3310 do
3411 pvc_name=$( kubectl get pv ${i} -o custom-columns=:spec.claimRef.name --no-headers | tr ' [:upper:]' ' [:lower:]' )
3512 size_in_spec=$( kubectl get pv ${i} -o custom-columns=:spec.capacity.storage --no-headers | tr ' [:upper:]' ' [:lower:]' )
36- size_in_bytes=$( calculate_pv_capacity ${size_in_spec} ; )
13+ size_in_bytes=$( numfmt --from=auto --to=none ${size_in_spec} ; )
3714 echo " pv_capacity_bytes{persistentvolume=\" ${i} \" ,persistentvolumeclaim=\" ${pvc_name} \" } ${size_in_bytes} "
3815 done
3916}
You can’t perform that action at this time.
0 commit comments