Uploaded image for project: 'EJBCA'
  1. EJBCA
  2. ECA-4039

Improve HealthCheck free memory control

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: EJBCA 6.2.8
    • Component/s: None
    • Labels:
      None

      Description

      Reported by Fabien Hochstrasser.

      https://sourceforge.net/p/ejbca/discussion/132019/thread/9030bc2f/?limit=25#0a83


      Hi,

      I configured Nagios to monitor EJBCA using the healthcheck page (which is really helpful!).
      My Problem is that I receive too many false alerts about the virtual memory about to run out.
      I configured the following in ejbca.properties: healthcheck.amountfreemem=32
      Which means for me: "Alert me when you have only 32MB left"

      I had a look in HealthCheckServlet.java and noticed that the healthcheck page compares the value configured in ejbca.properties with Runtime.getRuntime().freeMemory(). This method returns the current allocated free memory, and not the total free memory. The difference between both is explained very well here.

      I suggest to change this with:
      minfreememory >= Runtime.getRuntime().maxMemory() - Runtime.getRuntime().totalMemory() + Runtime.getRuntime().freeMemory();
      (sorry, I tried every possible code highlighting syntax but none is working)

      So yeah, I don't know if you agree with me and if yes who can implement the change...

      Thank you for your time

      Regards,
      Fabien


      http://docs.oracle.com/javase/7/docs/api/java/lang/Runtime.html
      maxMemory: Returns the maximum amount of memory that the Java virtual machine will attempt to use.
      totalMemory: Returns the total amount of memory in the Java virtual machine.
      freeMemory: Returns the amount of free memory in the Java Virtual Machine.

      maxMemory - totalMemory: Memory still not allocated by the JVM
      maxMemory - totalMemory + freeMemory: Memory still not allocated by the JVM + available memory of what is allocated by the JVM
      → Seems like a very good suggestion.

      As a side note, we usually recommend production setups usually pass the "-Xms" argument to the application server with the same setting as "-Xmx" to avoid the overhead of allocation during runtime.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              johan Johan Eklund
              Reporter:
              tomas Tomas Gustavsson
              Verified by:
              Mike Agrenius Kushner
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: