Thursday, May 8, 2014

How Enable the monitoring options on the Business services deployed on the OSB




##############################################################################################################################
# Scope    : To Enable the monitoring options on the Business services deployed on the OSB.
# Process  :
# 1. Set the classpath 
# CLASSPATH=/u01/app/oracle/product/fmw/Oracle_OSB1/lib/sb-kernel-api.jar:/u01/app/oracle/product/fmw/Oracle_OSB1/lib/sb-kernel-impl.jar:/u01/app/oracle/product/fmw/Oracle_OSB1/lib/modules/com.bea.alsb.configfwk-wls.jar:$CLASSPATH
# 2. export CLASSPATH
# 3. set the domain  eg : . ./bin/setDomain.sh
# 4. Update the sction below on the Enviroment specificaitons ( host,port,credentials)
# 5. execute the following command  java weblogic.WLST ProxyServiceMonotringOptions.py

##################################################################################################################################

import javax.management
import java.util
import javax.management.remote
import javax.naming
import weblogic.management.mbeanservers.domainruntime
import com.bea.wli.sb.management.configuration
from java.util import Hashtable
from java.util import HashSet
from java.util import ArrayList
from javax.management.remote import JMXServiceURL
from weblogic.management.mbeanservers.domainruntime import DomainRuntimeServiceMBean
from javax.naming import Context
from javax.management.remote import JMXConnectorFactory
from javax.management import ObjectName
from com.bea.wli.sb.management.configuration import SessionManagementMBean
from com.bea.wli.sb.management.configuration import ALSBConfigurationMBean
from com.bea.wli.sb.management.configuration import CommonServiceConfigurationMBean
import weblogic.management.jmx.MBeanServerInvocationHandler
from com.bea.wli.config import Ref
from com.bea.wli.config.env import EnvValueQuery
from com.bea.wli.config.env import QualifiedEnvValue
from com.bea.wli.config.resource import DependencyQuery
from com.bea.wli.sb.management.query import ProxyServiceQuery
from com.bea.wli.sb.management.query import BusinessServiceQuery
from com.bea.wli.sb.util import EnvValueTypes
from java.util import Collection
from java.util import Collections


def setMonitoringAllProjectsAndServices(isEnabled):
    refs = configMBean.getRefs(Ref.DOMAIN)
    refsList = ArrayList()
    refsList.addAll(refs)
    
    for ref in refsList :
        if ref.getTypeId() == "BusinessService" :
            if ref.getTypeId() == "BusinessService" :
                isPS = "1"
            else:
                isPS =  "0"
            if isEnabled:
                print "enabling monitoring for ", ref.getFullName()
                BusinessServiceConfigurationMBean.enableMonitoring(ref)
            else:
                print "disabling monitoring for ", ref.getFullName()
                BusinessServiceConfigurationMBean.disableMonitoring(ref)

           else: 
       print " This is Not a Business Service", ref.getFullName()
sessionName = "MonitorUpdate"
hostname=sys.argv[1]
port=7001
username=sys.argv[2]
password=sys.argv[3]

serviceURL=JMXServiceURL("t3", hostname, port, "/jndi/" + DomainRuntimeServiceMBean.MBEANSERVER_JNDI_NAME)
h=Hashtable()
h.put(Context.SECURITY_PRINCIPAL, username)
h.put(Context.SECURITY_CREDENTIALS, password)
h.put(JMXConnectorFactory.PROTOCOL_PROVIDER_PACKAGES, "weblogic.management.remote")

conn = JMXConnectorFactory.connect(serviceURL, h)

mbconn = conn.getMBeanServerConnection()

sm = JMX.newMBeanProxy(mbconn, ObjectName.getInstance(SessionManagementMBean.OBJECT_NAME), SessionManagementMBean)

sm.createSession(sessionName)

configMBean = JMX.newMBeanProxy(mbconn, ObjectName.getInstance("com.bea:Name=" + ALSBConfigurationMBean.NAME + "." + sessionName + ",Type=" + ALSBConfigurationMBean.TYPE), ALSBConfigurationMBean)

domainService = weblogic.management.jmx.MBeanServerInvocationHandler.newProxyInstance(mbconn, ObjectName(DomainRuntimeServiceMBean.OBJECT_NAME), DomainRuntimeServiceMBean, false)

BusinessServiceConfigurationMBean = domainService.findService(String("BusinessServiceConfiguration.").concat(sessionName),'com.bea.wli.sb.management.configuration.BusinessServiceConfigurationMBean', None)


setMonitoringAllProjectsAndServices(true)


sm.activateSession(sessionName, "Complete enable/disable service monitoring")
conn.close()

How to enable monitoring on OSB proxy Service using WLST script

Following script helps in enabling the monitoring on all osb proxy deployed in the domain.

##############################################################################################################################
# Scope    : To Enable the monitoring options on the proxy services deployed on the OSB.
# Process  :
# 1. Set the classpath 
# CLASSPATH=/u01/app/oracle/product/fmw/Oracle_OSB1/lib/sb-kernel-api.jar:/u01/app/oracle/product/fmw/Oracle_OSB1/lib/sb-kernel-impl.jar:/u01/app/oracle/product/fmw/Oracle_OSB1/lib/modules/com.bea.alsb.configfwk-wls.jar:$CLASSPATH
# 2. export CLASSPATH
# 3. set the domain  eg : . ./bin/setDomain.sh
# 4. Update the sction below on the Enviroment specificaitons ( host,port,credentials)
# 5. execute the following command  java weblogic.WLST ProxyServiceMonotringOptions.py

##################################################################################################################################

import javax.management
import java.util
import javax.management.remote
import javax.naming
import weblogic.management.mbeanservers.domainruntime
import com.bea.wli.sb.management.configuration
from java.util import Hashtable
from java.util import HashSet
from java.util import ArrayList
from javax.management.remote import JMXServiceURL
from weblogic.management.mbeanservers.domainruntime import DomainRuntimeServiceMBean
from javax.naming import Context
from javax.management.remote import JMXConnectorFactory
from javax.management import ObjectName
from com.bea.wli.sb.management.configuration import SessionManagementMBean
from com.bea.wli.sb.management.configuration import ALSBConfigurationMBean
from com.bea.wli.sb.management.configuration import CommonServiceConfigurationMBean
import weblogic.management.jmx.MBeanServerInvocationHandler
from com.bea.wli.config import Ref
from com.bea.wli.config.env import EnvValueQuery
from com.bea.wli.config.env import QualifiedEnvValue
from com.bea.wli.config.resource import DependencyQuery
from com.bea.wli.sb.management.query import ProxyServiceQuery
from com.bea.wli.sb.management.query import BusinessServiceQuery
from com.bea.wli.sb.util import EnvValueTypes
from java.util import Collection
from java.util import Collections


def setMonitoringAllProjectsAndServices(isEnabled):
    refs = configMBean.getRefs(Ref.DOMAIN)
    refsList = ArrayList()
    refsList.addAll(refs)
    
    for ref in refsList :
        if ref.getTypeId() == "ProxyService" :
            if ref.getTypeId() == "ProxyService" :
                isPS = "1"
            else:
                isPS =  "0"
            if isEnabled:
                print "enabling monitoring for ", ref.getFullName()
                proxyServiceConfigurationMBean.enableMonitoring(ref)
            else:
                print "disabling monitoring for ", ref.getFullName()
                proxyServiceConfigurationMBean.disableMonitoring(ref)

            else: 
print " This is Not a Proxy", ref.getFullName()


sessionName = "MonitorUpdate"
hostname=sys.argv[1]
port=7001
username=sys.argv[2]
password=sys.argv[3]

serviceURL=JMXServiceURL("t3", hostname, port, "/jndi/" + DomainRuntimeServiceMBean.MBEANSERVER_JNDI_NAME)
h=Hashtable()
h.put(Context.SECURITY_PRINCIPAL, username)
h.put(Context.SECURITY_CREDENTIALS, password)
h.put(JMXConnectorFactory.PROTOCOL_PROVIDER_PACKAGES, "weblogic.management.remote")

conn = JMXConnectorFactory.connect(serviceURL, h)

mbconn = conn.getMBeanServerConnection()

sm = JMX.newMBeanProxy(mbconn, ObjectName.getInstance(SessionManagementMBean.OBJECT_NAME), SessionManagementMBean)

sm.createSession(sessionName)

configMBean = JMX.newMBeanProxy(mbconn, ObjectName.getInstance("com.bea:Name=" + ALSBConfigurationMBean.NAME + "." + sessionName + ",Type=" + ALSBConfigurationMBean.TYPE), ALSBConfigurationMBean)

domainService = weblogic.management.jmx.MBeanServerInvocationHandler.newProxyInstance(mbconn, ObjectName(DomainRuntimeServiceMBean.OBJECT_NAME), DomainRuntimeServiceMBean, false)

proxyServiceConfigurationMBean = domainService.findService(String("ProxyServiceConfiguration.").concat(sessionName),'com.bea.wli.sb.management.configuration.ProxyServiceConfigurationMBean', None)


setMonitoringAllProjectsAndServices(true)

sm.activateSession(sessionName, "Complete enable/disable service monitoring")
conn.close()

------------------------------------

How to Start the WebLogic Server in Debug Mode


Starting the WebLogic Server in Debug Mode



To start the WebLogic Managed Server in debug mode (not the Admin Server).
Use the following procedure to start the WebLogic Managed Server in debug mode:
  1. Stop both the Admin Server and Managed Server if they are still running.
  2. Go to directory <WEBLOGIC_HOME>/user_projects/domains/<DOMAIN>/bin.
  3. Copy the existing startWebLogic.sh script to a new script file, startWebLogic_Debug.sh.
  4. Use a text editor to open startWebLogic_Debug.sh.
  5. After the line ${JAVA_HOME}/bin/java ${JAVA_VM} –version, add the following two lines:
    echo "Launching Java with debug port: 10171"
     
    JAVA_OPTIONS="-Xdebug -Djava.compiler=NONE -Xnoagent -Xrunjdwp:transport=dt_socket,server=y,address=10171,suspend=n $JAVA_OPTIONS"
    
    The debug port does not have to be 10171 if the port specified is available.
  6. Save this change.
  7. Copy the existing startManagedWebLogic.sh script to a new script file, startManagedWebLogic_Debug.sh.
  8. Use a text editor to open startManagedWebLogic_Debug.sh.
  9. Find the two lines that are referring to startWebLogic.sh.
  10. Replace startWebLogic.sh with startWeblogic_Debug.sh. This change is to start the WebLogic Managed Server in debug mode by invoking thestartWebLogic_Debug.sh script.
  11. Save this change.
  12. Start the Admin Server by running the usual start-up script, startWebLogic.sh.
  13. Start the Managed Server in debug mode by running the new script, startManagedWebLogic_Debug.sh.
or

Using the WebLogic Admin Console, navigate to the ‘Server Start’ properties of the managed server that hosts LiveCycle. Add the following to the ‘Arguments’ field. The port used (1044) should be available on the node:
-Xdebug -Xrunjdwp:transport=dt_socket,address=1044,server=y,suspend=n
Re-start the managed server. Point your debugger at the debug port (1044 in the example above).
If the managed server is being started from a script, the debug arguments should be added to the startup script, instead of within the Admin Console.