Add "Replication Delay" and "Last Status Change" to pcp_node_info.
-->
ここでは例を示します。
<programlisting>
-$ pcp_node_info -h localhost -U postgres 0
-host1 5432 1 0.500000 waiting primary
+$ pcp_node_info -h localhost -U postgres 1
+/tmp 11003 2 0.500000 up standby 208 2018-07-03 08:26:39
</programlisting>
</para>
<para>
4. load balance weight
5. status name
6. backend role
+7. replication delay
+8. last status change time
-->
1. ノードのホスト名
2. ノードのポート番号
4. ロードバランスウェイト
5. バックエンド状態名
6. バックエンドの役割
+7. レプリケーションの遅延
+8. 最終ステータス変更時刻
</literallayout>
</para>
<para>
<option>--verbose</option> オプションは出力内容を理解するのに役に立ちます。例:
</para>
<programlisting>
-$ pcp_node_info --verbose -h localhost -U postgres 0
-Hostname : host1
-Port : 5432
-Status : 1
-Weight : 0.500000
-Status Name: waiting
-Role : primary
+$ pcp_node_info --verbose -h localhost -U postgres 1
+Hostname : /tmp
+Port : 11003
+Status : 2
+Weight : 0.500000
+Status Name : up
+Role : standby
+Replication Delay : 208
+Last Status Change: 2018-07-03 08:26:39
</programlisting>
</refsect1>
<para>
Here is an example output:
<programlisting>
-$ pcp_node_info -h localhost -U postgres 0
-host1 5432 1 0.500000 waiting primary
+$ pcp_node_info -h localhost -U postgres 1
+/tmp 11003 2 0.500000 up standby 208 2018-07-03 08:26:39
</programlisting>
</para>
<para>
4. load balance weight
5. status name
6. backend role
+7. replication delay
+8. last status change time
</literallayout>
</para>
<para>
The <option>--verbose</option> option can help understand the output. For example:
</para>
<programlisting>
-$ pcp_node_info --verbose -h localhost -U postgres 0
-Hostname : host1
-Port : 5432
-Status : 1
-Weight : 0.500000
-Status Name: waiting
-Role : primary
+$ pcp_node_info --verbose -h localhost -U postgres 1
+Hostname : /tmp
+Port : 11003
+Status : 2
+Weight : 0.500000
+Status Name : up
+Role : standby
+Replication Delay : 208
+Last Status Change: 2018-07-03 08:26:39
</programlisting>
</refsect1>
index++;
backend_info->role = atoi(index);
+ index = (char *) memchr(index, '\0', len);
+ if(index == NULL)
+ goto INVALID_RESPONSE;
+
+ index++;
+ backend_info->standby_delay = atol(index);
+
+ index = (char *) memchr(index, '\0', len);
+ if(index == NULL)
+ goto INVALID_RESPONSE;
+
+ index++;
+ backend_info->status_changed_time = atol(index);
+
+ index = (char *) memchr(index, '\0', len);
+ if(index == NULL)
+ goto INVALID_RESPONSE;
+
if (setNextResultBinaryData(pcpConn->pcpResInfo, (void *)backend_info, sizeof(BackendInfo) , NULL) < 0)
goto INVALID_RESPONSE;
char status[2];
char weight_str[20];
char role_str[10];
+ char standby_delay_str[20];
+ char status_changed_time_str[20];
char code[] = "CommandComplete";
BackendInfo *bi = NULL;
SERVER_ROLE role;
role = ROLE_SLAVE;
}
snprintf(role_str, sizeof(role_str), "%d", role);
+
+ snprintf(standby_delay_str, sizeof(standby_delay_str), UINT64_FORMAT, bi->standby_delay);
+
+ snprintf(status_changed_time_str, sizeof(status_changed_time_str), UINT64_FORMAT, bi->status_changed_time);
pcp_write(frontend, "i", 1);
wsize = htonl(sizeof(code) +
strlen(status)+1 +
strlen(weight_str)+1 +
strlen(role_str)+1 +
+ strlen(standby_delay_str)+1 +
+ strlen(status_changed_time_str)+1 +
sizeof(int));
pcp_write(frontend, &wsize, sizeof(int));
pcp_write(frontend, code, sizeof(code));
pcp_write(frontend, port_str, strlen(port_str)+1);
pcp_write(frontend, status, strlen(status)+1);
pcp_write(frontend, weight_str, strlen(weight_str)+1);
-
pcp_write(frontend, role_str, strlen(role_str)+1);
+ pcp_write(frontend, standby_delay_str, strlen(standby_delay_str)+1);
+ pcp_write(frontend, status_changed_time_str, strlen(status_changed_time_str)+1);
+
do_pcp_flush(frontend);
}
* pgpool: a language independent connection pool server for PostgreSQL
* written by Tatsuo Ishii
*
- * Copyright (c) 2003-2016 PgPool Global Development Group
+ * Copyright (c) 2003-2018 PgPool Global Development Group
*
* Permission to use, copy, modify, and distribute this software and
* its documentation for any purpose and without fee is hereby
output_nodeinfo_result(PCPResultInfo* pcpResInfo, bool verbose)
{
BackendInfo *backend_info = (BackendInfo *) pcp_get_binary_data(pcpResInfo,0);
+ char last_status_change[20];
+ struct tm tm;
+
+ localtime_r(&backend_info->status_changed_time, &tm);
+ strftime(last_status_change, sizeof(last_status_change), "%F %T", &tm);
if (verbose)
{
- printf("Hostname : %s\nPort : %d\nStatus : %d\nWeight : %f\nStatus Name: %s\nRole : %s\n",
+ printf("Hostname : %s\nPort : %d\nStatus : %d\nWeight : %f\nStatus Name : %s\nRole : %s\nReplication Delay : %lu\nLast Status Change: %s\n",
backend_info->backend_hostname,
backend_info->backend_port,
backend_info->backend_status,
backend_info->backend_weight/RAND_MAX,
backend_status_to_string(backend_info),
- role_to_str(backend_info->role));
- } else {
- printf("%s %d %d %f %s %s\n",
+ role_to_str(backend_info->role),
+ backend_info->standby_delay,
+ last_status_change);
+ }
+ else
+ {
+ printf("%s %d %d %f %s %s %lu %s\n",
backend_info->backend_hostname,
backend_info->backend_port,
backend_info->backend_status,
backend_info->backend_weight/RAND_MAX,
backend_status_to_string(backend_info),
- role_to_str(backend_info->role));
+ role_to_str(backend_info->role),
+ backend_info->standby_delay,
+ last_status_change);
}
}