From dd7ebdc1c73fb9a47374b749a9a75d6cc3b32a86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Gross?= Date: Wed, 23 Sep 2015 15:50:36 +0200 Subject: [PATCH] Add more information in "cluster show" - Add display of current node name. - Add display of upstream node name. --- repmgr.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/repmgr.c b/repmgr.c index 9c04a4c8..a07d6837 100644 --- a/repmgr.c +++ b/repmgr.c @@ -588,9 +588,13 @@ do_cluster_show(void) conn = establish_db_connection(options.conninfo, true); sqlquery_snprintf(sqlquery, - "SELECT conninfo, type " - " FROM %s.repl_nodes ", - get_repmgr_schema_quoted(conn)); + "SELECT rn.conninfo, rn.type, rn.name, sq.name" + " FROM %s.repl_nodes as rn" + " LEFT JOIN %s.repl_nodes AS sq" + " ON sq.id=rn.upstream_node_id", + get_repmgr_schema_quoted(conn), + get_repmgr_schema_quoted(conn)); + res = PQexec(conn, sqlquery); if (PQresultStatus(res) != PGRES_TUPLES_OK) @@ -605,7 +609,7 @@ do_cluster_show(void) } PQfinish(conn); - printf("Role | Connection String\n"); + printf("Role | Name | Upstream | Connection String\n"); for (i = 0; i < PQntuples(res); i++) { conn = establish_db_connection(PQgetvalue(res, i, 0), false); @@ -619,6 +623,8 @@ do_cluster_show(void) strcpy(node_role, "* master"); printf("%-10s", node_role); + printf("| %-14s", PQgetvalue(res, i, 2)); + printf("| %-14s", PQgetvalue(res, i, 3)); printf("| %s\n", PQgetvalue(res, i, 0)); PQfinish(conn);