When a problem occurs in the online system, you need to record the current running status of the system. To sum up, you need to pay attention to the following aspects:
1. Load: -- top command
On Linux, execute top and other commands, pay attention to the overview of load, memory, CPU and other systems, and pay attention to the processes that consume a lot of CPU and memory.
Use top-H and sort the CPU by SHIFT + P to find the thread that currently occupies the most CPU. (Top-u BPM-h),-H display by thread, otherwise display by Process
Use PS-T <pid> | WC-L to find the number of threads of the currently running Java Process.
2. Thread dump -- jstack
Kill-3 <pid>
Jstack <pid> intercepts the thread stack of the current Java Process.
(Java thread dump related articles)
3. Memory -- jmap
Jmap-heap <pid> can obtain the current heap memory.
If you suspect there is a memory problem, you can also dump the heap object.
Java5: jmap-heap: format = B <pid>
Java6: jmap-dump: format = B, file = heap. Bin <pid>
Note: this operation has a great impact on the performance of the machine. In Java 6, you can also add-XX: heapdumppath =/home/NASDAQ/oom. hrof-XX: + heapdumponoutofmemoryerror to enable automatic memory dump during oom.
4. GC -- jstat
Jstat-gcutil <pid> to obtain the GC status of the current application.
5. Network Connection
Obtain the number of connections to each machine on the network.
Netstat-Na | grep established | awk '{print $5}' | awk-F: '{print $1}' | sort | uniq-c | sort-R
The preceding command execution result is:
Number of connected IP addresses
You can also use netstat to check the number of connections on a port.
6. Logs
Back up the current application log.
7. tools:
Heap dump analysis tool: Memory analyzer (MAT): http://www.eclipse.org/mat/ (using memory analyzer tool (MAT) Eclipse plug-in to Analyze memory leaks) thread dump analysis tool: lockness: http://lockness.plugin.free.fr/home.php