Basic Shell Script to Monitor Weblogic Server status
Below is the basic shell scripting which will monitor admin server and managed server status based on configured port numbers and sends a alert mail to admin if server is in other than running state. In this script weblogic commad line utility weblogic.admin is used. You can shcedule a cronjob for frequent monitoring depending on the environment.
———————————————————————————————
set -x
export CLASSPATH=”/wl_home/server/lib/weblogic.jar”
declare -a Port=( 8003 7072 8201 )
declare -a ServerState[]
declare -a ServerName[]
declare -a ObjectName[]
i=”0″
IP=10.17.19.200
while [ $i -lt 5 ]
do
ServerState[$i]=`java weblogic.Admin -url $IP:${Port[$i]} -username weblogic -password weblogic GET -pretty -type ServerRuntime -property State |grep -i State |awk ‘{print $2}’`
ObjectName[$i]=`java weblogic.Admin -url $IP:${Port[$i]} -username weblogic -password password GET -pretty -type JVMRuntime -property ObjectName |grep -i ObjectName |awk ‘{print $2}’`
if [ "${ServerState[$i]}” != “RUNNING” ] ;
then
mailx -s ” Weblogic Server Staus- $IP ” kartheek@solaris.com<
Weblogic Managed server ${Port[$i]} is in SHUTDOWN state
EOF
fi
i=`expr $i + 1`
done