If you enable the slow query log in mysql, it will give you a starting point for any SQL statements that take a lot of resources. It won't tell you which PHP script was the culprit, but you will have the database, table and SQL, and the time of the problem;
The slow query log consists of SQL statements that took more than
long_query_time seconds to execute and required at least
min_examined_row_limit rows to be examined.
Run the following query;
set global slow_query_log = 1;
By default the slow query log can be accessed like so;
here are some examples on parsing the information in the slow query log here;
You can combine that with examining the web server log files, to find requests that occurred at the same time as the long running query. For example once you have found a particularly slow query examine the apache or nginx log files;
[root@vps001 www]# vi /var/log/httpd/access_log
will show you which php file corresponds to a particular time request;
18.104.22.168 - - [03/Jul/2016:04:27:14 +0000] "POST /xmlrpc.php HTTP/1.1" 200 370 "-" "Googlebot/2.1 (+http://www.google.com/bot.html)"