Script to check weblogic managed server status

<pre>FULL_HOST_NAME=`hostname -f`
PORT="YOURPORT"
serverStateAll="serverStateAll.py"
rm -f $serverStateAll

printf "username = 'weblogic' \n" >> $serverStateAll;
printf "password = 'welcome1' \n" >> $serverStateAll;
printf "URL='t3://$FULL_HOST_NAME:$PORT' \n" >> $serverStateAll;
printf " \n" >> $serverStateAll;
printf "connect(username,password,URL) \n" >> $serverStateAll;
printf "domainConfig() \n" >> $serverStateAll;
printf "serverList=cmo.getServers(); \n" >> $serverStateAll;
printf "domainRuntime() \n" >> $serverStateAll;
printf "cd('/ServerLifeCycleRuntimes/') \n" >> $serverStateAll;
printf "\n" >> $serverStateAll;
printf "print 'Servers Status on ' +URL \n" >> $serverStateAll;
printf "for server in serverList: \n" >> $serverStateAll;
printf "        name=server.getName() \n" >> $serverStateAll;
printf "        cd(name) \n" >> $serverStateAll;
printf "        serverState=cmo.getState() \n" >> $serverStateAll;
printf "        if serverState!='RUNNING': \n" >> $serverStateAll;
printf "                print '**** FoundBadServer ****' \n" >> $serverStateAll;
printf "                print '***Server: '+ name +'-'+serverState \n" >> $serverStateAll;
printf "                break \n" >> $serverStateAll;
printf "        print '***Server: '+ name +'-'+serverState \n" >> $serverStateAll;
printf "        cd('..') \n" >> $serverStateAll;

printf "LOGFILE: $serverStateAll (type=serverStateAll_py)\n";
wlsstatus=`java -cp $FMW_HOME/wlserver_10.3/server/lib/weblogic.jar  weblogic.WLST $serverStateAll`
printf "$wlsstatus \n" ;
if [[ "$wlsstatus" =~ "FoundBadServer" ]]; then
    printf "It has managed server NOT in RUNNING state! \n" ;
	printf "Logon http://$FULL_HOST_NAME:$PORT/console to check... \n";
	exit 1;
fi

if [[ "$wlsstatus" =~ "Connection refused" ]]; then
    printf "Adadmin is DOWN! \n" ;
    exit 1;
fi

printf "All mid-tier services (managed servers) are up and RUNNING \n" ;
exit 0;