From 5c930cd4091f265066c5f6709a592b089abaff87 Mon Sep 17 00:00:00 2001 From: Christopher Ramey Date: Sat, 16 Jan 2021 09:30:18 -0900 Subject: [PATCH] Changed interval to duration, added outline for alarm configuration --- alrmrc | 8 +++++++- config/config.go | 6 +++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/alrmrc b/alrmrc index d353a81..ba6db9c 100644 --- a/alrmrc +++ b/alrmrc @@ -1,4 +1,10 @@ -set interval 30 +set interval 30s + +#alarm people email +# to test1@localhost +# to test2@localhost +# smtp localhost +# from alrm@localhost monitor group webservers host www1.example.com address 10.11.135.101 diff --git a/config/config.go b/config/config.go index 50139c6..9e2c506 100644 --- a/config/config.go +++ b/config/config.go @@ -2,12 +2,12 @@ package config import ( "fmt" - "strconv" + "time" ) type AlrmConfig struct { Groups map[string]*AlrmGroup - Interval int + Interval time.Duration } func (ac *AlrmConfig) NewGroup(name string) (*AlrmGroup, error) { @@ -25,7 +25,7 @@ func (ac *AlrmConfig) NewGroup(name string) (*AlrmGroup, error) { } func (ac *AlrmConfig) SetInterval(val string) error { - interval, err := strconv.Atoi(val) + interval, err := time.ParseDuration(val) if err != nil { return err }