Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # docker stats | awk '(NR+3)%4 {print $2, $3, $4, strftime("%Y-%m-%d %H:%M:%S")}' >> ~/research/tests/test.txt
- services <- read.table(file = "~/research/tests/test.txt", header = FALSE)
- separatedData <- split(services, services$V1, drop=TRUE)
- cpuRange <- range(0, lapply(separatedData, function(elem)
- max(ceiling(as.numeric(gsub("\\%", "", elem$V2))))
- ))
- memoryRange <- range(0, lapply(separatedData, function(elem)
- max(ceiling(as.numeric(gsub("[a-zA-Z]", "", elem$V3))))
- ))
- -
- for (data in separatedData) {
- print(paste(data$V1[1],
- paste(
- round(mean(as.numeric(gsub("\\%", "", data$V2))), digits = 2),
- "% cpu",
- sep = ""),
- paste(
- round(mean(as.numeric(gsub("[a-zA-Z ]", "", data$V3))), digits = 1),
- "MiB memory",
- sep = ""),
- "(AVERAGE)",
- sep = " "))
- cpuNumeric <- as.numeric(gsub("\\%", "", data$V2))
- maxCpu <- data[c(which(cpuNumeric == max(cpuNumeric))[1]),]
- print(paste(maxCpu$V1[1],
- maxCpu$V2,
- "cpu",
- "(MAX)",
- maxCpu$V4,
- maxCpu$V5,
- sep = " "))
- minCpu <- data[c(which(cpuNumeric == min(cpuNumeric))[1]),]
- print(paste(minCpu$V1[1],
- minCpu$V2,
- "cpu",
- "(MIN)",
- minCpu$V4,
- minCpu$V5,
- sep = " "))
- }
Add Comment
Please, Sign In to add comment