0 Replies Latest reply on Apr 19, 2011 7:37 PM by John Van Ommen

    Are the jython defaults too conservative?

      I have implemented a bit of code to monitor JVM memory usage in real time, and noticed that the amount of available memory for BLCLI commands is very low.


      I wanted to run this by the community, basically get a second opinion on whether there's a problem here.


      Here's an example of the memory usage; note that even VERY basic commands are nearly exhausting the memory of the JVM:


      Tue 04/19 19:17:00 : Running command blcli listAllInstanceNames ['Class://SystemObject/PRODUCTS/PROVISIONING_PORTAL_SW/LINUX'] JVM Free Memory = 26M, allocated memory = 63M, maximum memory = 227M.


      Tue 04/19 19:17:00 : Running command blcli getPropertyValue ['Class://SystemObject/PRODUCTS/PROVISIONING_PORTAL_SW/LINUX/0', 'DESCRIPTION'] JVM Free Memory = 19M, allocated memory = 63M, maximum memory = 227M.


      Tue 04/19 19:17:01 : Running command blcli getPropertyValue ['Class://SystemObject/PRODUCTS/PROVISIONING_PORTAL_SW/LINUX/1', 'DESCRIPTION'] JVM Free Memory = 17M, allocated memory = 63M, maximum memory = 227M.


      I am no expert on Java virtual machines, but if I'm not mistaken, the Jython script which is included with BladeLogic is setting the ceiling on the JVM very low, and that ceiling cannot be exceeded.  (That's one of the great things about Java, it runs in it's own sandbox.)


      Here's a snippet of shell code, from the 'stock' jython script, which defines the boundaries of the JVM:


      $JAVA_HOME/bin/java -Xmx256m $JVM_ARGS -Dpython.home=$JYTHON_HOME \

                           -Dblx.cmrootdir=$BLADELOGIC_HOME/br \

                          -Dcom.bladelogic.cli.xmldir=$BLADELOGIC_HOME/br/xml/cli \

                          org.python.util.jython "${@}"


      If I'm not mistaken, BladeLogic uses a series of Java virtual machines.  So it is NOT sufficient to simply monitor the memory usage of the app server.  Because there are multiple JVMs, you must monitor the memory of each one to tune the application as a whole.  For instance, the app server JVM could have plenty of memory, but the JVM that the BLCLI uses could be running out of memory, since each JVM has it's own process and it's own independent settings.  And the CLI settings cannot be tuned by blasadmin, you must tune them via the shell script.


      If any of this is incorrect, I'd appreciate feedback.


      Here's a snippet of the code that I am using to monitor the memory usage of the CLI's Java virtual machine.  Note that I am querying the memory of the CLI's JVM, not the app servers, and not the operating systems.  They're all seperate.


      def runBlcliCmd (cli, NameSpace, blcliCmd, args):
              cmd = []
              dataType = str(type(args))
              if dataType.find('PyList') >= 0:
                      for arg in args:

                      blcliResult = cli.run(cmd)
                      assert blcliResult, "ERROR: Failed executing " + blcliCmd
              except AssertionError,e:
                      print e
              logtime=time.strftime("%a %m/%d %H:%M:%S",time.localtime(time.time()))
              maxMemory = (Runtime.getRuntime().maxMemory()/1048576);
              allocatedMemory = (Runtime.getRuntime().totalMemory()/1048576);
              freeMemory = (Runtime.getRuntime().freeMemory()/1048576);
              appLog.write("%s : Running command blcli %s %s with result of blcliResult %s" % (logtime, blcliCmd, cmd, blcliResult))
              appLog.write("%s : JVM Free Memory = %sM, allocated memory = %sM, maximum memory = %sM.\n" % (logtime, freeMemory, allocatedMemory, maxMemory))

              return blcliResult