...
1
2
3 package main
4
5 import (
6 "context"
7 "fmt"
8 "os"
9
10 "github.com/Microsoft/hcsshim/internal/extendedtask"
11 "github.com/Microsoft/hcsshim/internal/shimdiag"
12 "github.com/urfave/cli"
13 )
14
15 func main() {
16 app := cli.NewApp()
17 app.Name = "extendedtask"
18 app.Usage = "tool for getting compute info"
19 app.Commands = []cli.Command{
20 processorInfoCommand,
21 }
22 if err := app.Run(os.Args); err != nil {
23 fmt.Fprintln(os.Stderr, err)
24 os.Exit(1)
25 }
26 }
27
28 var processorInfoCommand = cli.Command{
29 Name: "processorInfo",
30 ArgsUsage: "<shim name> <target container ID>",
31 Action: func(ctx *cli.Context) error {
32 args := ctx.Args()
33 var (
34 shimName = args[0]
35 containerID = args[1]
36 )
37 shim, err := shimdiag.GetShim(shimName)
38 if err != nil {
39 return err
40 }
41 svc := extendedtask.NewExtendedTaskClient(shim)
42 resp, err := svc.ComputeProcessorInfo(context.Background(), &extendedtask.ComputeProcessorInfoRequest{ID: containerID})
43 if err != nil {
44 return err
45 }
46 fmt.Println("CPU count:\n", resp.Count)
47 return nil
48 },
49 }
50
View as plain text