Skip to content

sebthom.de

Menu
  • Home
  • Über mich
  • Impressum
    • Datenschutzerklärung
  • Gästebuch
Menu

Logging WebSphere API calls in wsadmin scripts

Posted on Donnerstag, der 12. Juni 2014Sonntag, der 25. Dezember 2022 by sebthom

Deployment of enterprise applications and other administrative tasks in WebSphere Application Servers environments can be fully automated using Jython based scripts. Depending on the size of the environment and the level of automation these scripts may become rather big and complex. In case your management has the requirement that certain or all calls to the WebSphere API have be recorded into an audit log – e.g. calls that modify the environment configuration (e.g. installation of EARs, creation/deletion of data sources, etc.) or the runtime state of WebSphere processes (e.g. stop/start/restart of servers, applications, or listeners) – have a look at the following solution.

Save the code listing below into a file called wslogging.py.

from __future__ import nested_scopes

def __wrapMethod(methodToWrap, objectName):
    def __inner(*args):
        # YOUR LOGGING CODE GOES HERE
        print "wsadmin: %s.%s%s" % (objectName, methodToWrap.__name__, args[1:])
        return methodToWrap(*args)
    return __inner

# calls to the listed methods of these admin modules will not be logged
__methodCallsToIgnore = {
    "AdminConfig" : [ "attributes", "defaults", "getid", "list", "listTemplates", "show", "showall", "showdump", "types" ],
    "AdminControl" : [ "queryNames" ]
}

def __logwsadmin(adminClass, adminObjectName):
    # iterate over all features of the given admin class
    for (featureName, featureInstance) in adminClass.__dict__.items():
        # ignore class features that are no methods, e.g. properties
        if not callable(featureInstance): continue
        # ignore internal methods
        if featureName.startswith("_"): continue
        # ignore toString() method
        if featureName == "toString": continue

        # ignore methods from logging blacklist
        if __methodCallsToIgnore.has_key(adminObjectName) and featureName in __methodCallsToIgnore[adminObjectName]: continue

        # replace methods with logging delegates
        adminClass.__dict__[featureName] = __wrapMethod(featureInstance, adminObjectName)

# iterate over all loaded modules and enhance modules whose name starts with Admin
for (varName, varInstance) in locals().items():
    if varName.startswith("Admin"):
         __logwsadmin(varInstance.__class__, varName)

You can now transparently enable logging of calls to WebSphere admin objects in your custom Jython scripts using this launch pattern:

wsadmin.sh -lang jython -profile wslogging.py -f [FILENAME_OF_YOUR_SCRIPT]

Example:



			

Kategorien

  • Blog (1)
  • IT (21)
    • Entwicklung (16)
      • Java (7)
      • Jython (4)
      • Visual Basic (5)
    • Linux (3)
    • WebSphere Application Server (1)
    • WebSphere Portal (2)
    • Windows (1)
  • My Freeware (2)
  • My Music (3)

Neueste Beiträge

  • Logging WebSphere API calls in wsadmin scripts
  • [Solved] Windows 7 “Safely Remove Hardware” pop-up menu horrendously slow
  • Bash: Capturing stderr in a variable while still printing to the console.
  • Configuring EMF Teneo with Hibernate, Commons DBCP, Spring Hibernate Transaction Manager, and the OpenSessionInViewFilter
  • Using EMF ECore model objects with Wicket components
  • Installing Tomcat 6 on Debian Squeeze
  • Leveraging PyDev’s auto-completion for indirectly created objects
  • OVal 1.40 released
  • Installing WebSphere Portal in a local network
  • Comparing version numbers in Jython / Python

Blogroll

  • E L S U A
  • elektrofever.de
  • OVal
  • Sweettt.com
  • Twins’ Running Blog

Neueste Kommentare

  • Annibale bei Visual Basic – Multiple Undos Class v2.04
  • Annibale bei Visual Basic – Multiple Undos Class v2.04
  • koliko2k3 bei Gästebuch
  • hdkid bei MyPad v1.1.6 – ein PHP Editor
  • Luis Diego Villarreal bei Excel – VBA Timer Example v1.0.1

Archive

  • Juni 2014
  • Mai 2012
  • Januar 2011
  • Oktober 2010
  • September 2010
  • März 2010
  • Februar 2010
  • September 2009
  • Juli 2009
  • März 2009
  • Februar 2009
  • November 2008
  • September 2008
  • Mai 2008
  • September 2007
  • Juli 2007
  • Juli 2004
  • März 2003
  • August 2002
  • April 2002
  • Januar 2002
  • Deutsch (de)Deutsch
  • English (en)English
© 2025 sebthom.de | Powered by Minimalist Blog WordPress Theme