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) {
}
if CheckResult.Type == "CheckResult" {
fmt.Println("Processing type 'CheckResult'")
fmt.Println()
//fmt.Println("Processing type 'CheckResult'")
CheckResultCount++
......@@ -156,12 +154,14 @@ func handleEventTypes(response string) {
StateChangesObject[ObjectName] = append(StateChangesObject[ObjectName], state)
//periodic statistics
if time.Now().Unix() % 5 == 0 {
var CheckResultRate = CheckResultCount / (time.Now().Unix() - StartTime)
fmt.Println("Global check result rate:", CheckResultRate)
if time.Now().Unix() % 2 == 0 {
var CheckResultRate = float64(CheckResultCount) / float64(time.Now().Unix() - StartTime)
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.Printf("Check result rate for object %s: %f", ObjectName, CheckResultObjectRate)
fmt.Println(" ")
}
}
}
......@@ -203,8 +203,8 @@ func eventLoop() {
fmt.Println("Error reading stream", err)
return
}
fmt.Println("Processing message")
fmt.Println(string(line))
//fmt.Println("Processing message")
//fmt.Println(string(line))
//call handler for json decoding and message processing
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