Files
ProjectOctopus/agent-wdd/cmd/Info.go
zeaslity db3d259a0a Enhance Proxy and Configuration Management
- Implemented comprehensive VMESS proxy installation with dynamic configuration
- Added support for Xray installation and configuration generation
- Introduced hostname normalization with city, architecture, and IP-based naming
- Updated proxy commands to include VMESS and VLESS subcommands
- Improved configuration management with NormalizeConfig method
- Enhanced logging and error handling for proxy-related operations
2025-02-28 23:58:38 +08:00

99 lines
1.8 KiB
Go

package cmd
import (
"agent-wdd/config"
"github.com/spf13/cobra"
)
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",
Short: "主机Network相关的信息",
Run: func(cmd *cobra.Command, args []string) {
network := config.ConfigCache.Agent.Network
network.Gather()
network.SaveConfig()
},
}
// 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) {
// 执行所有info
cpu.Run(cmd, args)
os.Run(cmd, args)
memory.Run(cmd, args)
network.Run(cmd, args)
disk.Run(cmd, args)
// 归一化
config.ConfigCache.NormalizeConfig()
},
}
cmd.AddCommand(
all,
os,
cpu,
memory,
network,
disk,
)
}