repmgr node status: optional CSV output

This commit is contained in:
Ian Barwick
2017-07-25 11:26:09 +09:00
parent 56b2e9bb84
commit 2a08317984

View File

@@ -159,16 +159,66 @@ do_node_status(void)
initPQExpBuffer(&output);
appendPQExpBuffer(
&output,
"Node \"%s\":\n",
node_info.node_name);
for (cell = node_status.head; cell; cell = cell->next)
if (runtime_options.csv == true)
{
appendPQExpBuffer(
&output,
"\"Node name\",\"Node ID\",");
for (cell = node_status.head; cell; cell = cell->next)
{
appendPQExpBuffer(
&output,
"\"%s\"", cell->key);
if (cell->next)
{
appendPQExpBuffer(
&output,
",");
}
}
appendPQExpBuffer(
&output,
"\n");
appendPQExpBuffer(
&output,
"%s,%i,",
node_info.node_name,
node_info.node_id);
for (cell = node_status.head; cell; cell = cell->next)
{
appendPQExpBuffer(
&output,
"\"%s\"", cell->value);
if (cell->next)
{
appendPQExpBuffer(
&output,
",");
}
}
appendPQExpBuffer(
&output,
"\n");
}
else
{
appendPQExpBuffer(
&output,
"Node \"%s\":\n",
node_info.node_name);
for (cell = node_status.head; cell; cell = cell->next)
{
appendPQExpBuffer(
&output,
"\t%s: %s\n", cell->key, cell->value);
}
}
puts(output.data);