Initial commit

This commit is contained in:
Babak Farrokhi 2019-05-06 16:11:38 +02:00
parent 193049853e
commit 24f076b38c
Signed by: farrokhi
GPG Key ID: 6B267AD85D632E9A
2 changed files with 36 additions and 0 deletions

9
go.mod Normal file
View 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
View 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)
}
}