forked from containers/psgo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
psgo.go
41 lines (34 loc) · 688 Bytes
/
psgo.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package main
import (
"flag"
"fmt"
"os"
"text/tabwriter"
"github.com/sirupsen/logrus"
"github.com/vrothberg/psgo/ps"
)
func main() {
var (
data []string
err error
)
pid := flag.String("pid", "", "join mount namespace of the process ID")
format := flag.String("format", "", "ps (1) AIX format comma-separated string")
flag.Parse()
if *pid != "" {
data, err = ps.JoinNamespaceAndProcessInfo(*pid, *format)
if err != nil {
logrus.Panic(err)
}
} else {
data, err = ps.ProcessInfo(*format)
if err != nil {
logrus.Panic(err)
}
}
tw := tabwriter.NewWriter(os.Stdout, 20, 1, 3, ' ', 0)
for _, d := range data {
fmt.Fprintln(tw, d)
}
tw.Flush()
}