mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-26 08:36:30 +00:00
"repmgr cluster events": show node name in output, if available
Nodes can be removed from repmgr.nodes, so we'll only have the historical ID available via repmgr.events.
This commit is contained in:
@@ -275,6 +275,14 @@ The following commands are available:
|
|||||||
* `--node-name`: restrict entries to node with this name
|
* `--node-name`: restrict entries to node with this name
|
||||||
* `--event`: filter specific event
|
* `--event`: filter specific event
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
$ repmgr -f /etc/repmgr.conf cluster event --event=standby_register
|
||||||
|
Node ID | Name | Event | OK | Timestamp | Details
|
||||||
|
---------+-------+------------------+----+---------------------+--------------------------------
|
||||||
|
3 | node3 | standby_register | t | 2017-08-17 10:28:55 | standby registration succeeded
|
||||||
|
2 | node2 | standby_register | t | 2017-08-17 10:28:53 | standby registration succeeded
|
||||||
|
|
||||||
|
|
||||||
Backwards compatibility
|
Backwards compatibility
|
||||||
-----------------------
|
-----------------------
|
||||||
|
|||||||
@@ -23,10 +23,11 @@ typedef enum {
|
|||||||
SHOW_CONNINFO
|
SHOW_CONNINFO
|
||||||
} ShowHeader;
|
} ShowHeader;
|
||||||
|
|
||||||
#define EVENT_HEADER_COUNT 5
|
#define EVENT_HEADER_COUNT 6
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
EV_NODE_ID = 0,
|
EV_NODE_ID = 0,
|
||||||
|
EV_NODE_NAME,
|
||||||
EV_EVENT,
|
EV_EVENT,
|
||||||
EV_SUCCESS,
|
EV_SUCCESS,
|
||||||
EV_TIMESTAMP,
|
EV_TIMESTAMP,
|
||||||
@@ -353,17 +354,20 @@ do_cluster_event(void)
|
|||||||
initPQExpBuffer(&query);
|
initPQExpBuffer(&query);
|
||||||
initPQExpBuffer(&where_clause);
|
initPQExpBuffer(&where_clause);
|
||||||
|
|
||||||
appendPQExpBuffer(&query,
|
/* LEFT JOIN used here as a node record may have been removed */
|
||||||
" SELECT e.node_id, e.event, e.successful, \n"
|
appendPQExpBuffer(
|
||||||
" TO_CHAR(e.event_timestamp, 'YYYY-MM-DD HH24:MI:SS') AS timestamp, \n"
|
&query,
|
||||||
" e.details \n"
|
" SELECT e.node_id, n.node_name, e.event, e.successful, \n"
|
||||||
" FROM repmgr.events e");
|
" TO_CHAR(e.event_timestamp, 'YYYY-MM-DD HH24:MI:SS') AS timestamp, \n"
|
||||||
|
" e.details \n"
|
||||||
|
" FROM repmgr.events e \n"
|
||||||
|
"LEFT JOIN repmgr.nodes n ON e.node_id = n.node_id ");
|
||||||
|
|
||||||
if (runtime_options.node_id != UNKNOWN_NODE_ID)
|
if (runtime_options.node_id != UNKNOWN_NODE_ID)
|
||||||
{
|
{
|
||||||
|
|
||||||
append_where_clause(&where_clause,
|
append_where_clause(&where_clause,
|
||||||
"node_id=%i", runtime_options.node_id);
|
"n.node_id=%i", runtime_options.node_id);
|
||||||
}
|
}
|
||||||
else if (runtime_options.node_name[0] != '\0')
|
else if (runtime_options.node_name[0] != '\0')
|
||||||
{
|
{
|
||||||
@@ -375,8 +379,6 @@ do_cluster_event(void)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
appendPQExpBuffer(&query,
|
|
||||||
" INNER JOIN repmgr.nodes n ON e.node_id = n.node_id ");
|
|
||||||
append_where_clause(&where_clause,
|
append_where_clause(&where_clause,
|
||||||
"n.node_name='%s'",
|
"n.node_name='%s'",
|
||||||
escaped);
|
escaped);
|
||||||
@@ -437,6 +439,7 @@ do_cluster_event(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
strncpy(headers_event[EV_NODE_ID].title, _("Node ID"), MAXLEN);
|
strncpy(headers_event[EV_NODE_ID].title, _("Node ID"), MAXLEN);
|
||||||
|
strncpy(headers_event[EV_NODE_NAME].title, _("Name"), MAXLEN);
|
||||||
strncpy(headers_event[EV_EVENT].title, _("Event"), MAXLEN);
|
strncpy(headers_event[EV_EVENT].title, _("Event"), MAXLEN);
|
||||||
strncpy(headers_event[EV_SUCCESS].title, _("OK"), MAXLEN);
|
strncpy(headers_event[EV_SUCCESS].title, _("OK"), MAXLEN);
|
||||||
strncpy(headers_event[EV_TIMESTAMP].title, _("Timestamp"), MAXLEN);
|
strncpy(headers_event[EV_TIMESTAMP].title, _("Timestamp"), MAXLEN);
|
||||||
|
|||||||
Reference in New Issue
Block a user