Make it possible to provide optional thresholds for replicas.
Improve address handling, enforce square brackets for the IPv6 addresses
(per RFC3986).
Provide much more details in the help section.
On passing, reorganize code and move address handling into own function.
- add extended Usage message
- add possibility to specify several replicas via comma
- add possibility to specify lag in KB and MB
- pretty-print lag as KB, MB, GB instead of plain bytes
Now it is not neccessary to comment out checks when servers exchange
their roles during switchover.
Also cascading replicas can be monitored now, we're checking lag between
current cascaded replica and it's remote.
Details:
- for MASTER (can be cascading replica) use either
pg_current_wal_lsn() or pg_last_wal_receive_lsn()
- for REPLICA use either pg_last_wal_receive_lsn()
or return NULL in cases database is open (not in replicaiton)
- trim trailing newline via `tr -d '\n'`
Adjust `check_replication_lag.pl` script to work with 10+ databases.
Script now checks database version (extra query to master) and
uses proper funciton calls, as appropriate.
Get rid of previously created `check_replication_lag_wal.pl` script.