Monday, June 29, 2015

HTML format output for wlst scripts - Threadpool and server status



1. Download the HTML.py module from the following link http://www.decalage.info/python/html and place this in wlserver_10.3/common/wlst/modules

2. Below script will generate html file upon successful execution and it will be placed in the same directory from where you execute the script

#!/usr/bin/python
import sys
sys.path.insert(0,'/u01/app/oracle/product/fmw/wlserver_10.3/common/wlst/modules/HTML.py')
import HTML
tohtmlfile=open('ThreadPoolStatusHTMLFILE.html', 'w')

def connection():
    try:
        connect(wls_username,wls_password,url);
    except:
        "Unable to connect to the Admin Server, Please check!"
        
def Threadpoolstatus():
    tabledata=HTML.Table(header_row=['Server Name','Status','Completed Requests','Hogging Threads','Total Threads','Idle Threads','Pending','Queue Length','Throughput']);
    urldict={}
    serverConfig()
    serverlist=cmo.getServers()  # Getting Serverlist
    for svr in serverlist:
        cd("/Servers/"+svr.getName());
        urldict[svr.getName()]='t3://'+get('ListenAddress')+':'+str(get('ListenPort'));
    myKeyS = urldict.keys()
    myKeyS.sort()
    print "%7s %7s %7s %7s %7s %7s %7s %7s" % ('ServerName','compReq','hoggingThreads','totalThreads','idleThrds','pending','qLen','thruput');
    for name in myKeyS:
        connect("weblogic","Welcome1",url=urldict[name]);
        ServerName=str(name);
        cd('serverRuntime:/ThreadPoolRuntime/ThreadPoolRuntime/')
        statusstring = str(cmo.getHealthState())
        Status=statusstring.split(',')[1].split(':')[1]
        compReq = cmo.getCompletedRequestCount();
        hoggingThreads = cmo.getHoggingThreadCount();
        totalThreads = cmo.getExecuteThreadTotalCount();
        idleThrds = int(cmo.getExecuteThreadIdleCount());
        pending = cmo.getPendingUserRequestCount();
        qLen = cmo.getQueueLength();
        thruput = cmo.getThroughput();    
        print "%7s %7s %7d %10d %15d %10d %10d %10d" % (ServerName,compReq,hoggingThreads,totalThreads,idleThrds,pending,qLen,thruput)
        if idleThrds == 0 or Status <> 'HEALTH_OK':
            TPstatus = HTML.TableRow([ServerName,Status,compReq,hoggingThreads,totalThreads,idleThrds,pending,qLen,thruput],bgcolor='red')
        else:
            TPstatus = HTML.TableRow([ServerName,Status,compReq,hoggingThreads,totalThreads,idleThrds,pending,qLen,thruput],bgcolor='lime')
        tabledata.rows.append([TPstatus])

    myhtmlcode = tabledata
    print>>tohtmlfile, myhtmlcode

if __name__== "main":
    redirect('threadpoolstatus.log', 'false')
    connection()
    Threadpoolstatus() 

Sunday, June 21, 2015

Vagrant setup for Oracle SOA environment

Setup the Vagrant layer for SOA 11g on VirtualBox


  1.  Download the Centos7 box from below URL https://github.com/holms/vagrant-centos7-box/releases/download/7.1.1503.001/CentOS-7.1.1503-x86_64-netboot.box
  2.  create a directory for the centos and copy the box to this directory
  3.  Create a folder in your local machine for the shared folder which will host your SOA installations 
  4.  Open the command prompt and go to the centos folder which you created in the step # 3
  5.  enter vagrant init , this will create vagrantfile in the same directory, Open the file and delete all the lines and copy below code into it and save the file

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure(2) do |config|
  config.vm.box = "centos7.box"
  config.vm.hostname = "Centos7forOracleSOA"
  config.vm.network :private_network, ip: "192.168.33.101"
  config.vm.synced_folder "E:/Software", "/u01/app/software"
  config.vm.synced_folder "E:/virtualboxes/SOA_ENV_moc01", "/u01/app/env_01"
 config.vm.provider :virtualbox do |vb|
  vb.gui = true
  vb.customize ["modifyvm", :id, "--memory", "4096"]
  vb.customize ["modifyvm", :id, "--cpus", "2"]
 end
    config.vm.provision :shell, :path => "setup.sh"
end
 
6. Now create a setup.sh file in the same folder with the below code. 

 

echo "WELCOME TO VAGRANT, PLEASE WAIT WHILE WE UPDATE YOUR PROFILES AND THE OS..."
#yum -y update
yum -y install openssl*
echo "ADDING ORACLE USER AND DBA GROUP"
groupadd dba
grep dba /etc/group
useradd  -G dba -p `openssl passwd welcome1` oracle
echo 'oracle  ALL=(ALL:ALL) ALL' >> /etc/sudoers
#echo "MOUNTING THE SOFTWARE DIRECTORY"
#mount -t vboxsf -o uid=`id -u oracle`,gid=`getent group dba | cut -d: -f3` u01_software /u01/app/software
#mount -t vboxsf -o uid=`id -u oracle`,gid=`id -g dba` u01_software /u01/app/software
sudo -i
id oracle
chown -R oracle:dba /u01/app/env_01
ls -lhtr /u01/app/env_01
 
echo "Shell script SETUP.SH execution completed"

Now enter vagrant up this will bring your vagrant box with centos 7, oracle user will also be created with the password welcome1, you may change it as per your need.