mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-26 16:46:28 +00:00
Ensure "repmgr cluster events" can filter on node name
This commit is contained in:
@@ -50,7 +50,12 @@ static int build_cluster_matrix(t_node_matrix_rec ***matrix_rec_dest, int *name
|
|||||||
static int build_cluster_crosscheck(t_node_status_cube ***cube_dest, int *name_length);
|
static int build_cluster_crosscheck(t_node_status_cube ***cube_dest, int *name_length);
|
||||||
static void cube_set_node_status(t_node_status_cube **cube, int n, int node_id, int matrix_node_id, int connection_node_id, int connection_status);
|
static void cube_set_node_status(t_node_status_cube **cube, int n, int node_id, int matrix_node_id, int connection_node_id, int connection_status);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* CLUSTER SHOW
|
||||||
|
*
|
||||||
|
* Parameters:
|
||||||
|
* --csv
|
||||||
|
*/
|
||||||
void
|
void
|
||||||
do_cluster_show(void)
|
do_cluster_show(void)
|
||||||
{
|
{
|
||||||
@@ -330,7 +335,7 @@ do_cluster_show(void)
|
|||||||
* Parameters:
|
* Parameters:
|
||||||
* --limit[=20]
|
* --limit[=20]
|
||||||
* --all
|
* --all
|
||||||
* --node_[id|name]
|
* --node-[id|name]
|
||||||
* --event
|
* --event
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -349,16 +354,35 @@ do_cluster_event(void)
|
|||||||
initPQExpBuffer(&where_clause);
|
initPQExpBuffer(&where_clause);
|
||||||
|
|
||||||
appendPQExpBuffer(&query,
|
appendPQExpBuffer(&query,
|
||||||
" SELECT node_id, event, successful, \n"
|
" SELECT e.node_id, e.event, e.successful, \n"
|
||||||
" TO_CHAR(event_timestamp, 'YYYY-MM-DD HH24:MI:SS') AS timestamp, \n"
|
" TO_CHAR(e.event_timestamp, 'YYYY-MM-DD HH24:MI:SS') AS timestamp, \n"
|
||||||
" details \n"
|
" e.details \n"
|
||||||
" FROM repmgr.events");
|
" FROM repmgr.events e");
|
||||||
|
|
||||||
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);
|
"node_id=%i", runtime_options.node_id);
|
||||||
}
|
}
|
||||||
|
else if (runtime_options.node_name[0] != '\0')
|
||||||
|
{
|
||||||
|
char *escaped = escape_string(conn, runtime_options.node_name);
|
||||||
|
|
||||||
|
if (escaped == NULL)
|
||||||
|
{
|
||||||
|
log_error(_("unable to escape value provided for node name"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
appendPQExpBuffer(&query,
|
||||||
|
" INNER JOIN repmgr.nodes n ON e.node_id = n.node_id ");
|
||||||
|
append_where_clause(&where_clause,
|
||||||
|
"n.node_name='%s'",
|
||||||
|
escaped);
|
||||||
|
pfree(escaped);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (runtime_options.event[0] != '\0')
|
if (runtime_options.event[0] != '\0')
|
||||||
{
|
{
|
||||||
@@ -371,7 +395,7 @@ do_cluster_event(void)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
append_where_clause(&where_clause,
|
append_where_clause(&where_clause,
|
||||||
"event='%s'",
|
"e.event='%s'",
|
||||||
escaped);
|
escaped);
|
||||||
pfree(escaped);
|
pfree(escaped);
|
||||||
}
|
}
|
||||||
@@ -381,7 +405,7 @@ do_cluster_event(void)
|
|||||||
where_clause.data);
|
where_clause.data);
|
||||||
|
|
||||||
appendPQExpBuffer(&query,
|
appendPQExpBuffer(&query,
|
||||||
" ORDER BY event_timestamp DESC");
|
" ORDER BY e.event_timestamp DESC");
|
||||||
|
|
||||||
if (runtime_options.all == false && runtime_options.limit > 0)
|
if (runtime_options.all == false && runtime_options.limit > 0)
|
||||||
{
|
{
|
||||||
@@ -483,6 +507,8 @@ do_cluster_event(void)
|
|||||||
PQclear(res);
|
PQclear(res);
|
||||||
|
|
||||||
PQfinish(conn);
|
PQfinish(conn);
|
||||||
|
|
||||||
|
puts("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1199,6 +1225,9 @@ do_cluster_help(void)
|
|||||||
printf(_(" --limit maximum number of events to display (default: %i)\n"), CLUSTER_EVENT_LIMIT);
|
printf(_(" --limit maximum number of events to display (default: %i)\n"), CLUSTER_EVENT_LIMIT);
|
||||||
printf(_(" --all display all events (overrides --limit)\n"));
|
printf(_(" --all display all events (overrides --limit)\n"));
|
||||||
printf(_(" --event filter specific event\n"));
|
printf(_(" --event filter specific event\n"));
|
||||||
|
printf(_(" --node-id restrict entries to node with this ID\n"));
|
||||||
|
printf(_(" --node-name restrict entries to node with this name\n"));
|
||||||
|
|
||||||
puts("");
|
puts("");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user