mos-eisley
Joined: 21 Mar 2007 Posts: 76 Location: Klarup (AAlborg), Demark
|
Posted: Fri Jun 29, 2007 12:19 am Post subject: Number of processes script |
|
|
We have made Our own process count script, as many we monitor are different java app on the save server, so we nedd 2 parameters to grep for. The re is room for improvemnt, like testing for 3 or 4 parameters first etc.
The input is 3 or 4 parameters, like:
java 1 10 weblogic.server
PROCNAME=$1
MIN=$2
MAX=$3
PROCNAME2=$4
if [ $PROCNAME2 = "" ]
then
PROCS=`ps -ef | grep "$PROCNAME" | grep -v "grep" | grep -v "$0" | grep -v $PPID`
else
PROCS=`ps -ef | grep "$PROCNAME" | grep "$PROCNAME2" | grep -v "grep" | grep -v "$0" | grep -v $PPID`
fi
NUMOFPROCS=`echo "$PROCS" | wc -l`
if [ $NUMOFPROCS -lt $MIN ] || [ $NUMOFPROCS -gt $MAX ]
then
RESULT="Bad"
else
RESULT="Ok"
fi
echo "ScriptRes:$RESULT:$NUMOFPROCS process(es)" |
|