parent
ca051cd1cc
commit
1bc0252b84
1 changed files with 29 additions and 0 deletions
|
@ -4,6 +4,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
|
|
||||||
|
@ -33,12 +34,40 @@ func BoxIdValidator(cmd *cobra.Command, args []string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkAndNotify(boxIds []string) error {
|
func checkAndNotify(boxIds []string) error {
|
||||||
|
|
||||||
defaultNotifyConf := &core.NotifyConfig{}
|
defaultNotifyConf := &core.NotifyConfig{}
|
||||||
err := viper.UnmarshalKey("defaultHealthchecks", defaultNotifyConf)
|
err := viper.UnmarshalKey("defaultHealthchecks", defaultNotifyConf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// set default events, when no events are given. an empty events key indicates no checks are desired
|
||||||
|
if len(defaultNotifyConf.Events) == 0 {
|
||||||
|
allKeys := viper.AllKeys()
|
||||||
|
eventsDefined := false
|
||||||
|
for _, k := range allKeys {
|
||||||
|
if k == "defaulthealthchecks.events" {
|
||||||
|
eventsDefined = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !eventsDefined {
|
||||||
|
log.Debug("using default checks")
|
||||||
|
defaultNotifyConf.Events = []core.NotifyEvent{
|
||||||
|
core.NotifyEvent{
|
||||||
|
Type: "measurement_age",
|
||||||
|
Target: "all",
|
||||||
|
Threshold: "15m",
|
||||||
|
},
|
||||||
|
core.NotifyEvent{
|
||||||
|
Type: "measurement_faulty",
|
||||||
|
Target: "all",
|
||||||
|
Threshold: "",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
results, err := core.CheckBoxes(boxIds, defaultNotifyConf)
|
results, err := core.CheckBoxes(boxIds, defaultNotifyConf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
Loading…
Add table
Reference in a new issue