Commit 55a48ebc authored by Michael Friedrich's avatar Michael Friedrich
Browse files

go-icinga2-events: Better logging

parent 8b01485b
...@@ -137,9 +137,7 @@ func handleEventTypes(response string) { ...@@ -137,9 +137,7 @@ func handleEventTypes(response string) {
} }
if CheckResult.Type == "CheckResult" { if CheckResult.Type == "CheckResult" {
fmt.Println("Processing type 'CheckResult'") //fmt.Println("Processing type 'CheckResult'")
fmt.Println()
CheckResultCount++ CheckResultCount++
...@@ -156,12 +154,14 @@ func handleEventTypes(response string) { ...@@ -156,12 +154,14 @@ func handleEventTypes(response string) {
StateChangesObject[ObjectName] = append(StateChangesObject[ObjectName], state) StateChangesObject[ObjectName] = append(StateChangesObject[ObjectName], state)
//periodic statistics //periodic statistics
if time.Now().Unix() % 5 == 0 { if time.Now().Unix() % 2 == 0 {
var CheckResultRate = CheckResultCount / (time.Now().Unix() - StartTime) var CheckResultRate = float64(CheckResultCount) / float64(time.Now().Unix() - StartTime)
fmt.Println("Global check result rate:", CheckResultRate) fmt.Println("Global check result rate/second:", CheckResultRate)
var CheckResultObjectRate = float64(CheckResultCountObject[ObjectName]) / float64(time.Now().Unix() - StartTime)
fmt.Printf("Check result rate for object '%s': %.02f\n", ObjectName, CheckResultObjectRate)
var CheckResultObjectRate = CheckResultCountObject[ObjectName] / (time.Now().Unix() - StartTime) fmt.Println(" ")
fmt.Printf("Check result rate for object %s: %f", ObjectName, CheckResultObjectRate)
} }
} }
} }
...@@ -203,8 +203,8 @@ func eventLoop() { ...@@ -203,8 +203,8 @@ func eventLoop() {
fmt.Println("Error reading stream", err) fmt.Println("Error reading stream", err)
return return
} }
fmt.Println("Processing message") //fmt.Println("Processing message")
fmt.Println(string(line)) //fmt.Println(string(line))
//call handler for json decoding and message processing //call handler for json decoding and message processing
handleEventTypes(string(line)) handleEventTypes(string(line))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment