getTotalMemory returns the total memory available on the system. If a cgroup is detected, it will use the cgroup memory max.
(ctx context.Context)
| 2293 | |
| 2294 | // getTotalMemory returns the total memory available on the system. If a cgroup is detected, it will use the cgroup memory max. |
| 2295 | func getTotalMemory(ctx context.Context) uint64 { |
| 2296 | memoryTotal, err := memlimit.FromCgroup() |
| 2297 | if err == nil { |
| 2298 | return memoryTotal |
| 2299 | } |
| 2300 | base.TracefCtx(ctx, base.KeyAll, "Did not detect a cgroup for a memory limit") |
| 2301 | memory, err := mem.VirtualMemory() |
| 2302 | if err != nil { |
| 2303 | base.WarnfCtx(ctx, "Error getting total memory from gopsutil: %v", err) |
| 2304 | return 0 |
| 2305 | } |
| 2306 | return memory.Total |
| 2307 | } |
| 2308 | |
| 2309 | // getClusterUUID returns the cluster UUID. rosmar does not have a ClusterUUID, so this will return an empty cluster UUID and no error in this case. |
| 2310 | func (sc *ServerContext) getClusterUUID(ctx context.Context) (string, error) { |