Guest User

Untitled

a guest
Jan 16th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. # docker stats | awk '(NR+3)%4 {print $2, $3, $4, strftime("%Y-%m-%d %H:%M:%S")}' >> ~/research/tests/test.txt
  2.  
  3. services <- read.table(file = "~/research/tests/test.txt", header = FALSE)
  4.  
  5. separatedData <- split(services, services$V1, drop=TRUE)
  6.  
  7. cpuRange <- range(0, lapply(separatedData, function(elem)
  8. max(ceiling(as.numeric(gsub("\\%", "", elem$V2))))
  9. ))
  10.  
  11. memoryRange <- range(0, lapply(separatedData, function(elem)
  12. max(ceiling(as.numeric(gsub("[a-zA-Z]", "", elem$V3))))
  13. ))
  14.  
  15. -
  16. for (data in separatedData) {
  17.  
  18. print(paste(data$V1[1],
  19. paste(
  20. round(mean(as.numeric(gsub("\\%", "", data$V2))), digits = 2),
  21. "% cpu",
  22. sep = ""),
  23. paste(
  24. round(mean(as.numeric(gsub("[a-zA-Z ]", "", data$V3))), digits = 1),
  25. "MiB memory",
  26. sep = ""),
  27. "(AVERAGE)",
  28. sep = " "))
  29.  
  30.  
  31. cpuNumeric <- as.numeric(gsub("\\%", "", data$V2))
  32.  
  33. maxCpu <- data[c(which(cpuNumeric == max(cpuNumeric))[1]),]
  34.  
  35. print(paste(maxCpu$V1[1],
  36. maxCpu$V2,
  37. "cpu",
  38. "(MAX)",
  39. maxCpu$V4,
  40. maxCpu$V5,
  41. sep = " "))
  42.  
  43. minCpu <- data[c(which(cpuNumeric == min(cpuNumeric))[1]),]
  44.  
  45. print(paste(minCpu$V1[1],
  46. minCpu$V2,
  47. "cpu",
  48. "(MIN)",
  49. minCpu$V4,
  50. minCpu$V5,
  51. sep = " "))
  52. }
Add Comment
Please, Sign In to add comment