0

I do have a high CPU utilization PhP Process. This process in turn seem to invoke mysql and both processes together are using all the CPU cores and RAM

using ps aux | grep php , i could get the filename and location. i.e;
/usr/bin/php /path/to/index/file/index.php

I cannot remove the index.php as this file is required to run the website.
I tried changing index.php to home.php and did corresponding changes to website/htaccess.

After this i get
/usr/bin/php home.php for ps aux | grep php

It seems some script has been written to hit the website's index file but am not able to find which script it is.

I searched the entire machine using sudo find . | xargs grep '/usr/bin/php' but no luck yet.

So my question is how i can find the script (if that is the case) that is executing '/usr/bin/php index.php'
I appreciate any input on this.

Anil Bhat
  • 1
  • 3
  • 1
    I have no idea what your problem or what your question here is. – fuero Feb 15 '13 at 11:23
  • Question is how i can find the source/script that is invoking the command '/usr/bin/php index.php' . This does not seem to be a HTTP request , but command executed from the same machine – Anil Bhat Feb 15 '13 at 12:30

3 Answers3

0

If the file is index.php, and the integral part of a website, it stands to reason that if there is some script accessing it, it's just as likely to be external to the server as it is internal. Why not have a look through your access log, as any request sent to the server should be logged, including the IP and in theory there should be some information about what type of program is making the access (although that's easily spoofable).

NickW
  • 10,263
  • 1
  • 20
  • 27
  • Thank you very much for the response NickW I checked the access logs and there are very few requests for the day (less than 100, including bot visits) Also, the requests over browser/http will get executed as /usr/bin/php index.php ? – Anil Bhat Feb 15 '13 at 12:17
  • You should probably see the requests as http:///path/to/index.php it should also list what sort of request it's making.. – NickW Feb 15 '13 at 12:28
  • If you're sure it's being called directly as a file, you might want to check cron and crontab files.. – NickW Feb 15 '13 at 12:40
0

Normally performance questions are far too complex to address here. However there is a glaring WTF in your set up:

ps aux | grep php , i could get the filename and location. i.e; /usr/bin/php /path/to/index/file/index.php

Are you really running CGI PHP?

sudo find . | xargs grep '/usr/bin/php'

I strongly suggest you get some help from someone who knows how a Unix system and in particular a webserver is supposed to work.

symcbean
  • 21,009
  • 1
  • 31
  • 52
0

Thanks NickW and symcbean . Your responses were useful.

Below is the summary of the issue. The website was implemented using Yii framework and hence every request would go through index.php of the website.

The website had many pages (1ooo's out of 100k) with ridiculously slow and wrong sql queries. Whenever a search bot hits the server and requests for such pages, it would execute for 30 seconds (php default timeout) and then will result in error page. The bot will again hit the same page or another such page.

This was the reason why there were PhP and Mysql Processes with high CPU utilization.

Anil Bhat
  • 1
  • 3