From time to time load on my server (centos 4)jumps to 15 or more. I need to discover what process causes this high load on server. It there any script which can handle this for me ? I think its caused by mysql so even to discover the sql query would be great help.
High server load typically caused by disk I/O. There are some ways to identify which process is waiting for disk I/O:
iotop
top -b -i -n 10
atop
and pressD
htop
->F2
to add 2 columnsIO_RBYTES
andIO_WBYTES
, thenF6
to sortYou should especially pay attention to the processes in
D
state (uninterruptible sleep):look for something with a long runtime.
then EXPLAIN to see if it's making full table scans, generating temp tables, etc.
Otherwise, you can use something like the free version of Jet ( http://www.jetprofiler.com/ )
Garrett
If it is the case that mysql is the cause of the high load, then Mysql supports a
slow_query_log
argument, and once enabled it will log any particularly slow queries to a file;http://dev.mysql.com/doc/refman/5.7/en/slow-query-log.html