| 60 | } |
| 61 | |
| 62 | CheckableCheckStatistics CIB::CalculateHostCheckStats() |
| 63 | { |
| 64 | double min_latency = -1, max_latency = 0, sum_latency = 0; |
| 65 | int count_latency = 0; |
| 66 | double min_execution_time = -1, max_execution_time = 0, sum_execution_time = 0; |
| 67 | int count_execution_time = 0; |
| 68 | bool checkresult = false; |
| 69 | |
| 70 | for (const Host::Ptr& host : ConfigType::GetObjectsByType<Host>()) { |
| 71 | ObjectLock olock(host); |
| 72 | |
| 73 | CheckResult::Ptr cr = host->GetLastCheckResult(); |
| 74 | |
| 75 | if (!cr) |
| 76 | continue; |
| 77 | |
| 78 | /* set to true, we have a checkresult */ |
| 79 | checkresult = true; |
| 80 | |
| 81 | /* latency */ |
| 82 | double latency = cr->CalculateLatency(); |
| 83 | |
| 84 | if (min_latency == -1 || latency < min_latency) |
| 85 | min_latency = latency; |
| 86 | |
| 87 | if (latency > max_latency) |
| 88 | max_latency = latency; |
| 89 | |
| 90 | sum_latency += latency; |
| 91 | count_latency++; |
| 92 | |
| 93 | /* execution_time */ |
| 94 | double execution_time = cr->CalculateExecutionTime(); |
| 95 | |
| 96 | if (min_execution_time == -1 || execution_time < min_execution_time) |
| 97 | min_execution_time = execution_time; |
| 98 | |
| 99 | if (execution_time > max_execution_time) |
| 100 | max_execution_time = execution_time; |
| 101 | |
| 102 | sum_execution_time += execution_time; |
| 103 | count_execution_time++; |
| 104 | } |
| 105 | |
| 106 | if (!checkresult) { |
| 107 | min_latency = 0; |
| 108 | min_execution_time = 0; |
| 109 | } |
| 110 | |
| 111 | CheckableCheckStatistics ccs; |
| 112 | |
| 113 | ccs.min_latency = min_latency; |
| 114 | ccs.max_latency = max_latency; |
| 115 | ccs.avg_latency = sum_latency / count_latency; |
| 116 | ccs.min_execution_time = min_execution_time; |
| 117 | ccs.max_execution_time = max_execution_time; |
| 118 | ccs.avg_execution_time = sum_execution_time / count_execution_time; |
| 119 |
nothing calls this directly
no test coverage detected