Wednesday, November 30, 2016

Weblogic Monitoring Sessions



Here is the sample script to monitor weblogic server app level session counts. This helps in understanding which apps the sessions are being created the most and how frequent etc., and this can be extended to get session time details as well.

These stats can help in estimating the session memory footprints like sizing a JVM heap.



def getSessionStats():
 connect(adminname,adminPd, url);
 servers = domainRuntimeService.getServerRuntimes();
 timestmp = datetime.datetime.utcnow();
 for server in servers:
    apps = server.getApplicationRuntimes();
    for app in apps:
        crs = app.getComponentRuntimes();
        for cr in crs:
            if (cr.getType() == 'WebAppComponentRuntime'):
                snm = cr.getName();
                opens = repr(cr.getOpenSessionsCurrentCount());
                totals = repr(cr.getSessionsOpenedTotalCount());
                highs = repr(cr.getOpenSessionsHighCount());
                fo.write(str(timestmp)+','+snm+','+opens+','+totals+','+highs+'\n')

import datetime
adminPd=''
url='t3://...:'
adminname='faadmin'
fo=open("filepathtoopen","a+")
fo.write('Time, Name , OpenSessionCount, TotalSessions, SessionCountHigh \n')
AdminPorts=[ '' ]
for port in AdminPorts:
        urltoconnect=url+port
        getSessionStats()

fo.close()