Skip to content

Commit

Permalink
Merge pull request #1612 from eric1234/correct-process-counts
Browse files Browse the repository at this point in the history
Total Processes in `MiscStat` Corrected
  • Loading branch information
shirou authored Mar 23, 2024
2 parents ce0395f + cded180 commit e230f52
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions load/load_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func MiscWithContext(ctx context.Context) (*MiscStat, error) {

}

procsTotal, err := getProcsTotal(ctx)
procsTotal, err := common.NumProcsWithContext(ctx)
if err != nil {
return ret, err
}
Expand All @@ -116,14 +116,6 @@ func MiscWithContext(ctx context.Context) (*MiscStat, error) {
return ret, nil
}

func getProcsTotal(ctx context.Context) (int64, error) {
values, err := readLoadAvgFromFile(ctx)
if err != nil {
return 0, err
}
return strconv.ParseInt(strings.Split(values[3], "/")[1], 10, 64)
}

func readLoadAvgFromFile(ctx context.Context) ([]string, error) {
loadavgFilename := common.HostProcWithContext(ctx, "loadavg")
line, err := os.ReadFile(loadavgFilename)
Expand Down

0 comments on commit e230f52

Please sign in to comment.