Many times it is needed to monitor the ambari memory usage. JConsole and JVisualVM are the JDK provided JMX client utilities that can be used for the same.
Here in this demo we will see how to monitor ambari server's JVM memory using $JAVA_HOME/bin/jvisualvm (same steps will be applicable for jconsole as well)
Step-1). We will need to add the "com.sun.management.jmxremote" related JVM remoted jmx options to the "/var/lib/ambari-server/ambari-env.sh" as following.
com.sun.management.jmxremote => Enables the JMX remote agent and local monitoring via a JMX connector published on a private interface used by JConsole and any other local JMX clients that use the Attach API. JConsole can use this connector if it is started by the same user as the user that started the agent. No password or access files are checked for requests coming via this connector.
com.sun.management.jmxremote.port => Enables the JMX remote agent and creates a remote JMX connector to listen through the specified port. By default, the SSL, password, and access file properties are used for this connector. It also enables local monitoring as described for the com.sun.management.jmxremote property.
Step-2). Now we will need to restart the ambari server and validate if it has loaded these options properly or not?