Friday, October 22, 2010

Monitor your Weblogic Servers

As we have running SOA Suite, Service Bus or any other application on top of weblogic. You are intereseted in the behavior of the server. I have created a script that reads for all managed servers the following information:
  • Memory usage
  • Datasource connections
  • HTTP Session
  • Threads

The script is straight forward and appends each time a line in a result file. This can be used for furthe analyzing.

The property file:
# 
# Properties file
#
username=weblogic
password=welcome1
adminurl=t3://node1.vijfhuizen.com:7001
domain=MyDomain

#
# Show Sessions
#
showsession=true
appname=HelloWorldApplication
webname=/helloworld

# Show threads
showthreads=true

# Show memory
showmemory=true

# Show datasources
showdatasources=true

#
# Result file
#
appendresultsto=/tmp/wlmon.csv
The WLST script:
import traceback
import getopt

from java.util import Calendar

import getopt
import sys

# simulate command line invocation

propFile= file('wlsmon.properties', 'r')
propDict= dict()
for propLine in propFile:
  propDef= propLine.strip()
  if len(propDef) == 0:
        continue
  if propDef[0] in ( '!', '#' ):
        continue
  punctuation= [ propDef.find(c) for c in ':= ' ] + [ len(propDef) ]
  found= min( [ pos for pos in punctuation if pos != -1 ] )
  name= propDef[:found].rstrip()
  value= propDef[found:].lstrip(":= ").rstrip()
  propDict[name]= value

propFile.close()

# Connection properties
username = propDict['username']
password = propDict['password']
adminurl = propDict['adminurl']
domain   = propDict['domain']
appname  = propDict['appname']
webname  = propDict['webname']

# Switches
showsession     = propDict['showsession']
showthreads     = propDict['showthreads']
showmemory      = propDict['showmemory']
showdatasources = propDict['showdatasources']

# Open file in append mode
appendresultsto = propDict['appendresultsto']
f = open(appendresultsto,'a')

# Connect to Adminserver
connect(username, password, adminurl)

#Get number of servers from the domain config
domainConfig()
managedServers=cmo.getServers()

heap_string       = ''
session_string    = ''
datasource_string = ''
thread_string     = ''

#Get Runtime for our server
domainRuntime()
for managedServer in managedServers:
  servername=managedServer.getName()

  path = '/ServerRuntimes/' + servername
  cd(path)

  if cmo.getState() == 'RUNNING':

    #Get all running applications
    path='/ServerRuntimes/' + servername + '/JVMRuntime/' + servername
    cd(path)

    if showmemory == 'true':
      hpfree = str(cmo.getHeapFreeCurrent())
      hpfreepercent = str(cmo.getHeapFreePercent())
      hpsizecurrent = str(cmo.getHeapSizeCurrent())
      hpsizemax = str(cmo.getHeapSizeMax())
      uptime = str(cmo.getUptime())
 
      heap_string = uptime + ';' + hpsizemax + ';' + hpsizecurrent + ';' + hpfree + ';' + hpfreepercent
    
    path = '/ServerRuntimes/' + servername
    cd(path)

    if showsession == 'true':

      apps=cmo.getApplicationRuntimes()
      for app in apps:
      
        #We are intersted only on this application
        if app.getName() == appname:
    
          #Get all components in that application
          comps=app.getComponentRuntimes()
          for comp in comps:
              
            if comp.getName() == servername + '_/' + webname:
              #We are interested in only web components
              if comp.getType() == 'WebAppComponentRuntime':
                #Get all active sessions
                sessionids=comp.getServletSessionsMonitoringIds()
                session_string = str(len(sessionids))

    path='/ServerRuntimes/' + servername + '/JDBCServiceRuntime/' + servername
    cd(path)

    if showdatasources == 'true':
      dsMBeans = cmo.getJDBCDataSourceRuntimeMBeans()
      for ds in dsMBeans:        
        name                             = ds.getName()
        state                            = ds.getState()
        currcapacity                     = str(ds.getCurrCapacity())
        activeconnectionscurrentcount    = str(ds.getActiveConnectionsCurrentCount())
        activeconnectionshighcount       = str(ds.getActiveConnectionsHighCount())
        datasource_string = datasource_string + ';' + name + ';' + state + ';' + currcapacity + ';' + activeconnectionscurrentcount + ';' + activeconnectionshighcount 

    path='/ServerRuntimes/' + servername
    cd(path)

    if showthreads == 'true':
      opensocks = cmo.getOpenSocketsCurrentCount();

      path = '/ServerRuntimes/' + servername + '/ThreadPoolRuntime/ThreadPoolRuntime/'
      cd(path)

      executethreadtotal    = str(cmo.getExecuteThreadTotalCount())
      standbythreads        = str(cmo.getStandbyThreadCount())
      idlethreads           = str(cmo.getExecuteThreadIdleCount())
      pending               = str(cmo.getPendingUserRequestCount())
      hoggingthreads        = str(cmo.getHoggingThreadCount())
      serverthroughput      = str(cmo.getThroughput())

      thread_string = str(opensocks) + ';' + executethreadtotal + ';' + standbythreads + ';' + idlethreads + ';' + pending + ';' + hoggingthreads + ';' + serverthroughput

    cal = Calendar.getInstance()
    dt = cal.getTime()
    f.write(str(dt) + ';' + servername + ';' + heap_string + ';' + session_string + datasource_string + ';' + thread_string + '\n')

#Disconnect and exit
f.close()
disconnect()
exit()

Thursday, October 14, 2010

OSB Deployment with ANT

As deployment woth OSB 11g can be done via Eclise (Oracle Workshop), via the SB Console,  then ANT deployment is not straight forward.
 If you run into ANT errors with OSB, make sure:

  • You delete the .metadata directory before starting de deployment. OSB will recreate the .metatdata folder.
  • If errors occurs, check the .metadata/.log file

Friday, October 08, 2010

SOA 11g PS install behaviour

If you install from the Oracle SOA Suite PS2 only the SOA components, with the graphical installer or via silent install and you did the domain confguration, you will see that the 'soainfra' application has warnings. It is running, but in the log file of the managed server(s), you will see that is can not find some JNDI stuff.

  • jms/bpm/PeopleQueryConnectionFactory
  • jms/bpm/CubeCommandXAConnectionFactory
  • jms/bpm/PeopleQueryConnectionFactory
  • jms/bpm/MeasurementTopic
  • jms/bpm/PeopleQueryTopic
You can ignore these errors in your log file, unless you think I need them, then you should created the JMS Connection factories and topics.

If you select the BAM option as well, you will not have these errors :-).

Let's hope they will fix it in PS3.