"standby register/follow": provide primary node details for event notifications

For events generated by these commands, it may be useful to know details
of the primary node. This makes following additional parameters available
to event notification scripts:

- %p: node ID of the primary
- %a: node name of the primary
- %c: conninfo string for the primary

Implements GitHub #375
This commit is contained in:
Ian Barwick
2018-02-06 09:36:46 +09:00
parent da3a5ab1dc
commit 64035ef701
6 changed files with 117 additions and 57 deletions

View File

@@ -3265,14 +3265,14 @@ _create_event(PGconn *conn, t_configuration_options *options, int node_id, char
}
break;
case 'p':
/* %p: former primary id ("repmgr standby switchover") */
/* %p: primary id ("standby_switchover": former primary id) */
src_ptr++;
if (event_info->former_primary_id != UNKNOWN_NODE_ID)
if (event_info->node_id != UNKNOWN_NODE_ID)
{
PQExpBufferData node_id;
initPQExpBuffer(&node_id);
appendPQExpBuffer(&node_id,
"%i", event_info->former_primary_id);
"%i", event_info->node_id);
strlcpy(dst_ptr, node_id.data, end_ptr - dst_ptr);
dst_ptr += strlen(dst_ptr);
termPQExpBuffer(&node_id);