|
|
@ -112,12 +112,12 @@ func (c *processCollector) getAllocatedThreads() (int, map[string]int32, int, er
|
|
|
|
procStates := make(map[string]int32)
|
|
|
|
procStates := make(map[string]int32)
|
|
|
|
for _, pid := range p {
|
|
|
|
for _, pid := range p {
|
|
|
|
stat, err := pid.Stat()
|
|
|
|
stat, err := pid.Stat()
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
// PIDs can vanish between getting the list and getting stats.
|
|
|
|
// PIDs can vanish between getting the list and getting stats.
|
|
|
|
if errors.Is(err, os.ErrNotExist) || errorContains(err, syscall.ESRCH) {
|
|
|
|
if errors.Is(err, os.ErrNotExist) || strings.Contains(err.Error(), syscall.ESRCH.Error()) {
|
|
|
|
level.Debug(c.logger).Log("msg", "file not found when retrieving stats for pid", "pid", pid, "err", err)
|
|
|
|
level.Debug(c.logger).Log("msg", "file not found when retrieving stats for pid", "pid", pid, "err", err)
|
|
|
|
continue
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
level.Debug(c.logger).Log("msg", "error reading stat for pid", "pid", pid, "err", err)
|
|
|
|
level.Debug(c.logger).Log("msg", "error reading stat for pid", "pid", pid, "err", err)
|
|
|
|
return 0, nil, 0, err
|
|
|
|
return 0, nil, 0, err
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -127,7 +127,3 @@ func (c *processCollector) getAllocatedThreads() (int, map[string]int32, int, er
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return pids, procStates, thread, nil
|
|
|
|
return pids, procStates, thread, nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func errorContains(err, target error) bool {
|
|
|
|
|
|
|
|
return err != nil && target != nil && strings.Contains(err.Error(), target.Error())
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|