[agent-wdd] 基本完成Info部分的整理
This commit is contained in:
@@ -6,6 +6,19 @@ import (
|
||||
)
|
||||
|
||||
func addInfoSubcommands(cmd *cobra.Command) {
|
||||
|
||||
// 操作系统
|
||||
os := &cobra.Command{
|
||||
Use: "os",
|
||||
Short: "主机操作系统相关的信息",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
os := config.ConfigCache.Agent.OS
|
||||
os.Gather()
|
||||
|
||||
os.SaveConfig()
|
||||
},
|
||||
}
|
||||
|
||||
// network
|
||||
network := &cobra.Command{
|
||||
Use: "network",
|
||||
@@ -16,5 +29,64 @@ func addInfoSubcommands(cmd *cobra.Command) {
|
||||
},
|
||||
}
|
||||
|
||||
cmd.AddCommand(network)
|
||||
// cpu
|
||||
cpu := &cobra.Command{
|
||||
Use: "cpu",
|
||||
Short: "主机cpu相关的信息",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
cpu := config.ConfigCache.Agent.CPU
|
||||
cpu.Gather()
|
||||
cpu.Save()
|
||||
},
|
||||
}
|
||||
|
||||
// memory
|
||||
memory := &cobra.Command{
|
||||
Use: "mem",
|
||||
Short: "主机memory相关的信息",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
mem := config.ConfigCache.Agent.Mem
|
||||
mem.Gather()
|
||||
swap := config.ConfigCache.Agent.Swap
|
||||
swap.Gather()
|
||||
|
||||
mem.SaveConfig()
|
||||
swap.SaveConfig()
|
||||
|
||||
},
|
||||
}
|
||||
|
||||
// disk
|
||||
disk := &cobra.Command{
|
||||
Use: "disk",
|
||||
Short: "主机disk相关的信息",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
//disks := config.ConfigCache.Agent.Disks
|
||||
config.DiskListGather()
|
||||
|
||||
config.DiskListSaveConfig()
|
||||
},
|
||||
}
|
||||
|
||||
// all全部的info
|
||||
all := &cobra.Command{
|
||||
Use: "all",
|
||||
Short: "主机全部相关的信息",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
cpu.Run(cmd, args)
|
||||
os.Run(cmd, args)
|
||||
memory.Run(cmd, args)
|
||||
network.Run(cmd, args)
|
||||
disk.Run(cmd, args)
|
||||
},
|
||||
}
|
||||
|
||||
cmd.AddCommand(
|
||||
all,
|
||||
os,
|
||||
cpu,
|
||||
memory,
|
||||
network,
|
||||
disk,
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user