Load config from disk|url, create incidents

- Resolve incidents after the monitor is up
- Example configuration
- Updated readme
This commit is contained in:
Matej Kramny
2015-03-18 22:58:45 +01:00
parent 44a9cf905f
commit 42237e9c86
9 changed files with 130 additions and 49 deletions

View File

@@ -17,6 +17,7 @@ type Monitor struct {
ExpectedStatusCode int `json:"expected_status_code"`
History []bool `json:"-"`
LastFailReason *string `json:"-"`
Incident *Incident `json:"-"`
}
@@ -42,6 +43,8 @@ func (monitor *Monitor) doRequest() bool {
}
resp, err := client.Get(monitor.Url)
if err != nil {
errString := err.Error()
monitor.LastFailReason = &errString
return false
}
@@ -73,7 +76,11 @@ func (monitor *Monitor) AnalyseData() {
monitor.Incident = &Incident{
Name: monitor.Name,
Message: monitor.Name + " is unreachable.",
Message: monitor.Name + " failed",
}
if monitor.LastFailReason != nil {
monitor.Incident.Message += "\n\n" + *monitor.LastFailReason
}
monitor.Incident.SetInvestigating()
@@ -91,4 +98,4 @@ func (monitor *Monitor) AnalyseData() {
func getMs() int64 {
return time.Now().UnixNano() / int64(time.Millisecond)
}
}