Monitoring open connections

Started by Simon Brookealmost 26 years ago2 messagesgeneral
Jump to latest
#1Simon Brooke
simon@weft.co.uk

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@jasmine.org.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

#2Jesus Aneiros
aneiros@jagua.cfg.sld.cu
In reply to: Simon Brooke (#1)
SQL DOMAINS in PostgreSQL

Hello,

I would like to know is there is anything like SQL DOMAINS in PostgreSQL?

TIA, Jesus.