cli/cmd/supervisor_stats.go

42 lines
988 B
Go

package cmd
import (
"fmt"
helper "github.com/home-assistant/cli/client"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
var supervisorStatsCmd = &cobra.Command{
Use: "stats",
Aliases: []string{"status", "stat", "st"},
Short: "Provides system usage stats of the Home Assistant Supervisor",
Long: `
Provides insight into the system usage stats of the Home Assistant Supervisor.
It shows you how much CPU, memory, disk & network resources it uses.`,
Example: `
ha supervisor stats`,
Run: func(cmd *cobra.Command, args []string) {
log.WithField("args", args).Debug("supervisor stats")
section := "supervisor"
command := "stats"
base := viper.GetString("endpoint")
resp, err := helper.GenericJSONGet(base, section, command)
if err != nil {
fmt.Println(err)
ExitWithError = true
} else {
ExitWithError = !helper.ShowJSONResponse(resp)
}
},
}
func init() {
supervisorCmd.AddCommand(supervisorStatsCmd)
}