| 259 | } |
| 260 | |
| 261 | int16_t ControllerSocketProtocol::heartbeat(const C2Payload &payload) { |
| 262 | if (server_socket_ == nullptr) |
| 263 | return 0; |
| 264 | const std::vector<C2ContentResponse> &content = payload.getContent(); |
| 265 | for (const auto &pc : payload.getNestedPayloads()) { |
| 266 | if (pc.getLabel() == "flowInfo" || pc.getLabel() == "metrics") { |
| 267 | for (const auto &metrics_payload : pc.getNestedPayloads()) { |
| 268 | if (metrics_payload.getLabel() == "QueueMetrics" || metrics_payload.getLabel() == "queues") { |
| 269 | for (const auto &queue_metrics : metrics_payload.getNestedPayloads()) { |
| 270 | auto metric_content = queue_metrics.getContent(); |
| 271 | for (const auto &payload_content : queue_metrics.getContent()) { |
| 272 | uint64_t size = 0; |
| 273 | uint64_t max = 0; |
| 274 | for (auto content : payload_content.operation_arguments) { |
| 275 | if (content.first == "datasize") { |
| 276 | size = std::stol(content.second.to_string()); |
| 277 | } else if (content.first == "datasizemax") { |
| 278 | max = std::stol(content.second.to_string()); |
| 279 | } |
| 280 | } |
| 281 | std::lock_guard<std::mutex> lock(controller_mutex_); |
| 282 | if (size >= max) { |
| 283 | queue_full_[payload_content.name] = true; |
| 284 | } else { |
| 285 | queue_full_[payload_content.name] = false; |
| 286 | } |
| 287 | queue_size_[payload_content.name] = size; |
| 288 | queue_max_[payload_content.name] = max; |
| 289 | } |
| 290 | } |
| 291 | } |
| 292 | } |
| 293 | } |
| 294 | } |
| 295 | |
| 296 | parse_content(content); |
| 297 | |
| 298 | std::vector<uint8_t> buffer; |
| 299 | buffer.resize(1024); |
| 300 | |
| 301 | return 0; |
| 302 | } |
| 303 | |
| 304 | } // namespace c2 |
| 305 | } // namespace minifi |
no test coverage detected