Monday, December 16, 2013

wsadmin jython Tutorial

Jython is the preferred scripting language in Websphere from version 6.

Jython is the java version of python.

Refer Python Official Website for more details on python

We are not going to teach jython coding here rather we will be telling how to use wsadmin objects with  jython.

There are 5 wsadmin objects:
1.AdminApp
2.AdminTask
3.AdminConfig
4.AdminControl
5.AdminHelp

We will see all the available commands in these objects with exampls and which is the best one to use in complex environment.

Thursday, December 12, 2013

Wednesday, December 11, 2013

wsadmin Check Automatic Synchronisation jython

na= AdminConfig.list('NodeAgent').splitlines()
for i in na:
    fs=AdminConfig.showAttribute(i,'fileSynchronizationService')
    sy=AdminConfig.showAttribute(fs,'autoSynchEnabled')
    print "=" *30
    print "Automatic Synchronization Enabled : "+sy
    print "=" *30

ClassUnloadign Issue IBM Websphere

</con>
  <gc type="global" id="18" totalid="1830" intervalms="5375702.871">
    <classunloading classloaders="97276" classes="96598" timevmquiescems="0.000" timetakenms="27654.667" />
    <finalization objectsqueued="159" />
    <timesms mark="313.364" sweep="5.282" compact="0.000" total="31012.005" />
    <nursery freebytes="320865168" totalbytes="360956928" percent="88" />
    <tenured freebytes="411184336" totalbytes="1282799616" percent="32" >
      <soa freebytes="411184336" totalbytes="1282799616" percent="32" />
      <loa freebytes="0" totalbytes="0" percent="0" />
    </tenured>
  </gc>
  <nursery freebytes="320865168" totalbytes="360956928" percent="88" />
  <tenured freebytes="411184336" totalbytes="1282799616" percent="32" >
    <soa freebytes="411184336" totalbytes="1282799616" percent="32" />
    <loa freebytes="0" totalbytes="0" percent="0" />
  </tenured>
  <refs soft="97660" weak="68715" phantom="2543" dynamicSoftReferenceThreshold="10" maxSoftReferenceThreshold="32" />
  <time totalms="31057.771" />
</con>



The time taken by classunloading is 27654ms.the total time taken is 31057ms.
If its repeating in the gc logs then we have to tune the JVM.

If the environment you are 
Use -Xgc:classUnloadingKickoffThreshold=<number> to specify the
number of classes to be available for unloading to kick off a
Global GC earlier, this will reduce the impact of the class
unloading time.
 
Also analyse the  application is having problem from the  dump using MAT tool.
  


Refer IBM Document
-Xnoclassgc should not be used to prevent class loading and unloading as it may lead to native OOM.

IBM link for noclassgc lead to OOM

wsadmin List Server Port Details jython

servers = AdminConfig.list( 'ServerEntry' ).splitlines()
for server in servers :
    print '\n'
    print "Server Name : " +  server[0:server.find('(')]
    print "=" *30
    NamedEndPoints = AdminConfig.list( "NamedEndPoint" , server).splitlines()
    for namedEndPoint in NamedEndPoints:
        endPointName = AdminConfig.showAttribute(namedEndPoint, "endPointName" )
        endPoint = AdminConfig.showAttribute(namedEndPoint, "endPoint" )
        host = AdminConfig.showAttribute(endPoint, "host" )
        port = AdminConfig.showAttribute(endPoint, "port" )
        print "Endpoint Name  : " +  endPointName + " Host : " + host + " port : " + port



 


wsadmin Global Security Enable jython

gs=AdminTask.isGlobalSecurityEnabled()
if gs == true:
    print "=" *30
    print "Global Security is Enabled"
    print "=" *30
else:
    print "=" *30
    print "Global Security is disabled and enabling it"
    AdminTask.setGlobalSecurity ('[-enabled true]')
    print "=" *30

Monday, December 9, 2013

wsadminjython view VirtualHost Port Details

vh=AdminConfig.list('VirtualHost').splitlines()
for i in vh:
      x=len(AdminConfig.list('HostAlias',i).splitlines())
      iname=i.find('(')
      print "Port Details of "+i[0:iname]
      while x > 0:
        print AdminConfig.showAttribute(AdminConfig.list('HostAlias',i).splitlines()[x-1],'port')
        x=x-1






In Python indent is very important so please be careful while copying it.

Thursday, December 5, 2013

zgrep,zcat command to grep ,view zipped file

grep is a unix command to search in a file
cat will be used to open a file

zgrep and zcat will be used for zipped files

Ex:
zgrep CPU SystemOut.log.gz
zcat SystemOut.log.gz