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:
{
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: