From cc4475b8e22fe7908a0e5bcbf47380a5040d5375 Mon Sep 17 00:00:00 2001 From: Ian Barwick Date: Wed, 20 Apr 2022 17:35:44 +0900 Subject: [PATCH] node check: fix --downstream --nagios output Ensure the performance data output (the bit after the pipe) contains information in a pareseable format. GitHub #749. --- repmgr-action-node.c | 39 +++++++++++---------------------------- 1 file changed, 11 insertions(+), 28 deletions(-) diff --git a/repmgr-action-node.c b/repmgr-action-node.c index 5ba65d2e..fcbab0b3 100644 --- a/repmgr-action-node.c +++ b/repmgr-action-node.c @@ -1395,49 +1395,32 @@ do_node_check_downstream(PGconn *conn, OutputMode mode, t_node_info *node_info, { case OM_NAGIOS: { - printf("REPMGR_DOWNSTREAM_SERVERS %s: %s | ", - output_check_status(status), - details.data); - if (missing_nodes_count) { ItemListCell *missing_cell = NULL; bool first = true; - printf("missing: "); + appendPQExpBufferStr(&details, " (missing: "); + for (missing_cell = missing_nodes.head; missing_cell; missing_cell = missing_cell->next) { if (first == false) - printf(", "); + appendPQExpBufferStr(&details, ", "); else first = false; if (first == false) - printf("%s", missing_cell->string); + appendPQExpBufferStr(&details, missing_cell->string); } + + appendPQExpBufferChar(&details, ')'); } - if (expected_nodes_count - missing_nodes_count) - { - ItemListCell *attached_cell = NULL; - bool first = true; - - if (missing_nodes_count) - printf("; "); - printf("attached: "); - for (attached_cell = attached_nodes.head; attached_cell; attached_cell = attached_cell->next) - { - if (first == false) - printf(", "); - else - first = false; - - if (first == false) - printf("%s", attached_cell->string); - } - } - printf("\n"); - + printf("REPMGR_DOWNSTREAM_SERVERS %s: %s | attached=%i, missing=%i\n", + output_check_status(status), + details.data, + expected_nodes_count - missing_nodes_count, + missing_nodes_count); } break; case OM_CSV: