Skip to content

Instantly share code, notes, and snippets.

@miohtama
Created December 2, 2021 17:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save miohtama/bb5bef5e4751dd2465b44b47d8d01e8f to your computer and use it in GitHub Desktop.
Save miohtama/bb5bef5e4751dd2465b44b47d8d01e8f to your computer and use it in GitHub Desktop.
Bash script for pgmetrics + pgdash reporting loop
#!/bin/bash
#
# Monitor loop for TimescaleDB using pgdash
# - TimescaleDB runs in a Docker, exposed over TCP/IP socket 127.0.0.1:5555
# - pgdash SaaS offering used https://pgdash.io
# - run the sample collection loop every 30 seconds
#
#
set -e
set -x
# read secrets
source ~/secrets.env
# Give postgresql password to pgmetrics
export PGPASSWORD=$POSTGRES_PASSWORD
SERVER_NAME=myserver
while true ; do
./pgmetrics_1.12.0_linux_amd64/pgmetrics -f json -h 127.0.0.1 -p 5555 -U postgres | \
./pgdash_1.8.0_linux_amd64/pgdash -a $PGDASH_API_KEY report $SERVER_NAME
sleep 30
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment