From: | Simon Brooke <simon(at)weft(dot)co(dot)uk> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Monitoring open connections |
Date: | 2000-07-06 10:01:37 |
Message-ID: | 39645901.AD57A9EB@weft.co.uk |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Herewith a little script to monitor open connections to Postgres
databases on Linux platforms; I wrote it while desperately debugging
some connection pooling code which was (but hopefully is not still)
breaking horribly. If it's useful to you, feel free to use or adapt.
-------------------------------- cut here
--------------------------------
#! /bin/bash
# Monitor number of open Postgres connections by user and database
# Simon Brooke <simon(at)jasmine(dot)org(dot)uk>, 6th July 2000
# Copyleft - no warranty, use it if you like it.
tmp=/tmp/wpg$$
bak=/tmp/wpg$$.bak
cat /dev/null > $tmp
cat /dev/null > $bak
while [ 1 -eq 1 ];
do
ps auxww |\
awk '$11 ~ "postgres" {printf( "User: %-8s; Database: %-8s\n", $13,
$14)}' > $tmp
cmp -s $tmp $bak
if [ $? -ne 0 ] # there's been a change
then
echo "" # new line
date; # report it
sort $tmp |\
uniq -c;
else
echo -n "." # I'm still alive
fi
mv $tmp $bak
sleep 10;
done
-------------------------------- cut here
--------------------------------
--
Simon Brooke, Technical Director, Weft Technology Ltd --
http://www.weft.co.uk/
the weft is not just what binds the web: it is what makes it a web
From | Date | Subject | |
---|---|---|---|
Next Message | Robert | 2000-07-06 10:21:31 | Two many databases... |
Previous Message | Stephane Bortzmeyer | 2000-07-06 09:34:52 | Re: Find all the dates in the calendar week? |