Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hilli/pg-replication-lag
PostgreSQL replication lag - Tells you the time lag between a PostgreSQL master and slave.
https://github.com/hilli/pg-replication-lag
Last synced: about 13 hours ago
JSON representation
PostgreSQL replication lag - Tells you the time lag between a PostgreSQL master and slave.
- Host: GitHub
- URL: https://github.com/hilli/pg-replication-lag
- Owner: hilli
- Created: 2018-09-30T15:30:14.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2018-09-30T20:52:13.000Z (about 6 years ago)
- Last Synced: 2024-06-20T09:21:05.442Z (5 months ago)
- Language: Go
- Size: 7.81 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# pg-replication-lag
A command to let you get the _timed_ lag between a PostgreSQL master/slave replica set. PostgreSQL has queries to let you get the bytes difference between the master and the replica - This will let you get the amout of time there is between the masters writes and the replica has save the data to disk.
## Installation
```
go get github.com/hilli/pg-replication-lag
```Or checkout the source and do a `build` (for your current platform) or optionally `make build-linux` (to get a Linux binary):
```
git clone https://github.com/hilli/pg-replication-lag.git
make deps
make build
```## Getting started
Copy `pg-replication-lag.yaml.sample` to `pg-replication-lag.yaml`.```
curl https://raw.githubusercontent.com/hilli/pg-replication-lag/master/pg-replication-lag.yaml.sample > pg-replication-lag.yaml
```Fill out `pg-replication-lag.yaml` with some sane values. The values should be self explanatory but it is probably worth noting that, since it is a replica, the username and password is the same. `max_lag_before_exit` is the time to maximal wait before exiting - If your replication is broken, we won't wait forever.
Run `./pg-replication-lag` or use on of the flags as well:
```
$ ./pg-replication-lag --help
Usage of ./pg-replication-lag:
-config string
Path to YAML config file (default "./pg-replication-lag.yaml")
-verbose
Add verbosity to the outputDocumentation at https://github.com/hilli/pg-replication-lag
```It will look in the _current_ directory for a config file. If thats not where you keep it, specify it with `-config` flag.
### If all works out nicely
```
$ ./pg-replication-lag_linux_amd64
{ "postgresql-replication-lag": { "time": "23.346179ms", "bytes": "0" } }
```## Error cases
### If replication fails```
$ ./pg-replication-lag_linux_amd64
pg-replication-lag: 2018/09/30 16:10:01 BAILING, waited too long (1m0.089542009s, 26716448 bytes behind)
panic: BAILING, waited too long (1m0.089542009s, 26716448 bytes behind)
```### If DB connection fails
```
$ ./pg-replication-lag_linux_amd64
pg-replication-lag: 2018/09/30 16:23:16 Database error: dial tcp 127.0.0.1:5432: connect: connection refused
panic: Database error: dial tcp 127.0.0.1:5432: connect: connection refused
```exits with code 2 in all cases.