Skip to content

Commit

Permalink
Fix #58: correctly report the aggregate context switches for all the …
Browse files Browse the repository at this point in the history
…threads in the process.
  • Loading branch information
ncabatoff committed Sep 1, 2018
1 parent 05a1f77 commit d1c35c3
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions proc/tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,12 +221,22 @@ func (t *Tracker) handleProc(proc Proc, updateTime time.Time) (*IDInfo, CollectE
}
return nil, cerrs
}
cerrs.Partial += softerrors

var threads []Thread
if t.trackThreads {
threads, _ = proc.GetThreads()
threads, err = proc.GetThreads()
if err != nil {
softerrors |= 1
}
cerrs.Partial += softerrors

if len(threads) > 0 {
metrics.Counts.CtxSwitchNonvoluntary, metrics.Counts.CtxSwitchVoluntary = 0, 0
for _, thread := range threads {
metrics.Counts.CtxSwitchNonvoluntary += thread.Counts.CtxSwitchNonvoluntary
metrics.Counts.CtxSwitchVoluntary += thread.Counts.CtxSwitchVoluntary
}
}

var newProc *IDInfo
if known {
last.update(metrics, updateTime, &cerrs, threads)
Expand Down

0 comments on commit d1c35c3

Please # to comment.