In Middleware infrastructure, These two issues are very common.
1. Connection Pool Overflow
2. OutOfMemory(OOM)
Both of them will lead the application to the rock bottom and application unavailability, So its always recommended to have on eye on both of these key factors, by having some kind of Run time Monitoring and alerting system tools. (Tivoli, Wily, Nagios etc..)
Sometime, We will not be having the sufficient monitoring tool to capture this OutOfMemory and Connection Pool Overflow.
That's when, we fall back into the efficient and easiest way, which is scripting tools, like WLST and WSADMIN etc.
Hope you have read our another post about "Connection Pool Overflow monitoring and Alerting System" if not click here
Now, here is the Jython script designed to help monitor the "HeapSize" which can let us able to proactively measure and take action for OOM issue.
As mentioned earlier in our post, You can have some kind of scheduling tools like Autosys (or) Cron and run it in a frequent interval along with Shell/Perl script and generate an email (or) ticket.
Let me know if there is any help required in designing of Shell/perl (or) in the scheduling part.
Latest version of this code can be found here
TheCode
1. Connection Pool Overflow
2. OutOfMemory(OOM)
Both of them will lead the application to the rock bottom and application unavailability, So its always recommended to have on eye on both of these key factors, by having some kind of Run time Monitoring and alerting system tools. (Tivoli, Wily, Nagios etc..)
Sometime, We will not be having the sufficient monitoring tool to capture this OutOfMemory and Connection Pool Overflow.
That's when, we fall back into the efficient and easiest way, which is scripting tools, like WLST and WSADMIN etc.
Hope you have read our another post about "Connection Pool Overflow monitoring and Alerting System" if not click here
Now, here is the Jython script designed to help monitor the "HeapSize" which can let us able to proactively measure and take action for OOM issue.
As mentioned earlier in our post, You can have some kind of scheduling tools like Autosys (or) Cron and run it in a frequent interval along with Shell/Perl script and generate an email (or) ticket.
Let me know if there is any help required in designing of Shell/perl (or) in the scheduling part.
Latest version of this code can be found here
TheCode
Running_JVMS=AdminControl.queryNames("*:type=Server,*").split(java.lang.System.getProperty("line.separator")) ignorelist=['nodeagent','dmgr'] for JVM in Running_JVMS: ServerName=AdminControl.invoke(JVM ,"getName()") if ServerName not in ignorelist: JVMName=AdminControl.completeObjectName('type=JVM,process='+ServerName+',*') JVMObject=AdminControl.makeObjectName(JVMName) perf=AdminControl.completeObjectName('type=Perf,process='+ServerName+',*') perfObject=AdminControl.makeObjectName(perf) Obj=AdminControl.invoke_jmx(perfObject,"getStatsObject",[JVMObject,java.lang.Boolean('false')],['javax.management.ObjectName','java.lang.Boolean' ]) current=Obj.getStatistic('HeapSize').getCurrent() used=Obj.getStatistic('UsedMemory').getCount() usage=float(used)/float(current)*100 uptime=float(Obj.getStatistic('UpTime').getCount())/60/60/24 print "--------------------------------------------" print "ServerName :", ServerName print "uptime(in days) :", int(uptime) print "--------------------------------------------" print "CurrentUsage :", current print "Usedmemory :", used print "Usage in Percent:", int(usage) print "--------------------------------------------"
Save this with .py extention and run it with wsadmin
The Result
bash-3.00# ./wsadmin.sh -username wasadmin -password wasadmin -lang jython -f ./python_scripts/getHeapStatus.py WASX7209I: Connected to process "dmgr" on node mwiCellManager01 using SOAP connector; The type of process is: DeploymentManager -------------------------------------------- ServerName : mwi_server01 uptime(in days) : 13 -------------------------------------------- CurrentUsage : 119936 Usedmemory : 85675 Usage in Percent: 71 -------------------------------------------- -------------------------------------------- ServerName : mwi_server02 uptime(in days) : 50 -------------------------------------------- CurrentUsage : 483392 Usedmemory : 319485 Usage in Percent: 66 --------------------------------------------
Hope it helps.
For any question related to this. Please feel free to reach us via comment.
Always you can write an email to us at admin@mwinventory.in
Cheers and Have a great and prosperous new year. Best wishes from teammwi.
I have tried to executed this script in my environment ND 8.5.5.0 but its throwing exception:
ReplyDeleteC:\IBM\WebSphere\AppServer\profiles\Dmgr01\bin>wsadmin -lang jython -f C:\IBM\he
apmem.py
WASX7209I: Connected to process "dmgr" on node localhostCellManager01 using SOAP
connector; The type of process is: DeploymentManager
WASX7017E: Exception received while running file "C:\IBM\heapmem.py"; exception
information: com.ibm.bsf.BSFException: exception from Jython:
Traceback (innermost last):
(no code object) at line 0
File "", line 1
Running_JVMS=AdminControl.queryNames("*:type=Server,*").split(java.lang.
System.getProperty("line.separator")) ignorelist=['nodeagent','dmgr'] for JVM in
Running_JVMS: ServerName=AdminControl.invoke(JVM ,"getName()") if ServerName no
t in ignorelist: JVMName=AdminControl.completeObjectName('type=JVM,process='+Ser
verName+',*') JVMObject=AdminControl.makeObjectName(JVMName) perf=AdminControl.c
ompleteObjectName('type=Perf,process='+ServerName+',*') perfObject=AdminControl.
makeObjectName(perf) Obj=AdminControl.invoke_jmx(perfObject,"getStatsObject",[JV
MObject,java.lang.Boolean('false')],['javax.management.ObjectName','java.lang.Bo
olean' ]) current=Obj.getStatistic('HeapSize').getCurrent() used=Obj.getStatisti
c('UsedMemory').getCount() usage=float(used)/float(current)*100 uptime=float(Obj
.getStatistic('UpTime').getCount())/60/60/24 print "----------------------------
----------------" print "ServerName :", ServerName print "uptime(in days) :", in
t(uptime) print "--------------------------------------------" print "CurrentUsa
ge :", current print "Usedmemory :", used print "Usage in Percent:", int(usage)
print "--------------------------------------------"
^
SyntaxError: invalid syntax
please help me to fix this
I see there is some problem with your indentation. Consider editing your code with some programming editor like notepad++. Let me know if it does not get fixed
ReplyDeleteHi ,
ReplyDeleteEven I have tried to use in my environment , one of server where there are no application installed , it shows data of one jvm where as I have 4 jvms configured on my environment, where as in my other environment where I have 10 JVM ,3 nodes , the script executes without any error but does not print any output.
Hi
ReplyDeleteI am having WAS ND 8.5 installed on linux , on one of test environment where there are no application installed , it result displaying data for always one jvm whereas I have 4 jvms configured for the node, tried all possible combination. On the other environment where I 10 JVMS configured script executed without any error but doesnt display and result. No error in the wsadmin logs. Could you please help me .
Well, I still think there is something went wrong with you Python indentation. I made some changes in the script to display the running JVMs list, before it prints the statistics.
ReplyDeleteHere you go: http://1drv.ms/1ZQJ7FO Just download it and use it.
The output will be something like this.
----------------------------------
Running Servers
----------------------------------
dmgr
mwiserver1
nodeagent
----------------------------------
--------------------------------------------
ServerName : mwiserver1
uptime(in days) : 28
--------------------------------------------
CurrentUsage : 104768
Usedmemory : 85260
Usage in Percent: 81
--------------------------------------------
i am not able to access the one drive link, please post the script I will take it from here, if with multiple jvm will it list the statics for all the JVM or only one JVM
ReplyDeleteIt will print all the JVM's statistics federated with the DMGR that you are connecting to.. Here is the codeshare link for you..https://codeshare.io/SnqD7
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteI have 2 nodes federated to cell and the JVM names on all the nodes are same, while running the script getting the below error and could you also let me know the changes in the script if i need to print it node wise, which will be more readable for my prospective
ReplyDelete----------------------------------
WASX7026W: String "type=JVM,process=xxxxxxx,*" corresponds to 3 different MBeans; returning first one.
WASX7026W: String "type=Perf,process=xxxxxx,*" corresponds to 3 different MBeans; returning first one.
WASX7017E: Exception received while running file "/home/xxxx/xxxxx,py"; exception information: com.ibm.bsf.BSFException: exception from Jython:
Traceback (innermost last):
File "", line 20, in ?
AttributeError: 'None' object has no attribute 'getStatistic'
What is your websphere version including sub version.
Deleteits 8.5.5.3 ND
DeleteHi Ankit,
DeletePlease check this link. Hope it helps
http://www.mwinventory.in/2016/01/was-get-running-server-list-with-heap.html
Hi Sarav,
DeleteI am still facing the above issue for the Multiple Mbeans, the JVM names are same for all 3 Nodes as a results its not displaying the stats for the JVM's , only shows the stats for the Nodeagent.
Hi Sarav,
DeleteI am still facing the above issue for the Multiple Mbeans, the JVM names are same for all 3 Nodes as a results its not displaying the stats for the JVM's , only shows the stats for the Nodeagent.
WASX7017E: Exception received while running file "C:\Program Files\IBM\WebSphere
ReplyDelete\AppServer\profiles\maximoDMgr\bin\script.py"; exception information: co
m.ibm.bsf.BSFException: exception from Jython:
Traceback (innermost last):
(no code object) at line 0
File "", line 6
print AdminControl.invoke(Serv,"getName()")
^
SyntaxError: invalid syntax
i suggest a github for these scripts
ReplyDelete