2010-05-12 13:27:55 +00:00
|
|
|
#!/bin/sh
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
# ========= |
|
2013-12-11 16:09:41 +00:00
|
|
|
# \\ / F ield | foam-extend: Open Source CFD
|
2016-06-20 15:00:40 +00:00
|
|
|
# \\ / O peration | Version: 4.0
|
|
|
|
# \\ / A nd | Web: http://www.foam-extend.org
|
|
|
|
# \\/ M anipulation | For copyright notice see file Copyright
|
2011-01-13 17:21:49 +00:00
|
|
|
#------------------------------------------------------------------------------
|
2010-05-12 13:27:55 +00:00
|
|
|
# License
|
2013-12-11 16:09:41 +00:00
|
|
|
# This file is part of foam-extend.
|
2010-05-12 13:27:55 +00:00
|
|
|
#
|
2013-12-11 16:09:41 +00:00
|
|
|
# foam-extend is free software: you can redistribute it and/or modify it
|
2010-05-12 13:27:55 +00:00
|
|
|
# under the terms of the GNU General Public License as published by the
|
2013-12-11 16:09:41 +00:00
|
|
|
# Free Software Foundation, either version 3 of the License, or (at your
|
2010-05-12 13:27:55 +00:00
|
|
|
# option) any later version.
|
|
|
|
#
|
2013-12-11 16:09:41 +00:00
|
|
|
# foam-extend is distributed in the hope that it will be useful, but
|
|
|
|
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
# General Public License for more details.
|
2010-05-12 13:27:55 +00:00
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
2013-12-11 16:09:41 +00:00
|
|
|
# along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
|
2010-05-12 13:27:55 +00:00
|
|
|
#
|
|
|
|
# Script
|
|
|
|
# foamProcessInfo
|
|
|
|
#
|
|
|
|
# Description
|
|
|
|
# Collects user's process status information into file. File contains one
|
|
|
|
# line per process:
|
|
|
|
#
|
|
|
|
# pid state command
|
|
|
|
#
|
|
|
|
# state is one of 'RUNN' 'SUSP' 'OTHR',
|
|
|
|
# command is the argv[0]
|
|
|
|
#
|
|
|
|
# Tested on Linux,IRIX,SunOS
|
|
|
|
#
|
2011-01-13 17:21:49 +00:00
|
|
|
#------------------------------------------------------------------------------
|
2010-05-12 13:27:55 +00:00
|
|
|
|
|
|
|
PROGNAME=`basename $0`
|
|
|
|
TMPFILE=/tmp/${PROGNAME}$$.tmp
|
|
|
|
AWKFILE=/tmp/${PROGNAME}$$.awk
|
|
|
|
|
2010-05-27 10:48:11 +00:00
|
|
|
if [ `uname -s` = Linux ]
|
|
|
|
then
|
|
|
|
ECHO='echo -e'
|
2010-05-12 13:27:55 +00:00
|
|
|
else
|
2010-05-27 10:48:11 +00:00
|
|
|
ECHO='echo'
|
2010-05-12 13:27:55 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
2010-05-27 10:48:11 +00:00
|
|
|
if [ $# -ne 1 ]
|
|
|
|
then
|
2010-05-12 13:27:55 +00:00
|
|
|
echo "Error : $PROGNAME : insufficient arguments" 1>&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
outputFile=$1
|
|
|
|
rm -f $outputFile
|
|
|
|
|
|
|
|
|
|
|
|
ARCH=`uname`
|
|
|
|
|
|
|
|
#-- Force standards behaving ps
|
|
|
|
# Get info on all $USER processes
|
|
|
|
case $ARCH in
|
|
|
|
HP-UX*)
|
|
|
|
UNIX95=a; export UNIX95
|
|
|
|
;;
|
|
|
|
IRIX*)
|
|
|
|
_XPG=1; export _XPG
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
case $ARCH in
|
|
|
|
SunOS*)
|
|
|
|
ps -e -o 'pid,f,s,comm' > $TMPFILE
|
|
|
|
;;
|
|
|
|
HP-UX*)
|
|
|
|
ps -e -o 'pid,flags,state,comm' > $TMPFILE
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
ps -e -o 'pid,flag,state,comm' > $TMPFILE
|
|
|
|
esac
|
|
|
|
|
|
|
|
|
|
|
|
rm -f $AWKFILE; touch $AWKFILE
|
|
|
|
case $ARCH in
|
|
|
|
IRIX*)
|
|
|
|
echo '($2 == 40) || ($3 == "T") {print $1 " SUSP // " $4; next}' >> $AWKFILE
|
|
|
|
echo '($3 == "R") || ($3 == "S") || ($3 == "D") {print $1 " RUNN // " $4; next}' >> $AWKFILE
|
|
|
|
echo '{print $1 " OTHR // " $4}' >> $AWKFILE
|
|
|
|
;;
|
|
|
|
Linux*)
|
|
|
|
echo '($3 == "T") {print $1 " SUSP // " $4; next}' >> $AWKFILE
|
|
|
|
echo '($3 == "R") || ($3 == "S") || ($3 == "D") {print $1 " RUNN // " $4; next}' >> $AWKFILE
|
|
|
|
echo '{print $1 " OTHR // " $4}' >> $AWKFILE
|
|
|
|
;;
|
|
|
|
SunOS*)
|
|
|
|
echo '($3 == "T") {print $1 " SUSP // " $4; next}' >> $AWKFILE
|
|
|
|
echo '($3 == "O") || ($3 == "S") || ($3 == "R") {print $1 " RUNN // " $4; next}' >> $AWKFILE
|
|
|
|
echo '{print $1 " OTHR // " $4}' >> $AWKFILE
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Error : $PROGNAME : unsupported achitecture $ARCH"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
$ECHO "(" > $outputFile
|
|
|
|
tail +2 $TMPFILE | awk -f $AWKFILE >> $outputFile
|
|
|
|
$ECHO ")" >> $outputFile
|
|
|
|
|
|
|
|
rm -f $TMPFILE $AWKFILE
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------------
|