Got an alarm about this server having high CPU usage. From experience, I know it's usually due to memory exhaustion.
How to check memory usage in Linux?
[root@server ~]# free
total used free shared buff/cache available
Mem: 2097152 482772 1614380 0 0 1614380
Swap: 2097152 0 2097152
[root@server ~]# free -m
total used free shared buff/cache available
Mem: 2048 471 1576 0 0 1576
Swap: 2048 0 2048
Can also read /proc/meminfo file.
[root@server ~]# cat /proc/meminfo
MemTotal: 2097152 kB
MemFree: 1601748 kB
MemShared: 0 kB
Buffers: 0 kB
Cached: 0 kB
SwapCached: 0 kB
Active: 0 kB
Inactive: 0 kB
HighTotal: 0 kB
HighFree: 0 kB
LowTotal: 2097152 kB
LowFree: 1601748 kB
SwapTotal: 2097152 kB
SwapFree: 2097152 kB
You can use top command to get BOTH memory and CPU usage.
If have a newer Linux distribution, you can also use htop, which organizes the information better.
With top, the processes are sorted according to decreasing CPU usage. If you happen to be running Java apps, expect extra long paths and command lines that are truncated. To see the complete command, use the -vv switch (very verbose) to wrap around the output.
To view the processes organized in a tree diagram, which shows the relationships among the processes, use the pstree command.
Output showing garbled or strange characters? That's probably because the system is using the default UTF-8 language/character encoding. If you're too lazy to change the encoding, just use the -A (ASCII) switch.
No comments:
Post a Comment