[Melbourne-pm] Monitoring Starman apps

Sam Watkins sam at nipl.net
Wed Mar 14 05:33:02 PDT 2012

Toby Corkindale wrote:
> I could hack up a script that runs regularly, and counts the number
> of established connections to port 8080 or whatever, but.. surely
> this kind of thing has already been done?
> Any words of wisdom from the crowd?

I can offer words of dubious sanity and unknown utility...

Well, you could do it by touching and removing files (easy), sending
messages to a central tracker on a pipe, poking and peeking a shared
memory segment...

A shell hack would be easiest, and I guess it's good enough:

while true; do
	echo -n `date +%Y-%m-%d\ %H:%M:%S`"	"
	netstat -n | sed 's/  */\t/' | awk '$5 == "" { print }' | wc -l
	sleep 30

You could do similar in perl, perhaps a bit longer.  I'm comfortable
hacking things up in the shell.  Sometimes translate them to perl or C.

I found out today that perl in Linux can close 65536 unused file
descriptors in under 0.1 seconds, that's quite good really.  Forking and
managing long-running processes from a web server turned out to be a bit


More information about the Melbourne-pm mailing list