Analyzing resource consumption by script

1

I have a server with Ubuntu Server 12.04 LTS OS, on this machine I have apache2 with PHP5 and PERL installed, but it consumes a lot of CPU resources, I would like to know if it is a problem script anymore for this I would have which review one by one, plus the amount of files is too large. Then I would like to know if you have any tools that when integrated to apache show me what scripts requested consume more resources of the machine.

    
asked by anonymous 26.09.2014 / 14:57

2 answers

2

Perhaps two simple tools can give you a better direction than just monitoring.

I would use lsof and 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, your script directory, or the script itself)

lsof /var/www/cgi-bin

4 - List all system calls to a process

strace -p <PID>

After that you can write custom monitors for zabbix or another monitoring tool to report you if there is any suspicious situation, or simply to keep track of what is happening.

Another alternative is to use the apache mod_status: link

    
02.10.2014 / 19:19
0

Hiago, take a look at the apache configuration guide on the link

link

and download the guide, there are some configuration options that can be useful in this case.

abs,

    
02.10.2014 / 16:52