/bin/custom/zzGetStatus.sh - Get process running status
/bin/custom/zzGetStatus.sh
#!/bin/sh
#!/bin/bash
# Daha fazla bilgi icin / For more information:
# Ahmet Faruk Biskinler
# www.biskinler.com
# Sample Run: sh bin/zzGetStatus.sh glassfish w
# Sample Output:
# Mon Feb 4 15:35:57 EET 2013
# !!!!!!!!! glassfish = CALISMIYOR !!!!!!!!!!!
# Mon Feb 4 15:26:49 EET 2013
# +++++++++ glassfish = CALISIYOR +++++++++++ Count: 2 Process No: 28026, 28034
BASEDIR=$(dirname $0)
source $BASEDIR/zzSettings.sh
zzThisFile=$0
arg=$1
zzWatchEnabled=$2
checkProcessName () {
process_name=$1
# echo "process_name: $process_name"
run=""
# process =`ps -ef --cols 2000 | grep "$process_name " | grep -v grep | grep -v $zzThisFile | sed 's/ */ /g' | cut -f 2 -d " " | sed ':a;N;$!ba;s/\n/, /g'`
run=`ps -ef --cols 2000 | grep -v grep | grep -v "$zzThisFile" | grep "$process_name"`
process=`ps -ef --cols 2000 | grep -v grep | grep -v "$zzThisFile" | grep "$process_name" | sed 's/ */ /g' | cut -f 2 -d " " | sed ':a;N;$!ba;s/\n/, /g'`
cnt=`ps -ef --cols 2000 | grep -v grep | grep -v "$zzThisFile" | grep -c "$process_name"`
# echo "file: $0";
# echo "run: $run";
# echo "process: $process";
# echo "cnt: $cnt";
if [ "$run" = "" ]
then
#echo -e ${RedF} " !!!!!!!!! $process_name = CALISMIYOR !!!!!!!!!!! "${Reset}
printf " ${RedF} !!!!!!!!! %-10s = CALISMIYOR !!!!!!!!!!! ${Reset}\n" $process_name
else
#echo -e ${GreenF}" +++++++++ $process_name = CALISIYOR +++++++++++ Count: $cnt Process No: $process "${Reset}
printf "${GreenF} +++++++++ %-10s = CALISIYOR +++++++++++ Count: %s Process No: %-20s ${Reset}\n" $process_name $cnt "$process"
fi
}
process () {
arg=$1
checkProcessName $arg
}
main () {
arg=$1
zzWatchEnabled=$2
if [ "$zzWatchEnabled" == "w" ] || [ "$zzWatchEnabled" == "watch" ] ; then
while [ true ]; do
clear
echo `date`
process $arg
sleep 1
done
else
process $arg
fi
}
#Main
echo "Args: $*"
main $arg $zzWatchEnabled
Created 8 years ago by Ahmet Faruk Bişkinler
Last Updated 8 years ago by Ahmet Faruk Bişkinler