设为首页 收藏本站
查看: 576|回复: 0

[经验分享] Getting Runtime Information in Weblogic server by WLST.

[复制链接]

尚未签到

发表于 2017-2-16 12:52:59 | 显示全部楼层 |阅读模式
Getting Runtime Information
  This chapter describes how to use WebLogic Scripting Tool (WLST) to retrieve information that WebLogic Server instances produce to describe their run-time state.
  This chapter includes the following sections:


  •   Accessing Runtime Information: Main Steps

  •   Configuring Logging

  •   Working with the WebLogic Diagnostics Framework


Accessing Runtime Information: Main Steps
  The Administration Server hosts the domain run-time hierarchy which provides access to any MBean on any server in the WebLogic domain. If the Administration Server is not running for a WebLogic domain, WLST can connect to individual Managed Servers to retrieve
run-time data.
  Accessing the run-time information for a WebLogic domain includes the following main steps:


  •   Invoke WLST and connect to a running Administration Server instance. See
    Invoking WLST.

  •   Navigate to the domain run-time MBean hierarchy by entering the domainRuntime command.

    wls:/mydomain/serverConfig>domainRuntime()

      The domainRuntime command places WLST at the root of the domain-wide run-time management objects,
    DomainRuntimeMBean.

  •   Navigate to ServerRuntimes and then to the server instance which you are interested in monitoring.

    wls:/mydomain/domainRuntime>cd('ServerRuntimes/myserver')
  •   At the server instance, navigate to and interrogate run-time MBeans.

    wls:/mydomain/domainRuntime/ServerRuntimes/myserver>cd('JVMRuntime/myserver')>
    wls:/mydomain/domainRuntime/ServerRuntimes/myserver/JVMRuntime/myserver>ls()
    -r--   HeapFreeCurrent                              191881368
    -r--   HeapFreePercent                              87
    -r--   HeapSizeCurrent                              259588096
    -r--   HeapSizeMax                                  518979584
    -r--   JavaVMVendor                                 Sun Microsystems Inc.
    -r--   JavaVendor                                   Sun Microsystems Inc.
    -r--   JavaVersion                                  1.6.0_21
    -r--   Name                                         AdminServer
    -r--   OSName                                       Windows XP
    -r--   OSVersion                                    5.1
    -r--   Type                                         JVMRuntime
    -r--   Uptime                                       409141
    -r-x   preDeregister                                Void :
    ...
  The following sections provide example scripts for retrieving run-time information about WebLogic Server server instances and WebLogic domain resources.

Script for Monitoring Server State
  The WLST online script in
Example 8-1 navigates the domain run-time hierarchy and checks the status of a Managed Server every 5 seconds. It restarts the server if the server state changes from
RUNNING to any other status. It assumes that WLST is connected to the WebLogic domain's Administration Server.

Example 8-1 Monitoring Server State

# Node Manager needs to be running to run this script.
import thread
import time
def checkHealth(serverName):
while 1:
slBean = getSLCRT(serverName)
status = slBean.getState()
print 'Status of Managed Server is '+status
if status != "RUNNING":
print 'Starting server '+serverName
start(serverName, block="true")
time.sleep(5)
def getSLCRT(svrName):
domainRuntime()
slrBean = cmo.lookupServerLifecycleRuntime(svrName)
return slrBean
checkHealth("myserver")





Script for Monitoring the JVM
  The WLST online script in
Example 8-2 monitors the HJVMHeapSize for all running servers in a WebLogic domain; it checks the heap size every 3 minutes and prints a warning if the heap size is greater than a specified threshold. It assumes that the URL for the WebLogic
domain's Administration Server is t3://localhost:7001.
  For information on how to run this script, see
Invoking WLST.

Example 8-2 Monitoring the JVM Heap Size

waitTime=180000
THRESHOLD=300000000
uname = "weblogic"
pwd = "welcome1"
url = "t3://localhost:7001"
def monitorJVMHeapSize():
connect(uname, pwd, url)
while 1:
serverNames = getRunningServerNames()
domainRuntime()
for name in serverNames:
print 'Now checking '+name.getName()
try:
cd("/ServerRuntimes/"+name.getName()+"/JVMRuntime/"+name.getName())
heapSize = cmo.getHeapSizeCurrent()
if heapSize > THRESHOLD:
# do whatever is neccessary, send alerts, send email etc
print 'WARNING: The HEAPSIZE is Greater than the Threshold'
else:
print heapSize
except WLSTException,e:
# this typically means the server is not active, just ignore
# pass
print "Ignoring exception " + e.getMessage()
java.lang.Thread.sleep(waitTime)
def getRunningServerNames():
# only returns the currently running servers in the domain
return domainRuntimeService.getServerRuntimes()
if __name__== "main":
monitorJVMHeapSize()







Configuring Logging
  Using WLST, you can configure a server instance's logging and message output.
  To determine which log attributes can be configured, see
"LogMBean" and
"LogFileMBean" in the Oracle WebLogic Server MBean Reference. The reference also indicates valid values for each attribute.
  The WLST online script in
Example 8-3 sets attributes of LogMBean (which extends LogFileMBean). For information on how to run this script, see
Invoking WLST.

Example 8-3 Configuring Logging

# Connect to the server
connect("weblogic","welcome1","t3://localhost:7001")
edit()
startEdit()
# set CMO to the server log config
cd("Servers/myserver/Log/myserver")
ls ()
# change LogMBean attributes
set("FileCount", 5)
set("FileMinSize", 400)
# list the current directory to confirm the new attribute values
ls ()
# save and activate the changes
save()
activate()
# all done...
exit()





Working with the WebLogic Diagnostics Framework
  The WebLogic Diagnostic Framework (WLDF) is a monitoring and diagnostic framework that can collect diagnostic data that servers and applications generate. You configure WLDF to collect the data and store it in various sources, including log records, data
events, and harvested metrics. For more information, see
Configuring and Using the Diagnostics Framework for Oracle WebLogic Server.
  For example scripts that demonstrate using WLST to configure the WebLogic Diagnostic Framework, see
"WebLogic Scripting Tool Examples" in Configuring and Using the Diagnostics Framework for Oracle WebLogic Server.
  To view the collected diagnostics information using WLST, use one of the following commands to export the data from the WLDF repositories:


  •   From WLST offline, use the exportDiagnosticData command (see
    "exportDiagnosticData" in WebLogic Scripting Tool Command Reference).

  •   From WLST online, use the exportDiagnosticDataFromServer command (see
    "exportDiagnosticDataFromServer" in WebLogic Scripting Tool Command Reference)).




weblogic.management.runtime
Interface DomainRuntimeMBean




public interface DomainRuntimeMBean
  This class is used for monitoring a WebLogic domain. A domain may contain zero or more clusters. A cluster may be looked up by a logical name.

Deprecation of MBeanHome and Type-Safe Interfaces

This is a type-safe interface for a WebLogic Server MBean, which you can import into your client classes and access through
weblogic.management.MBeanHome. As of 9.0, the MBeanHome interface and all type-safe interfaces for WebLogic Server MBeans are deprecated. Instead, client classes that interact with WebLogic Server MBeans should use standard JMX design
patterns in which clients use the javax.management.MBeanServerConnection interface to discover MBeans, attributes, and attribute types at runtime.




Method Summary


Date

getActivationTime()

The time when the domain became active.


AppRuntimeStateRuntimeMBean

getAppRuntimeStateRuntime()

Returns a service from which it is possible to determine the state applications throughout the domain.


CoherenceServerLifeCycleRuntimeMBean[]

getCoherenceServerLifeCycleRuntimes()

The CoherenceServerLifecycleRuntimeMBean for all configured Coherence servers in the domain.


ConsoleRuntimeMBean

getConsoleRuntime()

Return the MBean which provides access to console runtime services.


DeployerRuntimeMBean

getDeployerRuntime()
Deprecated.9.0.0.0



DeploymentManagerMBean

getDeploymentManager()

Provides access to the service interface to the interface that is used to deploy new customer applications or modules into this domain.


LogRuntimeMBean

getLogRuntime()

Return the MBean which provides access to the control interface for WLS server logging.


MessageDrivenControlEJBRuntimeMBean

getMessageDrivenControlEJBRuntime()

The MessageDrivenControlEJBRuntimeMBean for this server.


MigratableServiceCoordinatorRuntimeMBean

getMigratableServiceCoordinatorRuntime()

Returns the service used for coordinating the migraiton of migratable services.


MigrationDataRuntimeMBean[]

getMigrationDataRuntimes()

Returns a history of server migrations.


WseePolicySubjectManagerRuntimeMBean

getPolicySubjectManagerRuntime()




ServerLifeCycleRuntimeMBean[]

getServerLifeCycleRuntimes()

The ServerLifecycleRuntimeMBean for all configured servers in the domain.


ServiceMigrationDataRuntimeMBean[]

getServiceMigrationDataRuntimes()

Returns all the service migrations done in the domain


SNMPAgentRuntimeMBean

getSNMPAgentRuntime()

Return the MBean which provides access to the monitoring statistics for WLS SNMP Agent.


CoherenceServerLifeCycleRuntimeMBean

lookupCoherenceServerLifeCycleRuntime(Stringname)

Returns the Coherence server life cycle run-time MBean for the specified server.


ServerLifeCycleRuntimeMBean

lookupServerLifeCycleRuntime(Stringname)

Returns the server life cycle run-time MBean for the specified server.


void

restartSystemResource(SystemResourceMBeanresource)

Restarts a system resource on all nodes to which it is deployed.


void

setPolicySubjectManagerRuntime(WseePolicySubjectManagerRuntimeMBeanbean)



运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-343065-1-1.html 上篇帖子: Weblogic的Machine,Server,Domain,Cluster的关系 下篇帖子: Aix下weblogic 报错 BEA-000402和BEA-000438
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表