#!/bin/sh
#
# $Id$
#
# check current status of ser: print running processes and
# -- if in possession of MySql password -- dump USRLOC database
# as well

USER_COLUMN='user'
SUBSCRIBER_COLUMN='user_id'
QUERY='select location.*, subscriber.email_address from location, subscriber where subscriber.user_id=location.user'

# username and password of a valid MySql user, preferably only with read-only
# privilegs
USER="serro"
PASSWORD="47serro11"

if [ $# -gt 1 ] ; then
	echo "usage: $0 [username]"
	exit 1
elif [ $# -eq 1 ] ; then
	QUERY="$QUERY AND subscriber.user_id='$1' "
fi

PIDS=`ps --no-headers -o "pid" -C sr`
for i in $PIDS ;  do
	ps -o "pid,user,group,euser,egroup,fuser,fgroup,args" $i
	echo "WD: `ls -ld /proc/$i/cwd`"
done

#ps  -wwwwww -o "drs,pid,user,group,euser,egroup,fuser,fgroup,args" -C sr 


mysql -h dbhost -u $USER "-p$PASSWORD" -e "$QUERY ;" csps107