Report new incident and set as fixed

This commit is contained in:
Matej Kramny
2015-07-19 21:32:26 +01:00
parent a710944218
commit b609679993
2 changed files with 7 additions and 20 deletions

View File

@@ -86,20 +86,6 @@ func (incident *Incident) Send() {
} }
} }
// GetSimilarIncidentID gets the same incident.
// Updates incident.ID
func (incident *Incident) GetSimilarIncidentID() {
incidents := GetIncidents()
for _, inc := range incidents {
if incident.Name == inc.Name && incident.Message == inc.Message && incident.Status == inc.Status {
incident.ID = inc.ID
Logger.Printf("Updated incident id to %v\n", inc.ID)
break
}
}
}
func (incident *Incident) fetchComponent() error { func (incident *Incident) fetchComponent() error {
_, body, err := makeRequest("GET", "/components/"+string(*incident.ComponentID), nil) _, body, err := makeRequest("GET", "/components/"+string(*incident.ComponentID), nil)
if err != nil { if err != nil {

View File

@@ -100,15 +100,12 @@ func (monitor *Monitor) AnalyseData() {
} }
if monitor.LastFailReason != nil { if monitor.LastFailReason != nil {
monitor.Incident.Message += "\n\n" + *monitor.LastFailReason monitor.Incident.Message += "\n\n - " + *monitor.LastFailReason
} }
// set investigating status // set investigating status
monitor.Incident.SetInvestigating() monitor.Incident.SetInvestigating()
// lookup relevant incident
monitor.Incident.GetSimilarIncidentID()
// create/update incident // create/update incident
monitor.Incident.Send() monitor.Incident.Send()
monitor.Incident.UpdateComponent() monitor.Incident.UpdateComponent()
@@ -116,8 +113,12 @@ func (monitor *Monitor) AnalyseData() {
// was down, created an incident, its now ok, make it resolved. // was down, created an incident, its now ok, make it resolved.
Logger.Println("Updating incident to resolved...") Logger.Println("Updating incident to resolved...")
// Add resolved message component_id := json.Number(strconv.Itoa(*monitor.ComponentID))
monitor.Incident.Message += "\n\n-\n\nResolved at " + time.Now().String() monitor.Incident = &Incident{
Name: monitor.Incident.Name,
Message: monitor.Name + " check succeeded",
ComponentID: &component_id,
}
monitor.Incident.SetFixed() monitor.Incident.SetFixed()
monitor.Incident.Send() monitor.Incident.Send()