# What is easiest way to recognise cause of high load on Linux?



## ICPH (Jan 10, 2016)

What is easiest way to recognize cause of high load on Linux?


I have opportunity to execute some commands in case there is high load on Linux server and send an email with output. My aim is to easilly see if RAM or CPU or I/O caused high load.


Which commands with tiniest, static output (so i can send output via email) can easily tell me which one caused it and possibly reason/detail about the issue?


thank you


----------



## graeme (Jan 10, 2016)

free -h


top -n 1


and copy and paste the bits you need. With free you almost certainly want the -/+ buffers/cache: line


----------



## ICPH (Jan 10, 2016)

thx, but i think this do not give me any idea regarding I/O impact on the load average?


While i have OpenVZ VPS is "%wa" value of the "top" command the thing that can give some idea about VPS I/O usage?


so top gives me idea about CPU usage:


Cpu(s): 16.4%us,  3.1%sy,  0.7%ni, 79.4%id,  0.4%wa


(last "wa" value about how much VPS is overloaded regarding I/O?)


the free gives idea about real RAM usage:


                                    used      free


-/+ buffers/cache:        423       1624


right?


----------



## graeme (Jan 10, 2016)

No, sorry, do not really know about IO off hand.


You are correct about free. free -h should give you more readable output.


For CPU you can use top and then once you have seen the problem top -n 1 to get a static version of it.


----------



## DomainBop (Jan 10, 2016)

install any of these tools:


1. iotop (in/out usage), 2. iftop (network usage), 3. mytop (mysql usage), 4. top or htop (processes), 5. sysstat (in/out, cpu, RAM, network usage, etc, includes iostat and sar command line tools and more http://sebastien.godard.pagesperso-orange.fr/features.html )


assorted command line to find processes, cpu usage: 


ps auxf


```
ps -eo pcpu,pid,user,args | sort -k1 -r | head -10
```


look at the last few lines of dmesg (useful if high load is caused by hardware problem, out of memory, etc


dmesg


find the network connections (IPs) that are making the most connections (useful if high load is caused by a DOS or other attack, etc)


```
netstat -plan |grep :80|awk '{print $5}' |cut -d: -f1 |sort |uniq -c |sort -n
```


----------



## samK (Jun 9, 2020)

The next *cause* for *high load* is a system that has run out of available RAM and has started to go into swap. Because swap space is usually on a hard drive that is much slower than RAM, when you use up available RAM and go into swap, each process slows down dramatically as the disk gets used


----------

