Skip to content

Instantly share code, notes, and snippets.

@i0rek
Created Dec 19, 2012
Embed
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"
)[2].strip.to_i
end
while true
start = curr
sleep(1)
p curr - start
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment