CPU
top
1 | ps aux |grep java |
MEMORY
free
1 | free -m |
dmesg
If process is killed by the OS due to OOM, we can get logs from here.1
sudo dmesg | grep -i kill
vmstat
Check memroy, cpu, io …1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36vmstat 2 10 -t # 2 : interval, 10 : times
procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu----- -----timestamp-----
r b swpd free buff cache si so bi bo in cs us sy id wa st UTC
3 0 134548 400884 152320 6737836 0 0 3 54 3 8 5 1 94 0 0 2020-02-08 08:35:06
0 0 134548 401940 152320 6737808 0 0 0 54 1309 1883 1 1 98 0 0 2020-02-08 08:35:08
# Procs
# r: The number of processes waiting for run time.
# b: The number of processes in uninterruptible sleep.
# Memory
# swpd: the amount of virtual memory used. (is the value is larger than 0, it means the memory is not enough)
# free: the amount of idle memory.
# buff: the amount of memory used as buffers.
# cache: the amount of memory used as cache.
# inact: the amount of inactive memory. (-a option)
# active: the amount of active memory. (-a option)
# Swap
# si: Amount of memory swapped in from disk (/s).
# so: Amount of memory swapped to disk (/s).
# (If si and so is not 0 for a while, it means memory is not enough)
# IO
# bi: Blocks received from a block device (blocks/s).
# bo: Blocks sent to a block device (blocks/s).
# (if bi+bo>1000, and wa value is large, then IO is bottleneck)
# System
# in: The number of interrupts per second, including the clock.
# cs: The number of context switches per second.
# CPU
# These are percentages of total CPU time.
# us: Time spent running non-kernel code. (user time, including nice time)
# sy: Time spent running kernel code. (system time)
# id: Time spent idle. Prior to Linux 2.5.41, this includes IO-wait time.
# wa: Time spent waiting for IO. Prior to Linux 2.5.41, included in idle.
# st: Time stolen from a virtual machine. Prior to Linux 2.6.11, unknown.
DISK
df
1 | df -h |
1 | du -m /mnt | sort -rn | head -3 |
NETWORK
netstat
1 | netstat -nat | awk '{print $6}' | sort | uniq -c | sort -rn # check socket status |
JAVA PROCESS
jstack
Check status status of a java process1
sudo jstack -F 1423 # 1423 is process id
jinfo
1 | sudo jinfo -flags 13474 |
jmap
check heap usage status of a java process1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50sudo jmap -heap 13474
Attaching to process ID 13474, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 25.152-b16
using parallel threads in the new generation.
using thread-local object allocation.
Concurrent Mark-Sweep GC
Heap Configuration:
MinHeapFreeRatio = 40
MaxHeapFreeRatio = 70
MaxHeapSize = 1073741824 (1024.0MB)
NewSize = 44040192 (42.0MB)
MaxNewSize = 174456832 (166.375MB)
OldSize = 88080384 (84.0MB)
NewRatio = 2
SurvivorRatio = 8
MetaspaceSize = 21807104 (20.796875MB)
CompressedClassSpaceSize = 1073741824 (1024.0MB)
MaxMetaspaceSize = 17592186044415 MB
G1HeapRegionSize = 0 (0.0MB)
Heap Usage:
New Generation (Eden + 1 Survivor Space):
capacity = 39649280 (37.8125MB)
used = 5273360 (5.0290679931640625MB)
free = 34375920 (32.78343200683594MB)
13.300014527376034% used
Eden Space:
capacity = 35258368 (33.625MB)
used = 4555320 (4.344291687011719MB)
free = 30703048 (29.28070831298828MB)
12.919826578473513% used
From Space:
capacity = 4390912 (4.1875MB)
used = 718040 (0.6847763061523438MB)
free = 3672872 (3.5027236938476562MB)
16.352867012593283% used
To Space:
capacity = 4390912 (4.1875MB)
used = 0 (0.0MB)
free = 4390912 (4.1875MB)
0.0% used
concurrent mark-sweep generation:
capacity = 88080384 (84.0MB)
used = 45554184 (43.44385528564453MB)
free = 42526200 (40.55614471435547MB)
51.71887534005301% used
check what live objects takes up the memory1
jmap -histo:live 5409 # first execute GC once, then show the summary information
create dump of the memory1
2sudo jmap -dump:live,format=b,file=dump.hprof 9557
# live : only dump the live objects, don't dump the objects that are going to be GC. This is helpful for reducing the dump size.
jstat
1 | sudo jstat -gc 13474 2000 10 |
jps
Check all java process information1
2
3
4
5sudo jps -mlvV
# m : print main method argument
# l : print whole package name, main class, jar full path
# v : print jvm parameter
# V : print JVM parameter passed by flag file
OTHERS
tail
1 | tail -100f server.log # Show last 100 lines and show new lines in realtime |
awk
1 | awk '{print $1,$2}' a.txt |
find
1 | find /tmp/ /user/ -name *.log |