Affects Version/s: None
Fix Version/s: EJBCA 6.2.8
Reported by Fabien Hochstrasser.
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
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.