Analyzing resource consumption by script

Asked

Viewed 757 times

1

I have a server with S.Ubuntu Server 12.04 LTS, on this machine I have apache2 with PHP5 and PERL installed, but it consumes a lot of CPU resource, I wonder if it is a script with more problem for that I would have to review one by one, plus the amount of files is very large. So I wonder if you have any tools that when integrated into apache show me which requested scripts consume the most machine resources.

  • you’ve heard of zend server has it all

2 answers

2


Maybe two simple tools can give you a better direction than exactly monitoring.

I would use the lsof and the strace. Some examples:

1- All files being used by the apache user(files can be anything on linux, including network sockets)

lsof -u apache

2- All files opened by a process (name or pid)

lsof -c httpd
lsof -p <PID>

3- Processes interacting with a directory or file (for example, its script directory, or the script itself)

lsof /var/www/cgi-bin

4 - List all system calls of a process

strace -p <PID>

After this you can write custom monitors for Zabbix or another monitoring tool to report to you if there is any suspicious situation, or simply to keep a history of what is happening.

Alternatively, use apache mod_status: http://httpd.apache.org/docs/2.4/mod/mod_status.html

  • Thanks to Help, that’s almost what I’m looking for. But I need to list the resources spent by my PHP algorithms.

  • 1

    Then you’ll have to use one strace in apache or suddenly use mod_status ... http://httpd.apache.org/docs/2.4/mod/status.html

  • I’ll run the tests and get back to you.

  • Man, thank you so much, that’s what I needed. Now I know the requested file along with its information, CPU, Transfer by connection, among others.

  • You can edit your reply so I can mark as solved?

  • You’re welcome! Glad you could help!

Show 1 more comment

0

  • Thanks @hulckb, but you don’t know anything of the kind I asked? See the name of the file being interpreted by php... Monitor resource usage by files!? Thanks more for your attention.

  • Hi Hiago, there are several monitoring tools, I already used ntop and Zabbix very good .. with them you can monitor the processes, etc ... abs

  • So, I have knowledge of them, I’ll even indicate you a legal well that I use and htop, but the problem is that I have a high processing like to know where there are bottlenecks to improve the processes more in the processes appear only the apache -k start

Browser other questions tagged

You are not signed in. Login or sign up in order to post.