zAllStatus.sh
zAllStatus.sh
#!/bin/sh
Escape="\033";
Reset="${Escape}[0m";
BlackF="${Escape}[30m";
RedF="${Escape}[31m";
GreenF="${Escape}[32m";
YellowF="${Escape}[33m";
checkProcessName () {
process_name=$1
zCommand="sudo service $process_name status"
zRun=`$zCommand`
zCheckUserGroupCommand="ls -al /etc/init.d/$process_name"
zCheckUserGroup=`$zCheckUserGroupCommand`
#echo $?
#echo $zCommand
if [[ "$zRun" = *"is running"* ]]
then
printf "${GreenF} $zCommand ${Reset}\n"
printf "${GreenF} $zRun ${Reset}\n"
elif [[ "$zRun" = *"is not running."* ]]
then
printf "${RedF} $zCommand ${Reset}\n"
printf "${RedF} $zRun ${Reset}\n"
else
printf "${YellowF} $zCheckUserGroup ${Reset}\n"
printf "${YellowF} $zCommand ${Reset}\n"
printf "${YellowF} $zRun ${Reset}\n"
fi
}
checkProcessNameNodeJS () {
process_name=$1
zCommand="sudo service $process_name status"
echo $zCommand
$zCommand
}
printf "${GreenF} \n\n########################## Java Applications ####################### \n\n ${Reset}\n"
zFolder=`grep -r -H 'java' /etc/init.d/* | cut -d: -f1 | uniq`
for process_name in $zFolder ; do
echo "______________________________________________________________"
zFind="\/etc\/init.d\/"
zReplace=""
zServiceName=$(echo $process_name | sed -e "s/$zFind/$zReplace/g")
checkProcessName $zServiceName
done
printf "${GreenF} \n\n########################## NodeJS Applications ####################### \n\n ${Reset}\n"
zFolder=`grep -r -H 'APP' /etc/init.d/* | cut -d: -f1 | uniq`
for process_name in $zFolder ; do
echo "______________________________________________________________"
zFind="\/etc\/init.d\/"
zReplace=""
zServiceName=$(echo $process_name | sed -e "s/$zFind/$zReplace/g")
checkProcessNameNodeJS $zServiceName
done
printf "${GreenF} \n\n########################## Other Applications ####################### \n\n ${Reset}\n"
zFolder="nginx mongod consul"
for process_name in $zFolder ; do
echo "______________________________________________________________"
zFind="\/etc\/init.d\/"
zReplace=""
zServiceName=$(echo $process_name | sed -e "s/$zFind/$zReplace/g")
checkProcessName $zServiceName
done
Created 7 years ago by Ahmet Faruk Bişkinler
Last Updated 7 years ago by Ahmet Faruk Bişkinler