2020-08-15 17:16:52 -08:00
|
|
|
package main
|
|
|
|
|
|
|
|
type AlrmConfig struct {
|
2020-08-16 04:19:06 -08:00
|
|
|
Groups []*AlrmGroup
|
|
|
|
Interval int
|
2020-08-15 17:16:52 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (ac *AlrmConfig) NewGroup() *AlrmGroup {
|
|
|
|
group := &AlrmGroup{}
|
|
|
|
ac.Groups = append(ac.Groups, group)
|
|
|
|
return group
|
|
|
|
}
|
|
|
|
|
|
|
|
type AlrmGroup struct {
|
|
|
|
Name string
|
|
|
|
Hosts []*AlrmHost
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ag *AlrmGroup) NewHost() *AlrmHost {
|
|
|
|
host := &AlrmHost{}
|
|
|
|
ag.Hosts = append(ag.Hosts, host)
|
|
|
|
return host
|
|
|
|
}
|
|
|
|
|
|
|
|
type AlrmHost struct {
|
|
|
|
Name string
|
|
|
|
Address string
|
|
|
|
}
|
|
|
|
|
|
|
|
func ReadConfig(fn string) (*AlrmConfig, error) {
|
|
|
|
parser := &Parser{}
|
2020-08-20 04:34:22 -08:00
|
|
|
config, err := parser.Parse(fn)
|
|
|
|
if err != nil {
|
2020-08-15 17:16:52 -08:00
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return config, nil
|
|
|
|
}
|