System logger

This commit is contained in:
Matej Kramny
2015-03-21 12:36:45 +01:00
parent dce1978b51
commit 8e9c388894
5 changed files with 46 additions and 24 deletions

View File

@@ -1,7 +1,6 @@
package cachet
import (
"fmt"
"net/http"
"time"
)
@@ -66,7 +65,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)
Logger.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
@@ -75,7 +74,7 @@ func (monitor *Monitor) AnalyseData() {
if t > monitor.Threshold && monitor.Incident == nil {
// is down, create an incident
fmt.Println("Creating incident...")
Logger.Println("Creating incident...")
monitor.Incident = &Incident{
Name: monitor.Name + " - " + Config.SystemName,
@@ -96,7 +95,7 @@ func (monitor *Monitor) AnalyseData() {
monitor.Incident.Send()
} else if t < monitor.Threshold && monitor.Incident != nil {
// was down, created an incident, its now ok, make it resolved.
fmt.Println("Updating incident to resolved...")
Logger.Println("Updating incident to resolved...")
monitor.Incident.SetFixed()
monitor.Incident.Send()