()
| 92 | } |
| 93 | |
| 94 | func getHostMemLimit() float64 { |
| 95 | file, err := os.Open("/proc/meminfo") |
| 96 | if err != nil { |
| 97 | return float64(^uint64(0)) |
| 98 | } |
| 99 | defer file.Close() |
| 100 | |
| 101 | scanner := bufio.NewScanner(file) |
| 102 | for scanner.Scan() { |
| 103 | if strings.HasPrefix(scanner.Text(), "MemTotal:") { |
| 104 | fields := strings.Fields(scanner.Text()) |
| 105 | if len(fields) >= 2 { |
| 106 | memKb, err := strconv.ParseUint(fields[1], 10, 64) |
| 107 | if err == nil { |
| 108 | return float64(memKb * 1024) // kB to bytes |
| 109 | } |
| 110 | } |
| 111 | break |
| 112 | } |
| 113 | } |
| 114 | return float64(^uint64(0)) |
| 115 | } |
| 116 | |
| 117 | func calculateCgroupCPUPercent(previousStats *ContainerStats, metrics *v1.Metrics, systemInfo SystemInfo) float64 { |
| 118 | var ( |
no test coverage detected
searching dependent graphs…