node check: fix --downstream --nagios output

Ensure the performance data output (the bit after the pipe) contains
information in a pareseable format.

GitHub #749.
This commit is contained in:
Ian Barwick
2022-04-20 17:35:44 +09:00
parent 9f1c9ef829
commit cc4475b8e2

View File

@@ -1395,49 +1395,32 @@ do_node_check_downstream(PGconn *conn, OutputMode mode, t_node_info *node_info,
{ {
case OM_NAGIOS: case OM_NAGIOS:
{ {
printf("REPMGR_DOWNSTREAM_SERVERS %s: %s | ",
output_check_status(status),
details.data);
if (missing_nodes_count) if (missing_nodes_count)
{ {
ItemListCell *missing_cell = NULL; ItemListCell *missing_cell = NULL;
bool first = true; bool first = true;
printf("missing: "); appendPQExpBufferStr(&details, " (missing: ");
for (missing_cell = missing_nodes.head; missing_cell; missing_cell = missing_cell->next) for (missing_cell = missing_nodes.head; missing_cell; missing_cell = missing_cell->next)
{ {
if (first == false) if (first == false)
printf(", "); appendPQExpBufferStr(&details, ", ");
else else
first = false; first = false;
if (first == false) if (first == false)
printf("%s", missing_cell->string); appendPQExpBufferStr(&details, missing_cell->string);
} }
appendPQExpBufferChar(&details, ')');
} }
if (expected_nodes_count - missing_nodes_count) printf("REPMGR_DOWNSTREAM_SERVERS %s: %s | attached=%i, missing=%i\n",
{ output_check_status(status),
ItemListCell *attached_cell = NULL; details.data,
bool first = true; expected_nodes_count - missing_nodes_count,
missing_nodes_count);
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");
} }
break; break;
case OM_CSV: case OM_CSV: