- customisable time format

- custom messages
- configure threshold count instead of uptime %
This commit is contained in:
Matej Kramny
2017-02-05 23:43:38 -08:00
parent b3bc1d4405
commit 0dc54e4e6e
5 changed files with 90 additions and 33 deletions

View File

@@ -10,13 +10,13 @@ import (
)
type CachetMonitor struct {
SystemName string `json:"system_name"`
SystemName string `json:"system_name" yaml:"system_name"`
DateFormat string `json:"date_format" yaml:"date_format"`
API CachetAPI `json:"api"`
RawMonitors []map[string]interface{} `json:"monitors" yaml:"monitors"`
Monitors []MonitorInterface `json:"-" yaml:"-"`
Immediate bool `json:"-" yaml:"-"`
Monitors []MonitorInterface `json:"-" yaml:"-"`
Immediate bool `json:"-" yaml:"-"`
}
// Validate configuration
@@ -28,6 +28,10 @@ func (cfg *CachetMonitor) Validate() bool {
cfg.SystemName = getHostname()
}
if len(cfg.DateFormat) == 0 {
cfg.DateFormat = DefaultTimeFormat
}
if len(cfg.API.Token) == 0 || len(cfg.API.URL) == 0 {
logrus.Warnf("API URL or API Token missing.\nGet help at https://github.com/castawaylabs/cachet-monitor")
valid = false
@@ -74,3 +78,11 @@ func GetMonitorType(t string) string {
return t
}
func getTemplateData(monitor *AbstractMonitor) map[string]interface{} {
return map[string]interface{}{
"SystemName": monitor.config.SystemName,
"API": monitor.config.API,
"Monitor": monitor,
}
}