feat: Add GPU inspection/monitoring support (#28)

This commit is contained in:
UUBulb
2024-06-23 10:27:18 +08:00
committed by GitHub
parent 968faca950
commit 338f0dabbe
18 changed files with 521 additions and 75 deletions
+10
View File
@@ -65,12 +65,20 @@ func editAgentConfig(cmd *cobra.Command, args []string) {
Default: strings.Join(agentConfig.DNS, ","),
},
},
{
Name: "gpu",
Prompt: &survey.Confirm{
Message: "是否启用 GPU 监控?",
Default: false,
},
},
}
answers := struct {
Nic []string
Disk []string
DNS string
GPU bool
}{}
err = survey.Ask(qs, &answers, survey.WithValidator(survey.Required))
@@ -108,6 +116,8 @@ func editAgentConfig(cmd *cobra.Command, args []string) {
agentConfig.DNS = []string{}
}
agentConfig.GPU = answers.GPU
if err = agentConfig.Save(); err != nil {
panic(err)
}
+1
View File
@@ -153,6 +153,7 @@ func init() {
agentCmd.PersistentFlags().BoolVar(&agentCliParam.DisableCommandExecute, "disable-command-execute", false, "禁止在此机器上执行命令")
agentCmd.PersistentFlags().BoolVar(&agentCliParam.DisableAutoUpdate, "disable-auto-update", false, "禁用自动升级")
agentCmd.PersistentFlags().BoolVar(&agentCliParam.DisableForceUpdate, "disable-force-update", false, "禁用强制升级")
agentCmd.PersistentFlags().BoolVar(&agentConfig.GPU, "gpu", false, "启用GPU监控")
agentCmd.PersistentFlags().Uint32VarP(&agentCliParam.IPReportPeriod, "ip-report-period", "u", 30*60, "本地IP更新间隔, 上报频率依旧取决于report-delay的值")
agentCmd.Flags().BoolVarP(&agentCliParam.Version, "version", "v", false, "查看当前版本号")
+1
View File
@@ -53,6 +53,7 @@ func serviceActions(cmd *cobra.Command, args []string) {
{agentCliParam.DisableCommandExecute, "--disable-command-execute", ""},
{agentCliParam.DisableAutoUpdate, "--disable-auto-update", ""},
{agentCliParam.DisableForceUpdate, "--disable-force-update", ""},
{agentConfig.GPU, "--gpu", ""},
{agentCliParam.IPReportPeriod != 30*60, "-u", fmt.Sprint(agentCliParam.IPReportPeriod)},
}