Friday, June 13, 2014

WebLogic Wrapper Scripts

Administrators with automation skill would perform than many admins. Requirement makes you to write automation scripts. I was working on Oracle Virtual Box, which is running SSH service. Hence I am able to connected thru PUTTy to the ubuntu Guest Linux server. By making Static IP configuration on the additional network adapter this was happen to possible.

 Everything going good! when I ran the WebLogic server from the PuTTY. It is working until when it is connected and alive. Once I went for break/Lunch the Windows system went to sleep then WebLogic server stopped due to PuTTY session inactive. To avoid this we can use the Wrapper start scripts.

 Idea behind the wrapper script/ psuedo code

  1. Using the script in background using &
  2. use the nohup -- no hungup to run the process even the PuTTY inactive or closed
  3. The log file generated by starting WebLogic server redirected to a separate file.
  4. The Standard error file also merged with standard output log 
  5. Display the tail command after doing the above
  6. Additionally you can add back up of old WebLogic file with a time stamp this can be applicable in Production environments.

Start WebLogic Admin Server with wrapper script

Here is the nohup usage sample:
$ nohup /domain/path/ &

No hangup

The nohup UNIX command only writes to nohup.out if the output is otherwise to the terminal. If you redirect the output of the command somewhere else - including /path/redirect or some casees you can use /dev/null - that's where it goes instead.

nohup >/path/redirect 2>&1   # doesn't create nohup.out

In modern bash and zsh (but not ksh) SHELLs you can shorten that to >&/path/redirect.

You can also use as follows:

nohup >/path/redirect 2>&1&

Applying the above ideas into the wrapper scripts you can write a sample script in your WebLogic Domain.

nohup bash -c "$DOMAIN_HOME/ 2>&1 >>$LOGPATH" &
echo .
echo "Starting admin server..."
echo "tail -f $LOGPATH"

Similarly you can write the wrapper codes for WebLogic Managed servers, NodeManager start scripts, so that your keep running your WebLogic related services without any hangs :)

 ii. Customized start managed server script

The above wrapper scripts there must inclusion of domain name recommended for non-production or multiple domains running on the same machines. There is a need to specify speparate standard output file path, if it is pre-production or Performance load testing environment you must also include GC logs path. Some of the WebLogic managed servers must include PRE_CLASSPATH that need to be processed before weblogic.jar in the CLASSPATH and some of the library jar files must be processed after the weblogic.jar, set them in a separate directories pre and post. Add them to CLASSPATH and it must be exported before or called.

The following start wrapper script saved as "" assuming that you might need few instance specific properties need to refer in script. 

# The managed server name as argument for this script
# File : 
# Usage: ./ mymanaged01  
export INSTANCE # not mandatory 
SOURCE=$(cd -P -- "$(dirname -- "$0")" && pwd -P)
echo tail -f $INST_HOME/$INSTANCE/logs/$INSTANCE.out

Here $INST_HOME is defined in the user profile script.

These customized start scripts for admin server and managed servers. In the script make a copy of the last server instance log to instance.out_bkp. Some times due to some panic situations servers might crashed, after monitoring you found that it happen so restarting server should not loss that lost logs. If you maintain the backup of logs file automatically before starting the instance, then you are saved with that backup log file for further analysis about that crash.

Here in the above script, Most of the UNIX environments your script could use "nohup" that means no hung up when the remote machine is accessed with ssh/Putty.
If you create this script in development/QA environment same script can be used for production because keeping it more portable with SDIR (source directory path).
Keep writing us your comments for betterment in this blog.

Saturday, April 5, 2014

Check system information for Capacity Planning

Working for migration projects requires lots of mesurements about the current running environment that gives you right way for predictions, estimations about the newly build environment. Thinking BIG!!! as architect for the enterprise applications, I started digging details of the system information of every machine I mean, every box and I need to prepare a table that will give all the details about the machine. This will make easy for deciding various things for WebLogic domain and its related environment.

Script Objective: Capacity Measurements

The Capacity plan is critical where a Senior WebLogic Administrator or Infrastructure Architect need to be more smarter to make wise decisions on allocated infrastructure. If you know the mesurements you can tailor your environment to give best predicated application environment platform. I had seen there is a legacy(old) shell script which gives the required information for mesurements! But it is not really robust and effective to give the desired outputs. Some of the modern CPU architectures changed and the processor information given expanded way. I thought better to renovate it in myway.  What do you say? Yes! right hmmm, I on top of it :).

The script must give outcome following factors
1. CPU Architecture
2. Num CPUs and  CPU Speed
3. Operating System Release version
4. Memory Sized (RAM)
5. Server platform
6. Virtual IP Addresses

First understood each line it was written in the script, then I refined those lines as per my thoughts and tried to get the effective output. bugging my friends if I'm not able to get desired outputs.

One Generic factor is that, I want to make this script must executed on both Solaris and also on the Redhat Linux operating environment. And finally reached the Victory!

I wish you could execute and share your experiances on HP-UX, AIX platforms as well that could help many other scripting fans.

Optimizing Script: Less pipes

Recently April 2014, While teaching UNIX & Linux Scripting for WebLogic Administrators revisited this script. The scripting can be more optimized when you use less pipes (|). The usage of two commands 'cat' and 'grep' on a text file here it is /proc/cpuinfo more costly why because the number of CPU cycle consumption is the factor, that why it is changed by Swetha here. The initial script used by Swetha on Ubuntu 12 got some of the info blank and non related outputs. Infact, Linux /proc/meminfo file provides you the RAM size in kb that is little incoveniance for us. Hence changed it to MB format also in this update.
Hope you are excited to see what is that script ? Here it is...

# FileName:
# Version            : 1.2
# Initial Drafted    : 2012/10
# Programmed         : Pavan Devarakonda
# Updated            : Swetha Reddy
# Description         : The bash utility script, display CPU, no of processors, Kernal version, RAM, Virtual IP, DNS
export PATH

case $os in
 nproc=`psrinfo |wc -l` ;
 prspeed=` psrinfo -v | grep -i Hz |awk '{print $6" " $7}'|uniq  `
 inet_addrs=`ifconfig -a |grep -i inet | awk '{print $2}' `
 mem=`prtconf |grep -i size`
 nproc=` grep -i processor /proc/cpuinfo |wc -l`
 prspeed=` grep -i model /proc/cpuinfo |grep -i hz |awk '{print $9 }' `
 inet_addrs=`ifconfig -a |grep -i inet | awk '{print $2}' |cut -d ":" -f 2`
mem=` grep -i MemTotal /proc/meminfo | awk '{print $2}' `

echo "Host name : $hname"
echo "Operating system is $os release `uname -r `"
echo "Number of CPU : $nproc with the speed of $prspeed"
echo "RAM Size: " $mem"mb"

for IPAddr in $inet_addrs
 if [ $IPAddr != "" ]
  if [ $os = "Linux" ]

   IPAddr_name=`nslookup $IPAddr|grep -i name |awk '{print $4}'`
   IPAddr_name=`nslookup $IPAddr|grep -i name |awk '{print $4}'`
  if [ ! -z ${IPAddr_name} ]; then
   echo $IPAddr === $IPAddr_name



After preparing my statistical table, reviewed and got an idea for include the disk space avaialble on every machine. That is the great result of good reviewer (my buddy did it!). So I need a disk size that I can get by df command but -lk is going to give in kilobytes, option -h works on Linux, Solaris 10 but summing up is issue so I took kilobytes and did convertions as follows:
df -lk | egrep -v "Filesystem|/proc|/dev/fd|swap|/home|/platform" | awk '
 { t += $2 }
 { u += $3}
 {GB2 = 1024*1024} END 
 { printf "%d of %d Gb in use.\n", u/GB2, t/GB2 }'
This command line excludes header, /proc, floppy, swap, user space and sun packages in /platform for Veritas.

35 of 130 Gb in use
Cheers! enjoy have fun in your work!
Good Reference:

Keep writing your innovative ideas, generic suggestions in comments!!

Blurb about this blog

Blurb about this blog

Essential Middleware Administration takes in-depth look at the fundamental relationship between Middleware and Operating Environment such as Solaris or Linux, HP-UX. Scope of this blog is associated with beginner or an experienced Middleware Team members, Middleware developer, Middleware Architects, you will be able to apply any of these automation scripts which are takeaways, because they are generalized it is like ready to use. Most of the experimented scripts are implemented in production environments.
You have any ideas for Contributing to a Middleware Admin? mail to me