getSystemCPUUsage reads the system's CPU usage from /proc/stat and returns the total CPU usage in nanoseconds and the number of CPUs.
()
| 134 | // getSystemCPUUsage reads the system's CPU usage from /proc/stat and returns |
| 135 | // the total CPU usage in nanoseconds and the number of CPUs. |
| 136 | func getSystemCPUUsage() (cpuUsage uint64, cpuNum uint32, _ error) { |
| 137 | f, err := os.Open("/proc/stat") |
| 138 | if err != nil { |
| 139 | return 0, 0, err |
| 140 | } |
| 141 | defer f.Close() |
| 142 | |
| 143 | return readSystemCPUUsage(f) |
| 144 | } |
| 145 | |
| 146 | // readSystemCPUUsage parses CPU usage information from a reader providing |
| 147 | // /proc/stat format data. It returns the total CPU usage in nanoseconds |
no test coverage detected
searching dependent graphs…