A simple monitoring solution written in Go (work in progress)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
814 B

package config
import (
"fmt"
"time"
)
type AlrmConfig struct {
Groups map[string]*AlrmGroup
Interval time.Duration
}
func (ac *AlrmConfig) NewGroup(name string) (*AlrmGroup, error) {
if ac.Groups == nil {
ac.Groups = make(map[string]*AlrmGroup)
}
if _, exists := ac.Groups[name]; exists {
return nil, fmt.Errorf("group %s already exists", name)
}
group := &AlrmGroup{Name: name}
ac.Groups[name] = group
return group, nil
}
func (ac *AlrmConfig) SetInterval(val string) error {
interval, err := time.ParseDuration(val)
if err != nil {
return err
}
ac.Interval = interval
return nil
}
func ReadConfig(fn string, debuglvl int) (*AlrmConfig, error) {
parser := &Parser{DebugLevel: debuglvl}
config, err := parser.Parse(fn)
if err != nil {
return nil, err
}
return config, nil
}