|
| 1 | +package process |
| 2 | + |
| 3 | +func (p *Process) UpdateProcInfo() { |
| 4 | + tempBackground, err := p.Proc.Background() |
| 5 | + if err == nil { |
| 6 | + p.Background = tempBackground |
| 7 | + } |
| 8 | + |
| 9 | + tempForeground, err := p.Proc.Foreground() |
| 10 | + if err == nil { |
| 11 | + p.Foreground = tempForeground |
| 12 | + } |
| 13 | + |
| 14 | + tempIsRunning, err := p.Proc.IsRunning() |
| 15 | + if err == nil { |
| 16 | + p.IsRunning = tempIsRunning |
| 17 | + } |
| 18 | + |
| 19 | + tempCPUPercent, err := p.Proc.CPUPercent() |
| 20 | + if err == nil { |
| 21 | + p.CPUPercent = tempCPUPercent |
| 22 | + } |
| 23 | + |
| 24 | + tempChildren, err := p.Proc.Children() |
| 25 | + if err == nil { |
| 26 | + p.Children = tempChildren |
| 27 | + } |
| 28 | + |
| 29 | + tempCreateTime, err := p.Proc.CreateTime() |
| 30 | + if err == nil { |
| 31 | + p.CreateTime = tempCreateTime |
| 32 | + } |
| 33 | + |
| 34 | + tempGids, err := p.Proc.Gids() |
| 35 | + if err == nil { |
| 36 | + p.Gids = tempGids |
| 37 | + } |
| 38 | + |
| 39 | + tempMemInfo, err := p.Proc.MemoryInfo() |
| 40 | + if err == nil { |
| 41 | + p.MemoryInfo = tempMemInfo |
| 42 | + } |
| 43 | + |
| 44 | + tempMemPerc, err := p.Proc.MemoryPercent() |
| 45 | + if err == nil { |
| 46 | + p.MemoryPercent = tempMemPerc |
| 47 | + } |
| 48 | + |
| 49 | + tempName, err := p.Proc.Name() |
| 50 | + if err == nil { |
| 51 | + p.Name = tempName |
| 52 | + } |
| 53 | + |
| 54 | + tempNice, err := p.Proc.Nice() |
| 55 | + if err == nil { |
| 56 | + p.Nice = tempNice |
| 57 | + } |
| 58 | + |
| 59 | + tempCtx, err := p.Proc.NumCtxSwitches() |
| 60 | + if err == nil { |
| 61 | + p.NumCtxSwitches = tempCtx |
| 62 | + } |
| 63 | + |
| 64 | + tempNumThreads, err := p.Proc.NumThreads() |
| 65 | + if err == nil { |
| 66 | + p.NumThreads = tempNumThreads |
| 67 | + } |
| 68 | + |
| 69 | + tempPageFault, err := p.Proc.PageFaults() |
| 70 | + if err == nil { |
| 71 | + p.PageFault = tempPageFault |
| 72 | + } |
| 73 | + |
| 74 | + tempStatus, err := p.Proc.Status() |
| 75 | + if err == nil { |
| 76 | + p.Status = tempStatus |
| 77 | + } |
| 78 | + |
| 79 | + tempExe, err := p.Proc.Exe() |
| 80 | + if err == nil { |
| 81 | + p.Exe = tempExe |
| 82 | + } else { |
| 83 | + p.Exe = "NA" |
| 84 | + } |
| 85 | + |
| 86 | + tempAffinity, err := p.Proc.CPUAffinity() |
| 87 | + if err == nil { |
| 88 | + p.CPUAffinity = tempAffinity |
| 89 | + } |
| 90 | +} |
0 commit comments