#! /bin/sh
# $Header: vmps.sh,v 1.4 97/10/23 10:54:11 jgs Locked $
#
#bcpyrght
#***************************************************************************
#* Copyright 1993 - 1998 VERITAS Software Corporation, All Rights Reserved *
#***************************************************************************
#ecpyrght
#
# Script for Media Manager to determine what processes are running.
#

if [ -f /usr/openv/volmgr/version ]
then
	HARDWARE=`head -1 /usr/openv/volmgr/version | cut -f2 -d" "`
else
	echo "/usr/openv/volmgr/version not found"
	exit 1
fi

if [ "$HARDWARE" = "SUN4" ]
then
	processes=`/bin/ps -cax |
		egrep ' (ltid|avrd|opr|xopr|vmd|ts8d|tc8d|tl4d|tl8d|tl8cd|acsd|odld|vtld|vtlcd|tldd|tldcd|tc4d|tsdd|tsdtest|tldtest|vtltest|tl4test|tl8test|odltest|tc8test|ts8test|tc4test|vmadm|xvmadm|xdevadm|vmquery)$' |
		awk '{print $1}'`
	for process in $processes
	do
		/bin/ps -wuax$process | tail +2
	done

# Add any new processes to this list, not the one above.

	processes=`/bin/ps -cax |
		egrep ' (tpconfig|oprd|vmcheckx|vmcheckxxx|vmupdate|acscmd|tshd|tshtest|vmdb_dump|tlhd|tlhcd|tlhtest|tlmd|tlmtest|acstest)$' |
		awk '{print $1}'`
	for process in $processes
	do
		/bin/ps -wuax$process | tail +2
	done

elif [ "$HARDWARE" = "ALPHA" ]
then

# Do not need oprd in the ALPHA list, since the "opr" catches it.

	processes=`/bin/ps -ea |
		egrep '[ /](ltid|avrd|opr|xopr|vmd|ts8d|tc8d|tl4d|tl8d|tl8cd|acsd|odld|vtld|vtlcd|tldd|tldcd|tc4d|tsdd|tsdtest|tldtest|vtltest|tl4test|tl8test|odltest|tc8test|ts8test|tc4test|vmadm|xvmadm|xdevadm|vmquery)' |
		awk '{print $1}'`
	for process in $processes
	do
		/bin/ps wwuax$process | tail +2
	done

# Add any new processes to this list, not the one above.

	processes=`/bin/ps -ea |
		egrep '[ /](tpconfig|vmcheckxxx|vmupdate|acscmd|tshd|tshtest|vmdb_dump|tlhd|tlhcd|tlhtest|tlmd|tlmtest|acstest)' |
		awk '{print $1}'`
	for process in $processes
	do
		/bin/ps wwuax$process | tail +2
	done

elif [ "$HARDWARE" = "SGI" ]
then

	# 
	# ps(1) on IRIX 6.2 puts a space on the end of "ps -ea"
	# and IRIX 5.2 doesn't, so chop off the space if it's there.
	#

	processes=`/bin/ps -ea | sed 's/ $//' | \
		egrep ' (ltid|avrd|opr|xopr|vmd|ts8d|tc8d|tl4d|tl8d|tl8cd|acsd|odld|vtld|vtlcd|tldd|tldcd|tc4d|tsdd|tsdtest|tldtest|vtltest|tl4test|tl8test|odltest|tc8test|ts8test|tc4test|vmadm|xvmadm|xdevadm|vmquery)$' | \
		awk '{print "-p " $1}'`
	if test -n "$processes"
	then
		/bin/ps -f $processes | tail +2
	fi

# Add any new processes to this list, not the one above.
# Include 9-character versions of longer binaries due to ps -ea limit on IRIX 6.2
# Include 8-character versions of longer binaries due to ps -ea limit on IRIX 5.2

	processes=`/bin/ps -ea | sed 's/ $//' | \
		egrep ' (tpconfig|oprd|vmcheckx|vmcheckxx|vmcheckxxx|vmupdate|acscmd|tshd|tshtest|vmdb_dump|vmdb_dum|tlhd|tlhcd|tlhtest|tlmd|tlmtest|acstest)$' | \
		awk '{print "-p " $1}'`

	if test -n "$processes"
	then
		/bin/ps -f $processes | tail +2
	fi

else
	# Include 8-character versions of longer binaries due to ps -ea limit on Solaris
	processes=`/bin/ps -ea |
		egrep ' (ltid|avrd|opr|xopr|vmd|ts8d|tc8d|tl4d|tl8d|tl8cd|acsd|odld|vtld|vtlcd|tldd|tldcd|tc4d|tsdd|tsdtest|tldtest|vtltest|tl4test|tl8test|odltest|tc8test|ts8test|tc4test|vmadm|xvmadm|xdevadm|vmquery)$' |
		awk '{print "-p " $1}'`
	if test -n "$processes"
	then
		/bin/ps -f $processes | tail +2
	fi

# Add any new processes to this list, not the one above.

	# Include 8-character versions of longer binaries due to ps -ea limit on Solaris
	processes=`/bin/ps -ea |
		egrep ' (tpconfig|oprd|vmcheckx|vmcheckxx|vmcheckxxx|vmupdate|acscmd|tshd|tshtest|vmdb_dump|vmdb_dum|tlhd|tlhcd|tlhtest|tlmd|tlmtest|acstest)$' |
		awk '{print "-p " $1}'`

	if test -n "$processes"
	then
		/bin/ps -f $processes | tail +2
	fi
fi
