Skip to content

Instantly share code, notes, and snippets.

Created Dec 19, 2012
What would you like to do?
# number postgres connections
sudo ps -ef | grep postgres | wc -l
# disk usage
iostat 5
# memory
mpstat 5
# slow req per second
tail -f /var/log/postgresql/postgresql-9.1-main.log | perl -e 'while (<>) {$l++;if (time > $e) {$e=time;print "$l\n";$l=0}}'
# slow query duration
tail -f /var/log/postgresql/postgresql-9.1-main.log | cut -d ' ' -f 7
# req per second
def curr
`psql -c 'SELECT SUM(xact_commit) FROM pg_stat_database;' 2> /dev/null`.split("\n"
while true
start = curr
p curr - start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment