Add user tag to procstat input (#4386)

This commit is contained in:
Greg
2018-07-05 14:56:41 -06:00
committed by Daniel Nelson
parent bf076dab73
commit b5cdeeb300
3 changed files with 17 additions and 0 deletions

View File

@@ -21,6 +21,7 @@ type Process interface {
Percent(interval time.Duration) (float64, error)
Times() (*cpu.TimesStat, error)
RlimitUsage(bool) ([]process.RlimitStat, error)
Username() (string, error)
}
type PIDFinder interface {
@@ -58,6 +59,10 @@ func (p *Proc) PID() PID {
return PID(p.Process.Pid)
}
func (p *Proc) Username() (string, error) {
return p.Process.Username()
}
func (p *Proc) Percent(interval time.Duration) (float64, error) {
cpu_perc, err := p.Process.Percent(time.Duration(0))
if !p.hasCPUTimes && err == nil {