From f999c810a77e21cb462926eb1e3b085e6387b159 Mon Sep 17 00:00:00 2001 From: Ian Barwick Date: Fri, 22 Jun 2018 10:15:45 +0900 Subject: [PATCH] node check: clarify status information for witness server Previously the output gave the impression the server was a primary, which is technically the case, but it's not the actual cluster primary. Also output an error if the node is in recovery, which is unlikely but you never know. --- repmgr-action-node.c | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/repmgr-action-node.c b/repmgr-action-node.c index c732eafc..2792536b 100644 --- a/repmgr-action-node.c +++ b/repmgr-action-node.c @@ -770,6 +770,19 @@ do_node_check_role(PGconn *conn, OutputMode mode, t_node_info *node_info, CheckS _("node is standby")); } break; + case WITNESS: + if (recovery_type == RECTYPE_STANDBY) + { + status = CHECK_STATUS_CRITICAL; + appendPQExpBuffer(&details, + _("node is registered as witness but running as standby")); + } + else + { + appendPQExpBuffer(&details, + _("node is witness")); + } + break; case BDR: { PQExpBufferData output; @@ -1148,21 +1161,26 @@ do_node_check_replication_lag(PGconn *conn, OutputMode mode, t_node_info *node_i switch (mode) { case OM_OPTFORMAT: - appendPQExpBuffer( - &details, + appendPQExpBuffer(&details, "--lag=0"); break; case OM_NAGIOS: - appendPQExpBuffer( - &details, + appendPQExpBuffer(&details, "0 seconds | lag=0;%i;%i", config_file_options.replication_lag_warning, config_file_options.replication_lag_critical); break; case OM_TEXT: - appendPQExpBuffer( - &details, - "N/A - node is primary"); + if (node_info->type == WITNESS) + { + appendPQExpBuffer(&details, + "N/A - node is witness"); + } + else + { + appendPQExpBuffer(&details, + "N/A - node is primary"); + } break; default: break;