mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-24 23:56:29 +00:00
repmgr: add --terse mode to "cluster show"
This suppresses display of the usually lengthy "conninfo" column, mainly useful for generating a compact table suitable for pasting into emails, chats etc. without messy line breaks. Implements GitHub #521.
This commit is contained in:
1
HISTORY
1
HISTORY
@@ -1,5 +1,6 @@
|
|||||||
4.3 2019-??
|
4.3 2019-??
|
||||||
repmgr: add --version-number command line option (Ian)
|
repmgr: add --version-number command line option (Ian)
|
||||||
|
repmgr: add --terse option to "cluster show"; GitHub #521 (Ian)
|
||||||
repmgrd: check binary and extension major versions match; GitHub #515 (Ian)
|
repmgrd: check binary and extension major versions match; GitHub #515 (Ian)
|
||||||
|
|
||||||
4.2.1 2018-??-??
|
4.2.1 2018-??-??
|
||||||
|
|||||||
@@ -26,6 +26,15 @@
|
|||||||
<para>
|
<para>
|
||||||
<itemizedlist>
|
<itemizedlist>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
Add <option>--terse</option> to <command><link linkend="repmgr-cluster-show">repmgr cluster show</link></command> (GitHub #521).
|
||||||
|
</para>
|
||||||
|
<para>
|
||||||
|
This makes it easier to copy the output into emails, chats etc. as a compact table.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
<command>repmgr --version-number</command> outputs the "raw"
|
<command>repmgr --version-number</command> outputs the "raw"
|
||||||
@@ -34,6 +43,7 @@
|
|||||||
of the &repmgr; version.
|
of the &repmgr; version.
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
|
|
||||||
</itemizedlist>
|
</itemizedlist>
|
||||||
</para>
|
</para>
|
||||||
</sect2>
|
</sect2>
|
||||||
|
|||||||
@@ -120,6 +120,15 @@
|
|||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><option>--terse</option></term>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
Suppress display of the <literal>conninfo</literal> column.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term><option>--verbose</option></term>
|
<term><option>--verbose</option></term>
|
||||||
<listitem>
|
<listitem>
|
||||||
|
|||||||
@@ -102,6 +102,7 @@ do_cluster_show(void)
|
|||||||
exit(ERR_BAD_CONFIG);
|
exit(ERR_BAD_CONFIG);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Initialize column headers */
|
||||||
strncpy(headers_show[SHOW_ID].title, _("ID"), MAXLEN);
|
strncpy(headers_show[SHOW_ID].title, _("ID"), MAXLEN);
|
||||||
strncpy(headers_show[SHOW_NAME].title, _("Name"), MAXLEN);
|
strncpy(headers_show[SHOW_NAME].title, _("Name"), MAXLEN);
|
||||||
strncpy(headers_show[SHOW_ROLE].title, _("Role"), MAXLEN);
|
strncpy(headers_show[SHOW_ROLE].title, _("Role"), MAXLEN);
|
||||||
@@ -117,7 +118,20 @@ do_cluster_show(void)
|
|||||||
|
|
||||||
for (i = 0; i < SHOW_HEADER_COUNT; i++)
|
for (i = 0; i < SHOW_HEADER_COUNT; i++)
|
||||||
{
|
{
|
||||||
headers_show[i].max_length = strlen(headers_show[i].title);
|
headers_show[i].display = true;
|
||||||
|
|
||||||
|
if (runtime_options.terse == true)
|
||||||
|
{
|
||||||
|
if (i == SHOW_CONNINFO)
|
||||||
|
{
|
||||||
|
headers_show[i].display = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (headers_show[i].display == true)
|
||||||
|
{
|
||||||
|
headers_show[i].max_length = strlen(headers_show[i].title);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (cell = nodes.head; cell; cell = cell->next)
|
for (cell = nodes.head; cell; cell = cell->next)
|
||||||
@@ -347,6 +361,12 @@ do_cluster_show(void)
|
|||||||
|
|
||||||
for (i = 0; i < SHOW_HEADER_COUNT; i++)
|
for (i = 0; i < SHOW_HEADER_COUNT; i++)
|
||||||
{
|
{
|
||||||
|
if (runtime_options.terse == true)
|
||||||
|
{
|
||||||
|
if (headers_show[i].display == false)
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (headers_show[i].cur_length > headers_show[i].max_length)
|
if (headers_show[i].cur_length > headers_show[i].max_length)
|
||||||
{
|
{
|
||||||
headers_show[i].max_length = headers_show[i].cur_length;
|
headers_show[i].max_length = headers_show[i].cur_length;
|
||||||
@@ -398,7 +418,13 @@ do_cluster_show(void)
|
|||||||
printf("| %-*s ", headers_show[SHOW_STATUS].max_length, cell->node_info->details);
|
printf("| %-*s ", headers_show[SHOW_STATUS].max_length, cell->node_info->details);
|
||||||
printf("| %-*s ", headers_show[SHOW_UPSTREAM_NAME].max_length, cell->node_info->upstream_node_name);
|
printf("| %-*s ", headers_show[SHOW_UPSTREAM_NAME].max_length, cell->node_info->upstream_node_name);
|
||||||
printf("| %-*s ", headers_show[SHOW_LOCATION].max_length, cell->node_info->location);
|
printf("| %-*s ", headers_show[SHOW_LOCATION].max_length, cell->node_info->location);
|
||||||
printf("| %-*s\n", headers_show[SHOW_CONNINFO].max_length, cell->node_info->conninfo);
|
|
||||||
|
if (headers_show[SHOW_CONNINFO].display == true)
|
||||||
|
{
|
||||||
|
printf("| %-*s", headers_show[SHOW_CONNINFO].max_length, cell->node_info->conninfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
puts("");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -91,6 +91,7 @@ do_daemon_status(void)
|
|||||||
for (i = 0; i < STATUS_HEADER_COUNT; i++)
|
for (i = 0; i < STATUS_HEADER_COUNT; i++)
|
||||||
{
|
{
|
||||||
headers_status[i].max_length = strlen(headers_status[i].title);
|
headers_status[i].max_length = strlen(headers_status[i].title);
|
||||||
|
headers_status[i].display = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
|
|||||||
@@ -199,6 +199,7 @@ typedef struct ColHeader
|
|||||||
char title[MAXLEN];
|
char title[MAXLEN];
|
||||||
int max_length;
|
int max_length;
|
||||||
int cur_length;
|
int cur_length;
|
||||||
|
bool display;
|
||||||
} ColHeader;
|
} ColHeader;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1947,9 +1947,20 @@ void
|
|||||||
print_status_header(int cols, ColHeader *headers)
|
print_status_header(int cols, ColHeader *headers)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
int max_cols = 0;
|
||||||
|
|
||||||
|
/* count how many columns we actually need to display */
|
||||||
|
for (i = 0; i < cols; i++)
|
||||||
|
{
|
||||||
|
if (headers[i].display == true)
|
||||||
|
max_cols ++;
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < cols; i++)
|
for (i = 0; i < cols; i++)
|
||||||
{
|
{
|
||||||
|
if (headers[i].display == false)
|
||||||
|
continue;
|
||||||
|
|
||||||
if (i == 0)
|
if (i == 0)
|
||||||
printf(" ");
|
printf(" ");
|
||||||
else
|
else
|
||||||
@@ -1959,17 +1970,22 @@ print_status_header(int cols, ColHeader *headers)
|
|||||||
headers[i].max_length,
|
headers[i].max_length,
|
||||||
headers[i].title);
|
headers[i].title);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
printf("\n");
|
printf("\n");
|
||||||
printf("-");
|
printf("-");
|
||||||
|
|
||||||
for (i = 0; i < cols; i++)
|
for (i = 0; i < max_cols; i++)
|
||||||
{
|
{
|
||||||
int j;
|
int j;
|
||||||
|
|
||||||
|
if (headers[i].display == false)
|
||||||
|
continue;
|
||||||
|
|
||||||
for (j = 0; j < headers[i].max_length; j++)
|
for (j = 0; j < headers[i].max_length; j++)
|
||||||
printf("-");
|
printf("-");
|
||||||
|
|
||||||
if (i < (cols - 1))
|
if (i < (max_cols - 1))
|
||||||
printf("-+-");
|
printf("-+-");
|
||||||
else
|
else
|
||||||
printf("-");
|
printf("-");
|
||||||
|
|||||||
Reference in New Issue
Block a user