Initial commit
This commit is contained in:
parent
193049853e
commit
24f076b38c
9
go.mod
Normal file
9
go.mod
Normal file
@ -0,0 +1,9 @@
|
||||
module goprocstat
|
||||
|
||||
require (
|
||||
github.com/cockroachdb/apd v1.1.0
|
||||
github.com/shirou/gopsutil v2.18.12+incompatible
|
||||
golang.org/x/sys v0.0.0-20190506115046-ca7f33d4116e // indirect
|
||||
)
|
||||
|
||||
go 1.12
|
27
goprocstat.go
Normal file
27
goprocstat.go
Normal file
@ -0,0 +1,27 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"github.com/shirou/gopsutil/process"
|
||||
"time"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
||||
flagPID := flag.Int("PID", 1, "Gimme your PID")
|
||||
flag.Parse()
|
||||
|
||||
p, _ := process.NewProcess(int32(*flagPID))
|
||||
v, err := p.Times()
|
||||
|
||||
for {
|
||||
if err == nil {
|
||||
fmt.Printf("%d pid: %d user: %f\t system: %f\n", time.Now().Unix(), *flagPID, v.User, v.System)
|
||||
} else {
|
||||
fmt.Println(err)
|
||||
}
|
||||
time.Sleep(time.Second)
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user