readFileBestEffort reads a file and returns its contents, or "" on any error. Missing cgroup/proc files (e.g. on non-Linux hosts) are expected and benign.
(path string)
| 26 | // readFileBestEffort reads a file and returns its contents, or "" on any error. |
| 27 | // Missing cgroup/proc files (e.g. on non-Linux hosts) are expected and benign. |
| 28 | func readFileBestEffort(path string) string { |
| 29 | b, err := os.ReadFile(path) |
| 30 | if err != nil { |
| 31 | return "" |
| 32 | } |
| 33 | return string(b) |
| 34 | } |
| 35 | |
| 36 | // systemTotalMemory returns the container-aware total system RAM in bytes. |
| 37 | // |