Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
aswinkarthik committed Feb 26, 2019
1 parent b4b5f42 commit 61f173f
Showing 1 changed file with 37 additions and 10 deletions.
47 changes: 37 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,47 @@

`pg-ping` is a command line utility to continously ping your postgres. This is useful to check if there is downtime when doing changes to your postgres instance.

## Configuration
## Installation

Using Homebrew

```bash
export PGPING_USERNAME=your-username
export PGPING_PASSWORD=your-password
export PGPING_HOST=your-host
export PGPING_DBNAME=your-dbname
export PGPING_QUERY=your-query # default is select 1
export PGPING_FREQUENCYINMS=300 # default is 1 second
brew tap thecasualcoder/stable
brew install pg-ping
```

## Usage

```bash
$ pg-ping
NAME:
pg-ping - Ping your postgres continously

USAGE:
pg-ping [global options] command [command options] [arguments...]

VERSION:
v0.1.0

COMMANDS:
help, h Shows a list of commands or help for one command

GLOBAL OPTIONS:
--once Ping only once and quit [$PGPING_ONCE]
--debug Print debug logs [$PGPING_DEBUG]
--username value, -U value Username to connect to postgres [$PGPING_USERNAME]
--password value, -p value Password to connect to postgres [$PGPING_PASSWORD]
--host value, -h value Host of postgres server [$PGPING_HOST]
--dbname value, -d value DBName to connect to [$PGPING_DBNAME]
--frequency value, -f value Frequency to ping (default: 0) [$PGPING_FREQUENCY_IN_MS]
--query value, -c value Query to run (default: "SELECT 1") [$PGPING_QUERY]
--help
--version, -v print the version
```

## Example

```bash
$ pg-ping -U myuser -h myhost -d mydb -c 'SELECT 1'
{"Value":"1","TimeTakenInMS":0.408563,"Failed":false,"FailureMessage":""}
{"Value":"1","TimeTakenInMS":0.46392500000000003,"Failed":false,"FailureMessage":""}
{"Value":"","TimeTakenInMS":0.634099,"Failed":true,"FailureMessage":"dial tcp 10.134.125.111:5432: connect: connection refused"} # Downtime
Expand All @@ -26,8 +52,9 @@ $ pg-ping
{"Value":"1","TimeTakenInMS":0.429533,"Failed":false,"FailureMessage":""}
```

## Build
## Build locally

```
go build -o pg-ping main.go
git clone https://github.com/thecasualcoder/pg-ping.git
make compile
```

0 comments on commit 61f173f

Please sign in to comment.