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

How to apply JVM Monitoring locally and remotely

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article shows you how to carry out JVM monitoring in local and remote applications, the content is concise and easy to understand, can definitely make your eyes bright, through the detailed introduction of this article, I hope you can get something.

The concept and application of JVM monitoring mainly include local JVM monitoring and JVM monitoring remote processes. After a simple trial, these commands + graphical tools are powerful enough to meet the general monitoring requirements, such as monitoring all kinds of memory, garbage collection and thread status.

JVM monitoring

After searching, it is found that there are such tools in sun's jdk, such as jstat,jps,jstatd on the command line from jdk5, jconsole; to jdk6 for graphic monitoring, jmap, jinfo, jstack for commands, and jvisualvm for graphics. After a simple trial, these command + graphics tools are powerful enough to meet the general monitoring requirements, such as monitoring all kinds of memory, garbage collection and thread status.

Graphics: visualvm

If it is local JVM monitoring, you can see the java application directly in the local window. Double-click to open the JVM monitoring window.

Remote it can be used to operate remote machines. The remote machine needs to start a daemon:jstatd

1. Remote machine starts jstatd

1.1.First, you need to prepare a java.policy file and save it to such as / home/admin/jstatd.java.policy

Grantcodebase "file:$ {java.home} /.. / lib/tools.jar" {permissionjava.security.AllPermission;}

1.2.Starting jstatd

Jstatd-J-Djava.security.policy=/home/admin/jstatd.java.policy-J-Djava.rmi.server.logCalls=true

1.3.You need to execute a command at the same time (linux requires)

Hostname-i

If the display is 127.0.0.1, you need to modify the / etc/hosts file to remove the configuration of the host name and have the host name resolve to its IP address, such as 10.20.131.214

2. Connect the remote machine

3. Click OK to see that it will connect to the remote machine and show the java process below it.

Jconsole

JVM monitors local applications

First of all, start the application you want JVM to monitor. For example, I use JDK1.6 to start Tomcat, or Eclipse can also be seen in the task manager (Ctrl+Alt+Del can be called up, or right-click in the taskbar) to see the process ID. For example, here I am 6132.

Then start jconsole.exe in the JDK installation directory (/ bin/jconsole.exe) (double-click or type jconsole in cmd), and the main interface will prompt you to establish a new connection:

You can see the process ID, select it, and then click Connect. These ID must be started with JDK1.6 's java.exe, otherwise they will not be seen in the list.

JConsle can JVM monitor memory, threads, the number of classes and CPU, and then click on each Tab to see the detailed output, which includes:

Memory: heap / non-heap, peak, various parts of memory, such as Perm,Eden, size graph.

Threads: peak, list of all threads, stack trace (thread in which object), etc. You can also enforce GC.

Class: peak value, total class graph.

MBean: detailed MBean information for some JVM parameters.

JVM monitors remote processes

First of all, you need to enable remote management on the running application. The parameters are as follows (no user verification is added during the simple period):

Java-Dcom.sun.management.jmxremote.port=1090-Dcom.sun.management. Jmxremote.ssl=false-Dcom.sun.management.jmxremote. Authenticate=false-jar../demo/jfc/Java2D/Java2Demo.jar

Then select the remote process when connecting, and enter the address: localhost:1090

It will be fine. Of course, on other computers (usually local area networks), you can enter the IP of that computer.

Summary: JConsole can be used to monitor the status of Server simply by JVM, but it takes up some resources, but the JVM monitoring that comes with JVM should occupy very small resources in theory, so it can be used to conveniently understand the status of Web server application process. If you want to tune applications, it is better to use tools such as JProfiler, which also take up more resources.

The above content is how to apply JVM monitoring locally and remotely. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

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

Development

Wechat

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

12
Report