diff --git a/src/runtime/cli/kata-metrics.go b/src/runtime/cli/kata-metrics.go new file mode 100644 index 0000000000..7d0c7307cc --- /dev/null +++ b/src/runtime/cli/kata-metrics.go @@ -0,0 +1,38 @@ +// Copyright (c) 2021 Apple Inc. +// +// SPDX-License-Identifier: Apache-2.0 +// + +package main + +import ( + "fmt" + + kataMonitor "github.com/kata-containers/kata-containers/src/runtime/pkg/kata-monitor" + "github.com/kata-containers/kata-containers/src/runtime/pkg/katautils" + "github.com/urfave/cli" +) + +var kataMetricsCLICommand = cli.Command{ + Name: "metrics", + Usage: "gather metrics associated with infrastructure used to run a sandbox", + UsageText: "metrics ", + Action: func(context *cli.Context) error { + + sandboxID := context.Args().Get(0) + + if err := katautils.VerifyContainerID(sandboxID); err != nil { + return err + } + + // Get the metrics! + metrics, err := kataMonitor.GetSandboxMetrics(sandboxID) + if err != nil { + return err + } + + fmt.Printf("%s\n", metrics) + + return nil + }, +} diff --git a/src/runtime/cli/main.go b/src/runtime/cli/main.go index 78ddb0739f..27757c0c4f 100644 --- a/src/runtime/cli/main.go +++ b/src/runtime/cli/main.go @@ -122,6 +122,7 @@ var runtimeCommands = []cli.Command{ kataCheckCLICommand, kataEnvCLICommand, kataExecCLICommand, + kataMetricsCLICommand, factoryCLICommand, }