daemon status: with csv output, show repmgrd status as unknown where appropriate

Previously, if PostgreSQL was not running on the node, repmgrd and
pause status were shown as "0", implying their status was known.

This brings the csv output in line with the human-readable output,
which displays "n/a" in this case.
This commit is contained in:
Ian Barwick
2019-02-28 11:51:47 +09:00
parent 1f256d4d73
commit bd35b450da
2 changed files with 64 additions and 51 deletions

View File

@@ -260,14 +260,24 @@ do_daemon_status(void)
{
if (runtime_options.output_mode == OM_CSV)
{
int running = repmgrd_info[i]->running ? 1 : 0;
int paused = repmgrd_info[i]->paused ? 1 : 0;
/* If PostgreSQL is not running, repmgrd status is unknown */
if (repmgrd_info[i]->pg_running == false)
{
running = -1;
paused = -1;
}
printf("%i,%s,%s,%i,%i,%i,%i,%i,%i\n",
cell->node_info->node_id,
cell->node_info->node_name,
get_node_type_string(cell->node_info->type),
repmgrd_info[i]->pg_running ? 1 : 0,
repmgrd_info[i]->running ? 1 : 0,
running,
repmgrd_info[i]->pid,
repmgrd_info[i]->paused ? 1 : 0,
paused,
cell->node_info->priority,
repmgrd_info[i]->pid == UNKNOWN_PID
? -1