The WebLogic capacity planning going on and various low memory or OutOfMemory issues araising when new migration happen from WebLogic 8.1 to 9.2 MP3. To identity how the Garbage Collection working? How much free memory is available for each instance? This can be known with JVM statistics, which inturn tuning the JVM parameters or reset is easy for decide.
I had found a JVM monitoring script that is best suites to my WebLogic environment.
This script is able to get all server instances JVM statistics with a single run. The beauty of WLST is that it runs on single JVM and provides us the required output with the help of domain, server Runtime MBeans, which are supported by WebLogic 9.x and later releases by default supporting JMX 1.2, which has many good features to control and monitor the Runtime Environment of a WebLogic Server instance.
Here have the script which I have modified as per my task there is little C-style customization done with Python language syntax. I mean in Jython which actally used in the WLST.
This could be further refined but ... short of time I am pubishing this
Enjoy!!! Jython/WLST SCRIPTING
#You can create key files ucf='keypath/xuserconfig.key' ukf='keypath/xkeyfile.key' admurl = "t3://hostingdns.com:port" # This module is for retrieve the JVM statistics def monitorJVMHeapSize(): connect(userConfigFile=ucf, userKeyFile=ukf, url=admurl) # alternate connect('user', 'passwd', 'adminurl') serverNames = getRunningServerNames() domainRuntime() print ' TotalJVM FreeJVM Used JVM' print '==============================================' for name in serverNames: try: cd("/ServerRuntimes/"+name.getName()+"/JVMRuntime/"+name.getName()) freejvm = int(get('HeapFreeCurrent'))/(1024*1024) totaljvm = int(get('HeapSizeCurrent'))/(1024*1024) usedjvm = (totaljvm - freejvm) print '%14s %4d MB %4d MB %4d MB ' % (name.getName(),totaljvm, freejvm, usedjvm) except WLSTException,e: pass # This module for managed Servers list def getRunningServerNames(): domainConfig() return cmo.getServers() if __name__== "main": monitorJVMHeapSize() disconnect()
Here in this program you can add more functionality with getting the HeapFreePercent. It is just a variable assigned with get('HeapFreePercent') . Later, You can print that variable value.
Thanks Pavan, this is great! There's so much that can be done and automated with WLST/jython.
ReplyDeleteGetting all the JVM stats with a single script is going to simplify my monitoring setup.
Wonderfull script.
ReplyDeleteDo you know how to get the Garbage Collection statistics? I'm interested in the total time spend by the GC.
Hope you can help.
@Frank, I am pretty interested your thoughts... Let me know your prototype ideas for GC I could help you on your script...
ReplyDeleteHi Pavan- i've been following this blog lately to get some understanding in WLST.
ReplyDeleteI've a script that gives me heapfreepercent. The program works perfectly and you can take a look below. its a simple one.
but i would like to see just the value as output but nothing.
username = 'system'
password = 'xxxx'
url = 't3://xx:xx'
connect(username, password, url)
domainRuntime()
get_heap_info('PIA1')
def get_heap_info(server_name):
cd('ServerRuntimes/'+server_name+'/JVMRuntime/'+server_name)
hpercent = float(get('HeapFreePercent'))
print 'HeapFreePercent:' + `hpercent`
disconnect()
exit()
This displays connectivity information, disconnect information. I'm looking for just one line output displaying the HeapFreePercent:50
Is there anyway to achieve this?
@Ravi, You can use redirect('./logs/status.log', 'false') command before you call connect command.
ReplyDeletei have always this erros can you help ?
ReplyDeletewlst try: SyntaxError: inconsistent dedent
prediksi sabung ayam bangkok adu terupdate
ReplyDeletevery good post, i actually love this web site, carry on it
ReplyDeletedot net online training hydarabad
dot net online training india