Hello,
There is issue with code, more precisely its in the jarray class used in dynamic classloader.
I have written python script to get the health status of weblogic server, it uses the python/jython code to pull the mbean in loop and provide the health status. It has been working fine except that it has been coming up with "java.lang.String" which i tried hard to avoid but no success. I have provided the code, please can expert in python please suggest how to get the desired output with using array.
Existing output
MSServer1 = HEALTH_CRITICAL : Stuck Threads = array(java.lang.String,["5 stuck threads detected in WorkManager 'default'"])
Expected/desired output :
MSServer1 = HEALTH_CRITICAL : Stuck Threads = [5 stuck threads detected in WorkManager 'default']
Mbean value in weblogic :
wls:/FADomain/domainRuntime/ServerRuntimes> servers = domainRuntimeService.getServerRuntimes();
wls:/FADomain/domainRuntime/ServerRuntimes> print servers
array(weblogic.management.runtime.ServerRuntimeMBean,[[MBeanServerInvocationHandler]com.bea:Name=MSServer1,Location=MSServer1,Type=ServerRuntime, [MBeanServerInvocationHandler]com.bea:Name=MSServer2,Location=MSServer2,Type=ServerRuntime])
wls:/FADomain/domainRuntime/ServerRuntimes/MSServer1>ls()
-r-- Name MSServer1
-r-- OverallHealthState Component:ServerRuntime,State:HEALTH_CRITICAL,MBean:FSCM_V3.0,ReasonCode:[5 stuck threads detected in WorkManager 'default']
Python code
There is issue with code, more precisely its in the jarray class used in dynamic classloader.
I have written python script to get the health status of weblogic server, it uses the python/jython code to pull the mbean in loop and provide the health status. It has been working fine except that it has been coming up with "java.lang.String" which i tried hard to avoid but no success. I have provided the code, please can expert in python please suggest how to get the desired output with using array.
Existing output
MSServer1 = HEALTH_CRITICAL : Stuck Threads = array(java.lang.String,["5 stuck threads detected in WorkManager 'default'"])
Expected/desired output :
MSServer1 = HEALTH_CRITICAL : Stuck Threads = [5 stuck threads detected in WorkManager 'default']
Mbean value in weblogic :
wls:/FADomain/domainRuntime/ServerRuntimes> servers = domainRuntimeService.getServerRuntimes();
wls:/FADomain/domainRuntime/ServerRuntimes> print servers
array(weblogic.management.runtime.ServerRuntimeMBean,[[MBeanServerInvocationHandler]com.bea:Name=MSServer1,Location=MSServer1,Type=ServerRuntime, [MBeanServerInvocationHandler]com.bea:Name=MSServer2,Location=MSServer2,Type=ServerRuntime])
wls:/FADomain/domainRuntime/ServerRuntimes/MSServer1>ls()
-r-- Name MSServer1
-r-- OverallHealthState Component:ServerRuntime,State:HEALTH_CRITICAL,MBean:FSCM_V3.0,ReasonCode:[5 stuck threads detected in WorkManager 'default']
Python code
import os import re import string import array import java.lang from jarray import array as jarray_c from java.util import Hashtable from javax.management import MBeanServerConnection from javax.management import ObjectName from java.lang import String from java.lang import Object connect(username,password,URL) domainRuntime(); cd('ServerRuntimes') servers = domainRuntimeService.getServerRuntimes(); stoppedServers = [] for server in servers: try: cd ('/ServerRuntimes/' + server.getName()) result[server] = get('OverallHealthState').getReasonCode() CS = get('OverallHealthState').getState() if CS == 0: print server.getName(), "= HEALTH_OK :", ": Stuck Threads =",str(result[server]) elif CS == 1: print server.getName(), "= HEALTH_WARN :", ": Stuck Threads =",str(result[server]) elif CS == 2: print server.getName(), "= HEALTH_CRITICAL :", ": Stuck Threads =",str(result[server]) stoppedServers.append(server.getName()) elif CS == 3: print server.getName(), "= HEALTH_FAILED :", ": Stuck Threads =",str(result[server]) stoppedServers.append(server.getName()) elif CS == 4: print server.getName(), "= HEALTH_OVERLOADED :", ": Stuck Threads =",str(result[server]) else: print server.getName() + ': ' + get('State') + ': UNKNOWN HEALTH STATE (' + currentState + ')' except WLSTException, e: print server.getName() + " is not running." stoppedServers.append(server.getName()) disconnect() exit()