Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Monitoring using JConsole

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

1. Introduction

The JConsole graphical user interface is a monitoring tool that conforms to the Java Management extension (JMX) specification and monitors information about the performance and resource consumption of applications running on the Java platform.

Start JConsole

Jconsole [options] [connection...]

Connection = pid | host:port | jmxURL

-interval=n: sets the update interval (4 seconds by default)

-notile: for two or more connections.

-pluginpath plugins: specify the directory and jar path.

META-INF/services/com.sun.tools.jconsole.JConsolePlugin must be included in the jar

For jmxURL, you can refer to the javax.management.remote.JMXServiceURL description.

two。 Local monitoring

Jconsole# process jconsole processID

3. Remote monitoring and control

% jconsole hostName:portNum

3.1 remote Monitoring configuration

Setting this property registers the MBean for the Java VM platform and publishes the remote method invocation (RMI) connector through a dedicated interface to allow JMX client applications to monitor the local Java platform, that is, Java VM running on the same machine as the JMX client.

3.1 Open the JMX port

Previous versions of com.sun.management.jmxremote#JDK6 Need to enable JMX agent% cd JDK_HOME / demo/jfc/ Notepad%java-Dcom.sun.management.jmxremote-jar Notepad.jar#JDK for Java SE sample application notepad later versions can enable out-of-the-box management agent monitoring and management% java-jar Notepad.jar#portNum is the port number to enable JMX RMI connections # setting this property will use the well-known name "jmxrmi" private read-only note on the specified port Publish an additional RMI connection com.sun.management.jmxremote.port = portNum in the book table

For production systems, SSL client certificates are used to verify user-managed client host and password authentication.

For more information, see the topic of using SSL and using LDAP authentication.

3.2 use password authentication

# enable or disable com.sun.management.jmxremote.authenticate=false

3.2.1 LDAP (not familiar with, not discussed)

Com.sun.management.jmxremote.login.config

3.2.2 password authentication

-Dcom.sun.management.jmxremote-Dcom.sun.management.jmxremote.port=8999\-Dcom.sun.management.jmxremote.ssl=false\-Dcom.sun.management.jmxremote.authenticate=true\-Dcom.sun.management.jmxremote.password.file=../conf/jmxremote.password\-Dcom.sun.management.jmxremote.access.file=../conf/jmxremote.access

Where com.sun.management.jmxremote.password.file can be obtained from the JRE_HOME/lib/jmxremote.password.template template

Com.sun.management.jmxremote.access.file can be obtained with JRE_HOME/lib/jmxremote.access template

4. Function

4.1 Tab

Overview (Overview): displays overview information about Java VM and monitoring values.

Memory (Memory): displays information about memory usage.

Threads: displays information about thread usage.

Class (Classes): displays information about loading classes.

VM (VM Summary): displays information about Java VM.

MBeans (MBeans): displays information about MBean.

4.1.1 Overview Information

The Overview tab displays graphical monitoring information about CPU usage, memory usage, thread count, and classes loaded in Java VM, all on a single screen.

JConsole allows you to save the data displayed in a chart in a comma separated value (CSV) file. To save data from a chart, just right-click any chart

4.1.2 memory Tab

The memory tab provides information about memory consumption and memory pools.

Eden Space (heap): the pool that initially allocated memory for most objects

Survivor Space (heap): a pool of objects that survive garbage collection in Eden space

Tenured Generation (heap): a pool containing objects that have existed in the survivor space for a period of time

Permanent Generation (non-heap): a pool that contains all the reflected data of the virtual machine itself, such as classes and method objects. For Java VM using class data sharing, this generation is divided into read-only and read-write areas

Code Cache (non-heap): HotSpot Java VM also includes code caching, which contains memory for compiling and storing native code.

The details area displays several current memory metrics:

Used (Used): the amount of memory currently in use, including memory occupied by all objects, accessible and inaccessible.

Commitment (Committed): ensures the amount of memory available to Java VM. The amount of committed memory may change over time. The Java virtual machine may release memory to the system, and the amount of committed memory may be less than the amount of memory initially allocated at startup. The amount of memory committed will always be greater than or equal to the amount of memory used.

Maximum (Max): the maximum amount of memory available for memory management. Its value may be changed or undefined. Even if the amount used is less than or equal to the maximum (for example, when the virtual memory system is low), memory allocation may fail if Java VM attempts to increase the amount of memory used more than committed memory.

GC time: cumulative time and total number of calls spent on garbage collection. It may have multiple lines, each of which represents a garbage collector algorithm used in Java VM.

The bar chart at the lower right shows the memory consumed by memory pools in both heap and non-heap memory. When the memory used exceeds the memory usage threshold, the bar turns red. You can set the memory usage threshold through the properties of MemoryMXBean.

Heap and Non-Heap

Non-heap memory includes method areas shared between all threads and memory required for internal processing or optimization of Java VM. It stores the structure of each class, such as running constant pools, field and method data, and code for methods and constructors.

Heap memory is the runtime data region for which Java VM allocates memory for all class instances and arrays.

Memory pool and memory manager

Memory pools and memory managers are key aspects of the Java VM memory system.

1. A memory pool represents the storage area managed by the Java virtual machine. Java VM has at least one memory pool and may create or delete memory pools during execution. Memory pools can belong to heap or non-heap memory.

two。 A memory manager manages one or more storage pools. The garbage collector is a memory manager responsible for reclaiming memory used by unreachable objects. Java VM may have one or more memory managers. It may add or remove memory managers during execution. Memory pools can be managed by multiple memory managers.

Garbage collection

For more information, see adjusting garbage collection using 5.0 HotSpot VM.

4.1.3 Monitoring thread usage

The Threads tab provides information about thread usage.

The list of threads in the lower left corner lists all active threads. If you enter a string in the filter field, the Thread list displays only threads whose names contain the string you entered. Click the thread name in the Thread list to display information about the thread, including thread name, status, and stack trace.

The chart shows the number of active threads over time. Displays two lines.

Red: peak number of threads

Blue: number of active threads.

Thread MXBean provides several other useful operations that are not overridden by the Threads tab.

FindMonitorDeadlockedThreads: detects whether there are any thread deadlocks on the object monitor lock. This operation returns a series of deadlocked threads ID.

GetThreadInfo: returns thread information. This includes the name, stack trace, and monitor locks (if any) currently blocked by the thread, as well as which thread holds the lock and thread contention statistics.

GetThreadCpuTime: returns the CPU time consumed by a given thread.

two。 Detect deadlock threads

The detect deadlock button detects deadlock cycles involving object monitors and java.util.concurrent autosynchronizers (see java.lang.management.LockInfo 's API specification documentation). Monitoring support for java.util.concurrent locks has been added in Java SE 6. If JConsole is connected to the Java SE 5.0VM, detecting the deadlock mechanism will only discover deadlocks related to the object monitor. JConsole does not show any deadlocks associated with all synchronizers.

4.1.4 Monitoring class loading

The classes tab displays information about class loading.

The red line is the total number of classes loaded (including classes that are subsequently unloaded).

The blue line is the number of classes currently loaded.

The details section at the bottom of the tab shows the total number of classes loaded, the number currently loaded, and the number unloaded since Java VM started. You can set the class load trace to detailed output by selecting the check box in the upper-right corner.

4.1.5 View VM information

The VM Summary tab provides information about Java VM.

Summary

Uptime: total time since Java VM was started

Process CPU Time: the total CPU time consumed by Java VM since it was started.

Total Compile Time: total cumulative time spent in JIT compilation

Threads

Live threads: current number of daemon threads and non-daemon threads.

Peak: the largest number of real-time threads since Java VM was started.

Daemon threads: the current number of daemon threads.

Total threads started: the total number of threads started after Java VM starts, including daemons, non-daemons, and terminated threads.

Classes

Current classes loaded: the number of classes currently loaded into memory.

Total classes loaded: the total number of classes loaded into memory since Java VM was started, including the total number of classes that were subsequently unloaded.

Total classes unloaded: the number of classes unloaded from memory since Java VM was started.

Memory

Current heap size: number of kilobytes currently occupied by the heap.

Committed memory: the total amount of memory allocated to the heap.

Maximum heap size: the maximum number of kilobytes occupied by the heap.

Objects pending for finalization: number of objects waiting to be completed.

Garbage collector: information about garbage collection, including the name of the garbage collector, the number of collections executed, and the total time it took to execute the GC.

Operating System

Total physical memory: the number of random access memories (RAM) that the operating system has.

Free physical memory: the amount of available memory available to the operating system.

Committed virtual memory: ensures the amount of virtual memory available to the running process.

Other Information

VM arguments: the input parameters that the application passes to the Java VM, excluding the parameters of the main method.

Class path: the classpath that the system class loader uses to search for class files.

Library path: a list of paths to search when the library is loaded.

Boot class path: the boot classpath is used by the bootstrap class loader to search for class files.

references

Http://docs.oracle.com/javase/8/docs/technotes/guides/management/agent.html

Http://docs.oracle.com/javase/8/docs/technotes/tools/unix/jconsole.html

Http://docs.oracle.com/javase/8/docs/technotes/guides/management/jconsole.html

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report