[pgpool-committers: 6193] pgpool: Adding new wd_cli utility

Muhammad Usama m.usama at gmail.com
Tue Sep 24 05:43:21 JST 2019


Adding new wd_cli utility

wd_cli makes it easier to integrate the external health check systems with the
Pgpool-II. It provides a very convenient and easy to use interface to interact with
watchdog and perform health check related node operations.

For example:
If some external health-check system monitoring the health of the watchdog
cluster detects the remote node failure. It can use wd_cli utility to inform
Pgpool-II about that node failure

    $wd_cli  --inform DEAD -N 'Remote watchdog name'  -p 9001 -m 'node 1 failed'

Similarly when the node becomes reachable again

    $wd_cli  --inform ALIVE -N 'Remote watchdog name'  -p 9001 -m 'node 1 found'

This utility can also be used to get the live information of all nodes.

    $wd_cli -f simple_conf/watchdog/pgpool_wd1.conf --info -v --all

    Total Watchdog nodes configured for lifecheck:    2
    *****************
    Node ID:           0
    Node Status code   4
    Node Status:       MASTER
    Node Name:         localhost:9991 Linux localhost.localdomain
    Node Host:         localhost
    Node WD Port:      9001
    Node Pgpool Port:  9991

    Node ID:           1
    Node Status code   7
    Node Status:       STANDBY
    Node Name:         localhost:9992 Linux localhost.localdomain
    Node Host:         localhost
    Node WD Port:      9002
    Node Pgpool Port:  9992

wd_cli provides many options for node search criteria.
See wd_cli --help for complete list of options.

The commit also re-arrange the code related to socket communication and
watchdog IPC commands and separates the internal and external watchdog
commands to make the code structure more modular.

The regression tests and documentation updates are not part of this commit
and will be taken care of separately.

Branch
------
master

Details
-------
https://git.postgresql.org/gitweb?p=pgpool2.git;a=commitdiff;h=6156534a7073bc6446b9bcccc1ed4a846fa82f34

Modified Files
--------------
configure                                          |   3 +-
configure.ac                                       |   2 +-
src/Makefile.am                                    |   1 +
src/Makefile.in                                    |  17 +-
src/include/utils/fe_ports.h                       |  13 +-
src/include/utils/json_writer.h                    |   2 +-
src/include/utils/pool_stream.h                    |   7 +-
src/include/utils/socket_stream.h                  |  36 +
src/include/watchdog/wd_commands.h                 |  66 ++
.../{wd_ipc_commands.h => wd_internal_commands.h}  |  66 +-
src/include/watchdog/wd_ipc_conn.h                 |  57 ++
src/include/watchdog/wd_ipc_defines.h              |   2 +-
src/include/watchdog/wd_json_data.h                |  14 -
src/include/watchdog/wd_lifecheck.h                |   4 +-
src/main/pgpool_main.c                             |  10 +-
src/pcp_con/pcp_worker.c                           |   4 +-
src/pcp_con/recovery.c                             |   2 +-
src/protocol/child.c                               |  16 +-
src/protocol/pool_connection_pool.c                |   4 +-
src/protocol/pool_process_query.c                  |   8 +-
src/tools/Makefile.am                              |   7 +-
src/tools/Makefile.in                              |   7 +-
src/tools/watchdog/Makefile.am                     |  74 ++
src/tools/watchdog/Makefile.in                     | 771 +++++++++++++++++++++
src/tools/watchdog/wd_cli.c                        | 749 ++++++++++++++++++++
src/utils/pool_stream.c                            | 138 +---
src/utils/psprintf.c                               |   4 +-
src/utils/socket_stream.c                          | 195 ++++++
src/watchdog/Makefile.am                           |   2 +
src/watchdog/Makefile.in                           |   3 +
src/watchdog/watchdog.c                            |  14 +-
src/watchdog/wd_commands.c                         | 757 ++++----------------
src/watchdog/wd_internal_commands.c                | 496 +++++++++++++
src/watchdog/wd_ipc_conn.c                         | 282 ++++++++
src/watchdog/wd_json_data.c                        |  86 ---
src/watchdog/wd_lifecheck.c                        |  12 +-
36 files changed, 2946 insertions(+), 985 deletions(-)



More information about the pgpool-committers mailing list