WLST monitoring methods

This article describes how Weblogic Scripting Tool (WLST) can be used for the monitoring of Weblogic server health. The aim is to provide a few suggestions and best practices for those who seek (alternative) methods for monitoring the Weblogic servers, i.e. for administrators without access to EM Grid Control and/or WebLogic Server Diagnostic Framework (WLDF).

 Ebicus

 23 juli 2014

Wij zijn verhuisd

WLST has great potential for monitoring purposes, because of its ability to be scripted. You can use the scripts for continuous monitoring by for example: crontab.

If you want to get the current healthstate of the Weblogic server you can use the method cmo.getHealthState(). This method will return healthstates  in a similar way as the Weblogic Console, i.e. HealthState = HEALTH_OK.

wls:/cp_dev/domainRuntime/ServerRuntimes/AdminServer> cmo.getHealthState()
Component:ServerRuntime,State:HEALTH_OK,MBean:AdminServer,ReasonCode:[]

The method getHealthState() can however, return HEALTH_OK instead of WARNING even, when in the WebLogic Server (WLS) admin console it shows as WARNING.

This is not a bug, but working as designed. The method getHealthState() is meant to report the WARNING if and only if:

  • All threads are stuck.
  • The server memory is below the user-configured low threshold.
  • The open socket threshold has been reached.

getSubsystemHealthStates

A workaround for retrieving the actual health of the Weblogic server is combining the method cmo.getHealthState() with checking the health of the Weblogic subsystems . If one of the subsystems doesn’t have HEALTH_OK, the health of the Weblogic server is compromised. The health of the subsystems can be checked using method cmo.getSubsystemHealthStates(). This will return an array containing the mbeans for the Weblogic subsystems.

wls:/cp_dev/domainRuntime/ServerRuntimes/AdminServer> cmo.getSubsystemHealthStates()
array(weblogic.health.HealthState,[Component:threadpool,State:HEALTH_OK,MBean:ThreadPoolRuntime,ReasonCode:[], Component:bea_wls_internal(Application),State:HEALTH_OK,MBean:bea_wls_internal,ReasonCode:[], Component:ConferencePlanner(Application),State:HEALTH_OK,MBean:ConferencePlanner,ReasonCode:[], Component:JTA,State:HEALTH_OK,MBean:JTARuntime,ReasonCode:[], Component:PersistentStore.WLS_DIAGNOSTICS,State:HEALTH_OK,MBean:WLS_DIAGNOSTICS,ReasonCode:[], Component:ServerRuntime,State:HEALTH_OK,MBean:AdminServer,ReasonCode:[], Component:AdminServer.saf,State:HEALTH_OK,MBean:AdminServer.saf,ReasonCode:[], Component:mejb(Application),State:HEALTH_OK,MBean:mejb,ReasonCode:[], Component:bea_wls9_async_response(Application),State:HEALTH_OK,MBean:bea_wls9_async_response,ReasonCode:[], Component:AdminServer.jms,State:HEALTH_OK,MBean:AdminServer.jms,ReasonCode:[], Component:JDBC,State:HEALTH_OK,MBean:AdminServer,ReasonCode:[], Component:PersistentStore._WLS_AdminServer,State:HEALTH_OK,MBean:_WLS_AdminServer,ReasonCode:[]])

Script example:

## Import the string library
import string

## Connect to adminserver of domain
connect(username, password, URL)

domainRuntime()
cd(‘ServerRuntimes’)

## Get servers in runtime
servers_runtime = domainRuntimeService.getServerRuntimes()

for server in servers_runtime:

## Get health of subsystems (i.e. dbadapter)

components = server.getSubsystemHealthStates()

## Convert to list

componentsList = components.tolist()

## Components with no HEALTH_OK will be added to variable error_message

for component in componentsList:

if not “HEALTH_OK” in str(component):

error_message+=server.getName() + “n” + str(component) + “nn”;

 

getOverallHealthState

A new WLST method has been introduced in WLS 10.3.6, which combines the methods cmo.getHealthState() and  cmo.getSubsystemHealthStates() and will return the same server health as reported in the admin console. This method is called cmo.getOverallHealthState().

wls:/cp_dev/domainRuntime/ServerRuntimes/AdminServer> cmo.getOverallHealthState()
Component:ServerRuntime,State:HEALTH_OK,MBean:AdminServer,ReasonCode:[]

Script example:

## Import the string library
import string

## Connect to adminserver of domain
connect(username, password, URL)

domainRuntime()
cd(‘ServerRuntimes’)

## Get servers in runtime
servers_runtime = domainRuntimeService.getServerRuntimes()

for server in servers_runtime:

## Get health of servers

serverhealth = server.getOverallHealthState()

## Servers with no HEALTH_OK will be added to variable error_message

if not “HEALTH_OK” in str(serverhealth):

error_message = server.getName() + “n” + str(serverhealth) + “nn”;

[ps2id id=’commentaren’ target=”/]


Hoe faciliteer je een naadloze customer journey? Op een manier die je wendbaar genoeg maakt om wijzigingen in je klantreis snel en efficiënt door te voeren? Want de ene app wordt binnen no-time vervangen door de andere app, zeker nu de cloud booming is.

Stay updated

Wij willen je graag op de hoogte houden van het nieuws rondom onze diensten die jou interesseren. Het enige wat je daar voor dient achter te laten zijn jouw mailadres en je voornaam. Vanaf dat moment zullen we je van tijd tot tijd een Ebicus update sturen.

Specifieke voorkeur voor content?


Op zoek naar vergelijkbare blogs?