diff --git a/main.go b/main.go index dceefe2..26c6102 100644 --- a/main.go +++ b/main.go @@ -33,7 +33,7 @@ func checkMonitors(config *Config) error { hasAlert := alertNotice != nil // Track status metrics - Metrics.SetMonitorStatus(monitor.Name, success) + Metrics.SetMonitorStatus(monitor.Name, monitor.IsUp()) Metrics.CountCheck(monitor.Name, success, hasAlert) // Should probably consider refactoring everything below here diff --git a/monitor.go b/monitor.go index 764b788..c5d8cd8 100644 --- a/monitor.go +++ b/monitor.go @@ -85,12 +85,13 @@ func (monitor *Monitor) Check() (bool, *AlertNotice) { return isSuccess, alertNotice } -func (monitor Monitor) isUp() bool { +// IsUp returns the status of the current monitor +func (monitor Monitor) IsUp() bool { return monitor.alertCount == 0 } func (monitor *Monitor) success() (notice *AlertNotice) { - if !monitor.isUp() { + if !monitor.IsUp() { // Alert that we have recovered notice = monitor.createAlertNotice(true) } diff --git a/monitor_test.go b/monitor_test.go index d5a1b1b..b7619c8 100644 --- a/monitor_test.go +++ b/monitor_test.go @@ -56,7 +56,7 @@ func TestMonitorShouldCheck(t *testing.T) { } } -// TestMonitorIsUp tests the Monitor.isUp() +// TestMonitorIsUp tests the Monitor.IsUp() func TestMonitorIsUp(t *testing.T) { cases := []struct { monitor Monitor @@ -71,9 +71,9 @@ func TestMonitorIsUp(t *testing.T) { for _, c := range cases { log.Printf("Testing case %s", c.name) - actual := c.monitor.isUp() + actual := c.monitor.IsUp() if actual != c.expected { - t.Errorf("isUp(%v), expected=%t actual=%t", c.name, c.expected, actual) + t.Errorf("IsUp(%v), expected=%t actual=%t", c.name, c.expected, actual) log.Printf("Case failed: %s", c.name) } log.Println("-----")