1 Reply Latest reply on Aug 29, 2012 2:23 PM by Michael Ekkert

    Need help with jython script to show AppServer Details

    Yanick Girouard

      I've written a simple script that dumps the results of the getAppServerDetails blcli command, but would like to refine it to return only a subset of the information (only specific lines). This script would be used to monitor the health of the app server (java memory, number of available worker threads, etc...). I could use grep to only include the lines I want but that implies I have to have another shell wrapper around it if I want to automate it.


      Here's what I have so far:


      import sys

      import os


      import bladelogic.cli.CLI as blcli

      retvalue = os.system('blcred cred -acquire -username Tivoli_Monitoring -password <password> -profile SRP &> /dev/null')

      jli = blcli.CLI()




      result = jli.run(['AppServerProfiler','getAppServerDetails'])

      print result.returnValue


      I'm a little new to Python and Jython in general, so any help would be appreciated.


      Note: On a side note, I had to add the sys.path.append line because no matter what, jython wouldn't read the registry file to locate the bladelogic module... I'm on Red Hat. Not sure what I did wrong...



        • 1. Re: Need help with jython script to show AppServer Details

          Hi Yanick,


          This may get you going to little more.... it's not perfect but will get you on the path to what you are trying to achieve I believe.  This will only dump the lines that have a Name/Value pair to a log line which you can then evaluate for the keys you are looking to report on.


          import logging # Logging Functions in Python


          if LOGGING_LEVEL_FLAG == "DEBUG":
          logging.basicConfig(level=logging.DEBUG, stream=sys.stdout, format='%(levelname)-8s %(message)s')
          elif LOGGING_LEVEL_FLAG == "INFO":
          logging.basicConfig(level=logging.INFO, stream=sys.stdout, format='%(levelname)-8s %(message)s')
          logging.basicConfig(level=logging.WARNING, stream=sys.stdout, format='%(levelname)-8s %(message)s')


          def runBlcliCmd(NameSpace,blcliCmd,args):

          logging.debug("Enter runBlcliCmd Function")

          cmd = []



          dataType = str(type(args))

          if dataType.find('list') >= 0:

            for arg in args:





            logging.debug(('BLCLI ARGS - ' + str(cmd)))

            blcliResult = jli.run(cmd)

            assert blcliResult, "ERROR: Failed executing " + blcliCmd

          except AssertionError,e:




          logging.debug("Leave runBlcliCmd Function")

          return blcliResult


          strServerDetails = runBlcliCmd('AppServerProfiler','getAppServerDetails',[]).returnValue
          logging.info("BladeLogic Application Server Details:\n" + str(strServerDetails))
          for sLine in str(strServerDetails).split('\n'):
          if (sLine != "" and str(sLine.startswith("====")) != "True"):
            sLineDetail = str(sLine).split('=')
            if(len(sLineDetail) > 1):
             logging.debug("--> " + str(sLineDetail[0]) + " ===> " + str(sLineDetail[1]))


          Hope this helps


          Mike E.