可选监控哪些分区及网卡

This commit is contained in:
naiba
2022-03-19 17:22:15 +08:00
parent 84866384f4
commit 4fa357755b
7 changed files with 243 additions and 95 deletions

View File

@@ -20,6 +20,34 @@ const (
ConfigCoverIgnoreAll
)
type AgentConfig struct {
HardDrivePartitionAllowlist []string
NICAllowlist map[string]bool
v *viper.Viper
}
func (c *AgentConfig) Read(path string) error {
c.v = viper.New()
c.v.SetConfigFile(path)
err := c.v.ReadInConfig()
if err != nil {
return err
}
err = c.v.Unmarshal(c)
if err != nil {
return err
}
return nil
}
func (c *AgentConfig) Save() error {
data, err := yaml.Marshal(c)
if err != nil {
return err
}
return ioutil.WriteFile(c.v.ConfigFileUsed(), data, os.ModePerm)
}
type Config struct {
Debug bool
Site struct {