format fixes

This commit is contained in:
David Lyle
2019-08-02 17:39:44 +01:00
committed by Graham Whaley
parent d8a8d77d1b
commit 45c9a7821a
2 changed files with 59 additions and 59 deletions
+12 -12
View File
@@ -132,11 +132,11 @@ for (currentdir in resultdirs) {
node_avail_gb=paste(nodename, "_avail_gb", sep="")
# Work out memory reduction by subtracting last (most consumed) from
srdata=cbind(mem_consumed=as.numeric(as.character(cdata[, node_avail_gb][1])) -
as.numeric(as.character(cdata[, node_avail_gb][length(cdata[, node_avail_gb])])))
as.numeric(as.character(cdata[, node_avail_gb][length(cdata[, node_avail_gb])])))
node_cpu_idle=paste(nodename, "_cpu_idle", sep="")
srdata=cbind(srdata, cpu_consumed=as.numeric(as.character(cdata[, node_cpu_idle][1])) -
as.numeric(as.character(cdata[, node_cpu_idle][length(cdata[, node_cpu_idle])])))
as.numeric(as.character(cdata[, node_cpu_idle][length(cdata[, node_cpu_idle])])))
sudata=rbind(sudata, srdata)
}
sdata=cbind(sdata, mem_consumed=sum(sudata[, "mem_consumed"]))
@@ -185,10 +185,10 @@ mem_stats_plot = suppressWarnings(ggtexttable(data.frame(rstats),
rows=NULL
))
# plot how samples varied over 'time'
mem_line_plot <- ggplot(data=fndata, aes(as.numeric(as.character(pod)),
as.numeric(as.character(mem_free)),
colour=interaction(testname, node), group=interaction(testname, node))) +
# plot how samples varied over 'time'
mem_line_plot <- ggplot(data=fndata, aes(as.numeric(as.character(pod)),
as.numeric(as.character(mem_free)),
colour=interaction(testname, node), group=interaction(testname, node))) +
geom_line(alpha=0.2) +
geom_smooth(se=FALSE, method="loess", size=0.3) +
xlab("Pods") +
@@ -209,10 +209,10 @@ cpu_stats_plot = suppressWarnings(ggtexttable(data.frame(cstats),
rows=NULL
))
# plot how samples varied over 'time'
cpu_line_plot <- ggplot(data=fndata, aes(as.numeric(as.character(pod)),
as.numeric(as.character(cpu_idle)),
colour=interaction(testname, node), group=interaction(testname, node))) +
# plot how samples varied over 'time'
cpu_line_plot <- ggplot(data=fndata, aes(as.numeric(as.character(pod)),
as.numeric(as.character(cpu_idle)),
colour=interaction(testname, node), group=interaction(testname, node))) +
geom_line(alpha=0.2) +
geom_smooth(se=FALSE, method="loess", size=0.3) +
xlab("Pods") +
@@ -246,7 +246,7 @@ cpu_text <- paste("System CPU consumption statistics")
cpu_text.p <- ggparagraph(text=cpu_text, face="italic", size="10", color="black")
# See https://www.r-bloggers.com/ggplot2-easy-way-to-mix-multiple-graphs-on-the-same-page/ for
# excellent examples
# excellent examples
master_plot = grid.arrange(
mem_line_plot,
cpu_line_plot,
@@ -256,5 +256,5 @@ master_plot = grid.arrange(
cpu_text.p,
boot_line_plot,
nrow=7,
heights=c(1, 1, 0.8, 0.1, 0.8, 0.1, 1) )
heights=c(1, 1, 0.8, 0.1, 0.8, 0.1, 1) )
+47 -47
View File
@@ -39,68 +39,68 @@ TEST_NAME="k8s scaling"
grab_stats() {
local launch_time_ms=$1
local n_pods=$2
local cpu_idle=()
local mem_free=()
local cpu_idle=()
local mem_free=()
info "And grab some stats"
local pods_json="$(cat << EOF
"n_pods": {
"Result": ${n_pods},
"Units" : "int"
}
local pods_json="$(cat << EOF
"n_pods": {
"Result": ${n_pods},
"Units" : "int"
}
EOF
)"
metrics_json_add_array_fragment "$pods_json"
)"
metrics_json_add_array_fragment "$pods_json"
local launch_json="$(cat << EOF
"launch_time": {
"Result": $launch_time_ms,
"Units" : "ms"
}
local launch_json="$(cat << EOF
"launch_time": {
"Result": $launch_time_ms,
"Units" : "ms"
}
EOF
)"
metrics_json_add_array_fragment "$launch_json"
)"
metrics_json_add_array_fragment "$launch_json"
metrics_json_start_nested_array
metrics_json_start_nested_array
# grab pods in the stats daemonset
# use 3 for the file descriptor rather than stdin otherwise the sh commands
# in the middle will read the rest of stdin
while read -u 3 name node; do
# Tell mpstat to measure over a short period, not only so we get slightly de-noised data, but also
# if you don't tell it the period, you will get the avg since boot, which is not what we want.
local cpu_idle=$(kubectl exec -ti $name -- sh -c "mpstat -u 3 1 | tail -1 | awk '{print \$11}'" | sed 's/\r//')
local mem_free=$(kubectl exec -ti $name -- sh -c "free | tail -2 | head -1 | awk '{print \$4}'" | sed 's/\r//')
# grab pods in the stats daemonset
# use 3 for the file descriptor rather than stdin otherwise the sh commands
# in the middle will read the rest of stdin
while read -u 3 name node; do
# Tell mpstat to measure over a short period, not only so we get slightly de-noised data, but also
# if you don't tell it the period, you will get the avg since boot, which is not what we want.
local cpu_idle=$(kubectl exec -ti $name -- sh -c "mpstat -u 3 1 | tail -1 | awk '{print \$11}'" | sed 's/\r//')
local mem_free=$(kubectl exec -ti $name -- sh -c "free | tail -2 | head -1 | awk '{print \$4}'" | sed 's/\r//')
info "idle [$cpu_idle] free [$mem_free] launch [$launch_time_ms] node [$node]"
info "idle [$cpu_idle] free [$mem_free] launch [$launch_time_ms] node [$node]"
# Annoyingly, it seems sometimes once in a while we don't get an answer!
# We should really retry, but for now, make the json valid at least
cpu_idle=${cpu_idle:-0}
mem_free=${mem_free:-0}
# Annoyingly, it seems sometimes once in a while we don't get an answer!
# We should really retry, but for now, make the json valid at least
cpu_idle=${cpu_idle:-0}
mem_free=${mem_free:-0}
local util_json="$(cat << EOF
{
"node": "${node}",
"cpu_idle": {
"Result": ${cpu_idle},
"Units" : "%"
},
"mem_free": {
"Result": ${mem_free},
"Units" : "kb"
}
}
local util_json="$(cat << EOF
{
"node": "${node}",
"cpu_idle": {
"Result": ${cpu_idle},
"Units" : "%"
},
"mem_free": {
"Result": ${mem_free},
"Units" : "kb"
}
}
EOF
)"
)"
metrics_json_add_nested_array_element "$util_json"
metrics_json_add_nested_array_element "$util_json"
done 3< <(kubectl get pods --selector name=stats-pods -o json | jq -r '.items[] | "\(.metadata.name) \(.spec.nodeName)"')
done 3< <(kubectl get pods --selector name=stats-pods -o json | jq -r '.items[] | "\(.metadata.name) \(.spec.nodeName)"')
metrics_json_end_nested_array "node_util"
metrics_json_end_nested_array "node_util"
metrics_json_close_array_element
metrics_json_close_array_element
}
init() {