mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-23 23:26:30 +00:00
Add "repmgr node status"
Outputs an overview of a node's status, and emits warnings if any issues detected.
This commit is contained in:
38
dbutils.c
38
dbutils.c
@@ -2005,6 +2005,7 @@ delete_node_record(PGconn *conn, int node)
|
||||
log_verbose(LOG_DEBUG, "delete_node_record():\n %s", query.data);
|
||||
|
||||
res = PQexec(conn, query.data);
|
||||
termPQExpBuffer(&query);
|
||||
|
||||
if (!res || PQresultStatus(res) != PGRES_COMMAND_OK)
|
||||
{
|
||||
@@ -2019,6 +2020,43 @@ delete_node_record(PGconn *conn, int node)
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
get_node_replication_stats(PGconn *conn, t_node_info *node_info)
|
||||
{
|
||||
PQExpBufferData query;
|
||||
PGresult *res;
|
||||
|
||||
initPQExpBuffer(&query);
|
||||
|
||||
appendPQExpBuffer(
|
||||
&query,
|
||||
" SELECT current_setting('max_wal_senders')::INT AS max_wal_senders, "
|
||||
" (SELECT COUNT(*) FROM pg_catalog.pg_stat_replication) AS attached_wal_receivers, "
|
||||
" current_setting('max_replication_slots')::INT AS max_replication_slots, "
|
||||
" (SELECT COUNT(*) FROM pg_catalog.pg_replication_slots WHERE active = TRUE) AS active_replication_slots, "
|
||||
" (SELECT COUNT(*) FROM pg_catalog.pg_replication_slots WHERE active = FALSE) AS inactive_replication_slots ");
|
||||
|
||||
res = PQexec(conn, query.data);
|
||||
termPQExpBuffer(&query);
|
||||
|
||||
if (PQresultStatus(res) != PGRES_TUPLES_OK)
|
||||
{
|
||||
log_warning(_("unable to retrieve node replication statistics:\n %s"),
|
||||
PQerrorMessage(conn));
|
||||
PQclear(res);
|
||||
return;
|
||||
}
|
||||
|
||||
node_info->max_wal_senders = atoi(PQgetvalue(res, 0, 0));
|
||||
node_info->attached_wal_receivers = atoi(PQgetvalue(res, 0, 1));
|
||||
node_info->max_replication_slots = atoi(PQgetvalue(res, 0, 2));
|
||||
node_info->active_replication_slots = atoi(PQgetvalue(res, 0, 3));
|
||||
node_info->inactive_replication_slots = atoi(PQgetvalue(res, 0, 4));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
clear_node_info_list(NodeInfoList *nodes)
|
||||
|
||||
Reference in New Issue
Block a user