From d62aa53169bd4544c300653ba85d1b1bd848317a Mon Sep 17 00:00:00 2001 From: Matej Kramny Date: Fri, 20 Mar 2015 21:04:48 +0100 Subject: [PATCH] Golint & bug fixes --- cachet/incident.go | 6 +++--- cachet/monitor.go | 10 +++++----- main.go | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/cachet/incident.go b/cachet/incident.go index cc9f791..62bd649 100644 --- a/cachet/incident.go +++ b/cachet/incident.go @@ -82,9 +82,9 @@ func (incident *Incident) Send() { } } -// Get the same incident. -// GetSimilarIncidentId Updates incident.ID -func (incident *Incident) GetSimilarIncidentId() { +// GetSimilarIncidentId gets the same incident. +// Updates incident.ID +func (incident *Incident) GetSimilarIncidentID() { incidents := GetIncidents() for _, inc := range incidents { diff --git a/cachet/monitor.go b/cachet/monitor.go index 111a927..2a922d7 100644 --- a/cachet/monitor.go +++ b/cachet/monitor.go @@ -34,8 +34,8 @@ func (monitor *Monitor) Run() { monitor.History = append(monitor.History, isUp) monitor.AnalyseData() - if isUp == true && monitor.MetricId > 0 { - SendMetric(monitor.MetricId, lag) + if isUp == true && monitor.MetricID > 0 { + SendMetric(monitor.MetricID, lag) } } @@ -43,7 +43,7 @@ func (monitor *Monitor) doRequest() bool { client := &http.Client{ Timeout: timeout, } - resp, err := client.Get(monitor.Url) + resp, err := client.Get(monitor.URL) if err != nil { errString := err.Error() monitor.LastFailReason = &errString @@ -66,7 +66,7 @@ func (monitor *Monitor) AnalyseData() { } t := (float32(numDown) / float32(len(monitor.History))) * 100 - fmt.Printf("%s %.2f%% Down at %v. Threshold: %.2f%%\n", monitor.Url, t, time.Now().UnixNano()/int64(time.Second), monitor.Threshold) + fmt.Printf("%s %.2f%% Down at %v. Threshold: %.2f%%\n", monitor.URL, t, time.Now().UnixNano()/int64(time.Second), monitor.Threshold) if len(monitor.History) != 10 { // not enough data @@ -90,7 +90,7 @@ func (monitor *Monitor) AnalyseData() { monitor.Incident.SetInvestigating() // lookup relevant incident - monitor.Incident.GetSimilarIncidentId() + monitor.Incident.GetSimilarIncidentID() // create/update incident monitor.Incident.Send() diff --git a/main.go b/main.go index 5fdfd48..cf79c43 100644 --- a/main.go +++ b/main.go @@ -10,9 +10,9 @@ func main() { fmt.Printf("API: %s\n", cachet.Config.APIUrl) fmt.Printf("Starting %d monitors:\n", len(cachet.Config.Monitors)) for _, monitor := range cachet.Config.Monitors { - fmt.Printf(" %s: GET %s & Expect HTTP %d\n", monitor.Name, monitor.Url, monitor.ExpectedStatusCode) - if monitor.MetricId > 0 { - fmt.Printf(" - Logs lag to metric id: %d\n", monitor.MetricId) + fmt.Printf(" %s: GET %s & Expect HTTP %d\n", monitor.Name, monitor.URL, monitor.ExpectedStatusCode) + if monitor.MetricID > 0 { + fmt.Printf(" - Logs lag to metric id: %d\n", monitor.MetricID) } }