From acca9ec425b5e2688bcc9863b0b7d9e33a0b9e9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Ma=C5=9Blanka?= Date: Wed, 3 Apr 2024 12:35:09 +0200 Subject: [PATCH] c/types: made cluster health overview printable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Michał Maślanka --- src/v/cluster/health_monitor_types.cc | 20 ++++++++++++++++++++ src/v/cluster/health_monitor_types.h | 3 +++ 2 files changed, 23 insertions(+) diff --git a/src/v/cluster/health_monitor_types.cc b/src/v/cluster/health_monitor_types.cc index 4c4183dc138f5..cfec6acc7ce05 100644 --- a/src/v/cluster/health_monitor_types.cc +++ b/src/v/cluster/health_monitor_types.cc @@ -263,4 +263,24 @@ std::ostream& operator<<(std::ostream& o, const get_cluster_health_reply& r) { return o; } +std::ostream& operator<<(std::ostream& o, const cluster_health_overview& ho) { + fmt::print( + o, + "{{controller_id: {}, nodes: {}, unhealthy_reasons: {}, nodes_down: {}, " + "nodes_in_recovery_mode: {}, bytes_in_cloud_storage: {}, " + "leaderless_count: {}, under_replicated_count: {}, " + "leaderless_partitions: {}, under_replicated_partitions: {}}}", + ho.controller_id, + ho.all_nodes, + ho.unhealthy_reasons, + ho.nodes_down, + ho.nodes_in_recovery_mode, + ho.bytes_in_cloud_storage, + ho.leaderless_count, + ho.under_replicated_count, + ho.leaderless_partitions, + ho.under_replicated_partitions); + return o; +} + } // namespace cluster diff --git a/src/v/cluster/health_monitor_types.h b/src/v/cluster/health_monitor_types.h index 738a7f4c01430..9b58705c9682d 100644 --- a/src/v/cluster/health_monitor_types.h +++ b/src/v/cluster/health_monitor_types.h @@ -276,6 +276,9 @@ struct cluster_health_overview { std::vector under_replicated_partitions; size_t under_replicated_count{}; std::optional bytes_in_cloud_storage; + + friend std::ostream& + operator<<(std::ostream&, const cluster_health_overview&); }; using include_partitions_info = ss::bool_class;