Skip to content

Instantly share code, notes, and snippets.

@avenet
Last active August 29, 2015 13:58
Show Gist options
  • Save avenet/10115596 to your computer and use it in GitHub Desktop.
Save avenet/10115596 to your computer and use it in GitHub Desktop.
Realtime moitoring pgbouncer
#!/bin/bash
# -*- ENCODING: UTF-8 -*-
dbname="db_name"
username="db_user"
host="localhost"
port="6432"
available_commands=("lists" "pools" "servers")
if [[ $# -eq 0 ]] ; then
echo 'realtime_monitoring [lists][pools][servers]'
exit 0
fi
if [[ $# -eq 1 ]] ; then
for available_command in "${available_commands[@]}"
do
if [[ "$1" == "$available_command" ]]; then
while true; do
echo 'Showing '$1':'
psql -d $dbname -U $username -h $host -p $port -t -c 'show '$1 > .realtime_monitoring.tmp & cat .realtime_monitoring.tmp
sleep 3
clear
done
exit 0
fi
done
fi
echo 'realtime_monitoring [lists][pools][servers]'
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment