#!/bin/sh 

#
# show all the processess that are running for this instance
#

platform=`uname -s`

#
# ps format for each specific platform
#
if [ "$platform" = "OSF1" ]; then
  PS_CMD="/usr/bin/ps"
  FORMAT="-o user,pid,state,vsize,rssize,start,cputime,command"
elif [ "$platform" = "SunOS" ]; then
  PS_CMD="/usr/bin/ps"
  FORMAT="-o user,pid,s,vsz,rss,stime,time,comm"
elif [ "$platform" = "HP-UX" ]; then
  PS_CMD="/usr/bin/ps"
  # Special environment variable needed on HP-UX to support -o like other
  # platforms
  UNIX95=1
  export UNIX95
  FORMAT="-o user,pid,state,vsz,sz,stime,time,args"
elif [ "$platform" = "Linux" ]; then
  PS_CMD="/bin/ps"
  FORMAT="-w -eo user,pid,state,vsize,rssize,start,cputime,args"
elif [ "$platform" = "AIX" ]; then
  PS_CMD="/usr/bin/ps"
  # the -o option don't have all the fields we want, so use -fl
  # and awk the output instead.  Still we are missing te RSS field
  # since we can only get it through the berkley style u or v switch
  FORMAT="-fl | awk 'NF == 15 {printf \"%8s %5s %2s %5s %8s %6s %s\n\",\$3,\$4,\$2,\$10,\$12,\$14,\$15} NF == 16 {printf \"%8s %5s %2s %5s %5s%3s %6s %s\n\",\$3,\$4,\$2,\$10,\$12,\$13,\$15,\$16}'"
else
  FORMAT=
fi

pidlist=

# get pid from imta_pid program 
pidlist=`${MTABINDIR}/imta_pid`

pidlist=`echo $pidlist|sed 's/^ //'`
pidlist=`echo $pidlist|sed 's/ /,/g'`

if [ "$pidlist" != "" ]; then
  eval $PS_CMD -p "$pidlist" $FORMAT 
fi
