mirror of
https://github.com/clearlinux/cloud-native-setup.git
synced 2026-08-19 13:36:43 +00:00
metrics: make pods_per_gb valid JSON
Under some circumstances, the pod_per_gb value would come out as <0, and be generated without any leading 0's (such as `.14` rather than `0.14`). This is not valid JSON, and would break the report generation parsing in R. Use `printf` to force a leading 0 prefix onto the value. Signed-off-by: Graham Whaley <graham.whaley@intel.com>
This commit is contained in:
committed by
David Lyle
parent
f146c771cc
commit
b6c7cf1b8e
@@ -169,7 +169,7 @@ EOF
|
||||
if [ $n_pods -eq 0 ]; then
|
||||
local pods_per_gb=0
|
||||
else
|
||||
local pods_per_gb=$(bc -l <<< "scale=2; ($total_mem_used/1024) / $n_pods")
|
||||
local pods_per_gb=$(printf "%0f" $(bc -l <<< "scale=2; ($total_mem_used/1024) / $n_pods"))
|
||||
fi
|
||||
local mem_json="$(cat << EOF
|
||||
"memory": {
|
||||
|
||||
@@ -195,7 +195,7 @@ EOF
|
||||
if [ $n_pods -eq 0 ]; then
|
||||
local pods_per_gb=0
|
||||
else
|
||||
local pods_per_gb=$(bc -l <<< "scale=2; ($total_mem_used/1024) / $n_pods")
|
||||
local pods_per_gb=$(printf "%0f" $(bc -l <<< "scale=2; ($total_mem_used/1024) / $n_pods"))
|
||||
fi
|
||||
local mem_json="$(cat << EOF
|
||||
"memory": {
|
||||
|
||||
Reference in New Issue
Block a user