Skip to content

Commit

Permalink
Add stats to metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
nakabonne committed Oct 31, 2020
1 parent 97c565d commit 85487d0
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions stats/meta.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package stats

import (
"fmt"
"os"
"runtime"

Expand All @@ -10,6 +11,7 @@ import (
// Meta represents process metadata, which will be not changed
// as long as the process continues.
type Meta struct {
PID int
Username string
Command string
GoMaxProcs int
Expand All @@ -31,9 +33,21 @@ func NewMeta() (*Meta, error) {
command = c
}
return &Meta{
PID: os.Getpid(),
Username: username,
Command: command,
GoMaxProcs: runtime.GOMAXPROCS(0),
NumCPU: runtime.NumCPU(),
}, nil
}

func (m *Meta) String() string {
return fmt.Sprintf(
"PID: %d, CMD: %s, User: %s, Num CPU: %d, GOPAXPROS: %d",
m.PID,
m.Command,
m.Username,
m.NumCPU,
m.GoMaxProcs,
)
}

0 comments on commit 85487d0

Please sign in to comment.