cle_clock
Home > wikikonf >  was/actions/by kikonf > logs







Logs

print

Action : was.logs   (Category : was, Name : logs, By : kikonf)
Complete Name : was.logs.by.kikonf
Version : 5.0        License : Modified BSD License

Purpose of the was category :
Easy to customize. This category use in background the wsadmin command in jython mode (through AdminConfig, AdminControl and AdminTask), to drive WebSphere Application Server configuration.
You can use it to manage the whole WebSphere architecture.

Purpose of this logs plugin : Tune the JVM logs directories

The following shows the main Source Code File for the Action : was.logs

Toggle lines
##  Copyright (c) 2008, Patrick Germain Placidoux
##  All rights reserved.
##
##  This file is part of Kikonf Public Software.
##
##  Kikonf Public Software is released under the modified BSD License,
##  which should accompany it or any part of it in the file "COPYING".
##  If you do not have this file you can access the license 
##  through the WWW at http://www.kikonf.org/license/bsd/license.txt.
## 
##  Home: http://www.kikonf.org
##  Contact: kikonf@gmx.com




from actions.was.tools import *



class Logs(wasAction):
            
    def extract(self, scope_attrs=None, **keywords):
        self_funct='extract'
        scope_id, scope_attrs, scope=self.getScope(scope_attrs=scope_attrs, indent=self.getIndent())
        self.verbose(scope_attrs)
        indent=self.getIndent() + 3*' '
        
        logs_node=self.newTop() #-- because in extract mode, each call returns a new blank top node.
                
        #-- root_dir
        oids=getShowAsDict(AdminConfig.show(AdminConfig.showAttribute(scope_id, 'outputStreamRedirect')))
        root_dir=oids['fileName']
        if root_dir.find('/')>=0:sep='/'
        else:sep='\\'
        spl=root_dir.split(sep)
        if len(spl)>=2:
            if spl[0]=='':spl=spl[1:]
            root_dir=sep.join(spl[:-1])
        
        #-- do_activity
        verbose('RASLoggingService listing.', level=self.getVerbose(), ifLevel=4, indent=indent, logFile=self.getLogFile())
        ras = AdminConfig.list('RASLoggingService', scope_id)
        do_activity=AdminConfig.showAttribute(AdminConfig.showAttribute(ras, 'serviceLog'), 'enabled')
        
        logs_node.setAttrs(root_dir=root_dir, do_activity=do_activity)         
        
        mkNodeScope(logs_node, scope_attrs, isUnique=True)                  
        
        oids=getShowAsDict(AdminConfig.show(AdminConfig.showAttribute(scope_id, 'outputStreamRedirect'))) # Tag: Stdout
        verbose('OutputStreamRedirect retreived.', level=self.getVerbose(), ifLevel=3, indent=indent, logFile=self.getLogFile())
        logs_node.newNode('stdout', rollover_size=oids['rolloverSize'], max_backup_files=oids['maxNumberOfBackupFiles'])
        
        oids=getShowAsDict(AdminConfig.show(AdminConfig.showAttribute(scope_id, 'errorStreamRedirect'))) # Tag: Stderr 
        verbose('ErrorStreamRedirect retreived.', level=self.getVerbose(), ifLevel=3, indent=indent, logFile=self.getLogFile())
        logs_node.newNode('stderr', rollover_size=oids['rolloverSize'], max_backup_files=oids['maxNumberOfBackupFiles'])

    def inject(self):
        self_funct='inject'
        logs_node = self.getTop()        
        logs_attrs = logs_node.getAttrs()
        scope_id, scope_attrs, scope=self.getScope(parent_node=logs_node, indent=self.getIndent()) #-- Retreives scope
        self.verbose(scope_attrs)
        indent=self.getIndent() + 3*' '

        #-- Do activity ?
        cmdvalues = 'enabled', logs_attrs.do_activity
        
        verbose('RASLoggingService listing.', level=self.getVerbose(), ifLevel=4, indent=indent, logFile=self.getLogFile())
        ras = AdminConfig.list('RASLoggingService', scope_id)
        oid = AdminConfig.showAttribute(ras, 'serviceLog')
        AdminConfig.modify(oid, cmdvalues)

        #-- Stdout
        if logs_node.hasNode('stdout'):
            attrs=logs_node.getNode('stdout')[0].getAttrs()

            cmdvalues=[]
            cmdvalues.append(['rolloverSize', attrs.rollover_size])
            cmdvalues.append(['maxNumberOfBackupFiles', attrs.max_backup_files])
            cmdvalues.append(['fileName', logs_attrs.root_dir + '/SystemOut.log'])
            oid = AdminConfig.showAttribute(scope_id, 'outputStreamRedirect')

            verbose('OutputStreamRedirect modifying.', level=self.getVerbose(), ifLevel=4, indent=indent, logFile=self.getLogFile())
            AdminConfig.modify(oid, cmdvalues)
            verbose('OutputStreamRedirect modified.', level=self.getVerbose(), ifLevel=3, indent=indent, logFile=self.getLogFile())
            
        #-- Stderr
        if logs_node.hasNode('stderr'):
            attrs=logs_node.getNode('stdout')[0].getAttrs()

            cmdvalues=[]
            cmdvalues.append(['rolloverSize', attrs.rollover_size])
            cmdvalues.append(['maxNumberOfBackupFiles', attrs.max_backup_files])
            cmdvalues.append(['fileName', logs_attrs.root_dir + '/SystemErr.log'])
            oid = AdminConfig.showAttribute(scope_id, 'errorStreamRedirect')
            
            verbose('ErrorStreamRedirect modifying.', level=self.getVerbose(), ifLevel=4, indent=indent, logFile=self.getLogFile())
            AdminConfig.modify(oid, cmdvalues)
            verbose('ErrorStreamRedirect modified.', level=self.getVerbose(), ifLevel=3, indent=indent, logFile=self.getLogFile())
            
        # - Treat Logs root_dir
        logs_attrs=logs_node.getAttrs()
        if logs_attrs.root_dir!=None:self.injLogsRootDir(logs_attrs.root_dir, indent=indent)
        
    def injLogsRootDir(self, root_dir, indent=None):
        scope_id, scope_attrs, scope=self.getScope()

        #-- Native Stdout/Stderr log
        cmdvalues=[]
        cmdvalues.append(['stderrFilename', root_dir + '/native_stderr.log'])
        cmdvalues.append(['stdoutFilename', root_dir + '/native_stdout.log'])
        
        verbose('JavaProcessDef listing.', level=self.getVerbose(), ifLevel=4, indent=indent, logFile=self.getLogFile())
        pd = AdminConfig.list('JavaProcessDef', scope_id)
        oid = AdminConfig.showAttribute(pd,'ioRedirect')
        
        AdminConfig.modify(oid, cmdvalues)
        verbose('IoRedirect modified.', level=self.getVerbose(), ifLevel=3, indent=indent, logFile=self.getLogFile())

        #-- RAS Logs
        cmdvalues='name', root_dir + '/activity.log'
        
        verbose('RASLoggingService listing.', level=self.getVerbose(), ifLevel=4, indent=indent, logFile=self.getLogFile())
        ras  = AdminConfig.list('RASLoggingService', scope_id)
        oid = AdminConfig.showAttribute(ras, 'serviceLog')
        
        verbose('ServiceLog modifying.', level=self.getVerbose(), ifLevel=4, indent=indent, logFile=self.getLogFile())
        AdminConfig.modify(oid, cmdvalues)
        verbose('ServiceLog modified.', level=self.getVerbose(), ifLevel=3, indent=indent, logFile=self.getLogFile())        

        #-- Trace service log
        cmdvalues='fileName', root_dir + '/trace.log'
        
        verbose('TraceService listing.', level=self.getVerbose(), ifLevel=4, indent=indent, logFile=self.getLogFile())
        traceService = AdminConfig.list('TraceService', scope_id)
        oid     = AdminConfig.showAttribute(traceService,'traceLog')
        
        verbose('TraceLog modifying.', level=self.getVerbose(), ifLevel=4, indent=indent, logFile=self.getLogFile())
        AdminConfig.modify(oid, cmdvalues)
        verbose('TraceLog modified.', level=self.getVerbose(), ifLevel=3, indent=indent, logFile=self.getLogFile())        

        #-- Transaction Service log
        cmdvalues='transactionLogDirectory', root_dir + '/tranlog'
        
        verbose('TransactionService listing.', level=self.getVerbose(), ifLevel=4, indent=indent, logFile=self.getLogFile())
        oid = AdminConfig.list('TransactionService', scope_id)

        verbose('TransactionService modifying.', level=self.getVerbose(), ifLevel=4, indent=indent, logFile=self.getLogFile())
        AdminConfig.modify(oid, cmdvalues)
        verbose('TransactionService modified.', level=self.getVerbose(), ifLevel=3, indent=indent, logFile=self.getLogFile())                
        
        #-- WebServer AccessLog
        cmdvalues='filePath', root_dir + '/http_access.log'
        
        verbose('HTTPAccessLoggingService listing.', level=self.getVerbose(), ifLevel=4, indent=indent, logFile=self.getLogFile())
        webs = AdminConfig.list('HTTPAccessLoggingService', scope_id)
        oid = AdminConfig.showAttribute(webs, 'accessLog')
        
        verbose('AccessLog modifying.', level=self.getVerbose(), ifLevel=4, indent=indent, logFile=self.getLogFile())
        AdminConfig.modify(oid, cmdvalues)
        verbose('AccessLog modified.', level=self.getVerbose(), ifLevel=3, indent=indent, logFile=self.getLogFile())                

        #-- WebServer ErrorLog
        cmdvalues='filePath', root_dir + '/http_error.log'
        oid = AdminConfig.showAttribute(webs, 'errorLog')
        
        verbose('ErrorLog modifying.', level=self.getVerbose(), ifLevel=4, indent=indent, logFile=self.getLogFile())
        AdminConfig.modify(oid, cmdvalues)
        verbose('ErrorLog modified.', level=self.getVerbose(), ifLevel=3, indent=indent, logFile=self.getLogFile())                
        
    def verbose(self, scope_attrs):
        scope=str(scope_attrs).replace("'", '')[1:-1]
        
        verbose('Logs at scope:' + scope + '.', level=self.getVerbose(), ifLevel=2, indent=self.getIndent())
							
(Source: <KIKONF_INSTALLATION_DIR>/plugins/actions/was/logs/by/kikonf/logs.py)


  • Line 1 to 3 say something , say something , say something
  • Line 10 to 17 say something , say something , say something , say something , say something
  • Line 20 to 25 say something



Trademarks :
  • "IBM", "WebSphere", "WebSphere Aplication Server", "WAS" are registred trademarks of International Business Machines Corporation.
  • "Java" and "JVM" are a registred trademarks of Oracle and/or its affiliates.
  • Other names may be trademarks of their respective owners.

Copyright © 2011 - Patrick Placidoux, Hélène Malamoud