Golint & bug fixes
This commit is contained in:
@@ -82,9 +82,9 @@ func (incident *Incident) Send() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the same incident.
|
// GetSimilarIncidentId gets the same incident.
|
||||||
// GetSimilarIncidentId Updates incident.ID
|
// Updates incident.ID
|
||||||
func (incident *Incident) GetSimilarIncidentId() {
|
func (incident *Incident) GetSimilarIncidentID() {
|
||||||
incidents := GetIncidents()
|
incidents := GetIncidents()
|
||||||
|
|
||||||
for _, inc := range incidents {
|
for _, inc := range incidents {
|
||||||
|
|||||||
@@ -34,8 +34,8 @@ func (monitor *Monitor) Run() {
|
|||||||
monitor.History = append(monitor.History, isUp)
|
monitor.History = append(monitor.History, isUp)
|
||||||
monitor.AnalyseData()
|
monitor.AnalyseData()
|
||||||
|
|
||||||
if isUp == true && monitor.MetricId > 0 {
|
if isUp == true && monitor.MetricID > 0 {
|
||||||
SendMetric(monitor.MetricId, lag)
|
SendMetric(monitor.MetricID, lag)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -43,7 +43,7 @@ func (monitor *Monitor) doRequest() bool {
|
|||||||
client := &http.Client{
|
client := &http.Client{
|
||||||
Timeout: timeout,
|
Timeout: timeout,
|
||||||
}
|
}
|
||||||
resp, err := client.Get(monitor.Url)
|
resp, err := client.Get(monitor.URL)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errString := err.Error()
|
errString := err.Error()
|
||||||
monitor.LastFailReason = &errString
|
monitor.LastFailReason = &errString
|
||||||
@@ -66,7 +66,7 @@ func (monitor *Monitor) AnalyseData() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
t := (float32(numDown) / float32(len(monitor.History))) * 100
|
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 {
|
if len(monitor.History) != 10 {
|
||||||
// not enough data
|
// not enough data
|
||||||
@@ -90,7 +90,7 @@ func (monitor *Monitor) AnalyseData() {
|
|||||||
monitor.Incident.SetInvestigating()
|
monitor.Incident.SetInvestigating()
|
||||||
|
|
||||||
// lookup relevant incident
|
// lookup relevant incident
|
||||||
monitor.Incident.GetSimilarIncidentId()
|
monitor.Incident.GetSimilarIncidentID()
|
||||||
|
|
||||||
// create/update incident
|
// create/update incident
|
||||||
monitor.Incident.Send()
|
monitor.Incident.Send()
|
||||||
|
|||||||
6
main.go
6
main.go
@@ -10,9 +10,9 @@ func main() {
|
|||||||
fmt.Printf("API: %s\n", cachet.Config.APIUrl)
|
fmt.Printf("API: %s\n", cachet.Config.APIUrl)
|
||||||
fmt.Printf("Starting %d monitors:\n", len(cachet.Config.Monitors))
|
fmt.Printf("Starting %d monitors:\n", len(cachet.Config.Monitors))
|
||||||
for _, monitor := range cachet.Config.Monitors {
|
for _, monitor := range cachet.Config.Monitors {
|
||||||
fmt.Printf(" %s: GET %s & Expect HTTP %d\n", monitor.Name, monitor.Url, monitor.ExpectedStatusCode)
|
fmt.Printf(" %s: GET %s & Expect HTTP %d\n", monitor.Name, monitor.URL, monitor.ExpectedStatusCode)
|
||||||
if monitor.MetricId > 0 {
|
if monitor.MetricID > 0 {
|
||||||
fmt.Printf(" - Logs lag to metric id: %d\n", monitor.MetricId)
|
fmt.Printf(" - Logs lag to metric id: %d\n", monitor.MetricID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user