LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 03-25-2011, 03:05 AM   #1
mahendra.patil
LQ Newbie
 
Registered: Mar 2011
Posts: 3

Rep: Reputation: 0
troubleshoot CPU utilization


Hello,
I have one linux(centos) server working as a web hosting server.SO there are many websites running on it with mysql databases.Sometimes server shows very high load with max cpu and memory utilization by httpd and mysql.
Now i want to find which apache/mysql process is taking max hardware resources with the request they are executing.
for eg:- there is one site which having high videos,mysql queries among the 100 sites this site is taking max cpu/memory usage.so i want to find which site is this.

Regards
Mahendra
 
Old 03-25-2011, 03:50 AM   #2
rigor
Member
 
Registered: Sep 2003
Location: 19th moon ................. ................Planet Covid ................Another Galaxy;............. ................Not Yours
Posts: 705

Rep: Reputation: Disabled
What you need to do will tend to depend on the nature of the problem.

Is there anything in the mysql queries being executed that will identify the site, for example, does some parameter in the queries identify the site for which the query is being invoked? If so, then this command:

Code:
show full processlist;
executed from the mysql client command as a mysql administrator, might show you which sites are causing the load as far as mysql is concerned.

If there isn't a parameter that identifies the site, you might wish to add something to identify the site that causes a query to be run. Then either the processlist or the mysql logs might be helpful in identifying slow or frequent queries.

Also, apache access logs can sometimes be helpful in such cases.

At a system level:

Code:
ps --forest
will show you the process tree for each process ( which may be relevant depending on how you have things configured ).

If you have a collection of connections that are maintained between apache and mysql, then this next thing wouldn't help. But if you have apache repeatedly connecting and dropping connections to mysql, then a command such as:

Code:
netstat -vepa
may show you if you have a lot of connections timing out after disconnect for a particular site ( implying that a lot of connections were made and have been disconnected, so there is likely a lot of activity for that site ).

I realize that is all rather general, but without additional details on how you have things configured it's difficult to be specific. Perhaps you could give tell us more about how you have things set up.
 
Old 04-01-2011, 05:41 AM   #3
mahendra.patil
LQ Newbie
 
Registered: Mar 2011
Posts: 3

Original Poster
Rep: Reputation: 0
I run the netstat command but this not giving me complete idea about which apache process is processing which website request.

# netstat -vepa
unix 2 [ ] STREAM CONNECTED 365398965 28997/httpd
unix 2 [ ] STREAM CONNECTED 365398385 7336/httpd
unix 2 [ ] STREAM CONNECTED 365398223 2091/httpd
unix 2 [ ] STREAM CONNECTED 365397263 7519/httpd
unix 2 [ ] STREAM CONNECTED 365396358 2904/httpd
unix 2 [ ] STREAM CONNECTED 365396223 2826/httpd
unix 2 [ ] STREAM CONNECTED 365395604 30607/httpd
unix 2 [ ] STREAM CONNECTED 365390680 28683/httpd
unix 2 [ ] STREAM CONNECTED 365389581 28694/httpd
 
Old 04-07-2011, 05:23 AM   #4
snjksh
Member
 
Registered: Jan 2008
Location: Pune, India
Distribution: RHEL
Posts: 34

Rep: Reputation: 0
Hi Mahendra,

You can check the following command.

1. ps -eo pcpu,pmem,pid,args,comm|grep java
To find the process using max cpu and memory

2. ps -ef|grep 'pid'
'pid' you can get from the first command.

From the full path of the pid, you can say which site is using more resource.

Cheers,
snjksh.
 
Old 04-07-2011, 06:57 PM   #5
amonamarth
Member
 
Registered: Dec 2009
Location: Los Angeles
Distribution: Fedora ,CentOS, RHEL
Posts: 59

Rep: Reputation: 17
Execute'top'
Once it comes up, hit the 'c' key, which will display the full command name. Then run ps -ef|grep 'pid', as suma5550 suggested.
 
Old 04-08-2011, 12:50 AM   #6
mahendra.patil
LQ Newbie
 
Registered: Mar 2011
Posts: 3

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by amonamarth View Post
Execute'top'
Once it comes up, hit the 'c' key, which will display the full command name. Then run ps -ef|grep 'pid', as suma5550 suggested.


When i run the command top command and then press the c key i found the following process i taking max cpu and memory usage.
5987 apache 15 0 62244 37m 6752 S 18.8 1.8 3:52.35 /usr/sbin/httpd

So i run the command as suggested above
# ps -ef|grep 5986
apache 5986 27405 2 18:31 ? 00:03:52 /usr/sbin/httpd

the desired output is not coming....
 
Old 04-08-2011, 07:47 PM   #7
amonamarth
Member
 
Registered: Dec 2009
Location: Los Angeles
Distribution: Fedora ,CentOS, RHEL
Posts: 59

Rep: Reputation: 17
Ok, here is your solution, using Apache's status page... and I just tried it on CentOS 5.3, so it works

- Tweak you http.conf file.
Look for this section:

<Location /server-status>
SetHandler server-status
Order deny,allow
Deny from all
Allow from YOUR_IP_ADDRESS
</Location>

Just replace YOUR_IP_ADDRESS by the IP or hostname from which you want to allow access to Apache's status page.

- reload configuration: /sbin/service httpd reload
- From $YOUR_IP_ADDRESS point your browser to http://host_running_apache/server-status
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
CPU Utilization mail2mphani Linux - Software 1 09-13-2010 09:11 AM
High CPU utilization on only one CPU out of 4 CPUs makam.sreekanth Linux - Kernel 2 09-03-2009 05:12 AM
cpu utilization and cpu load soltanloo Linux - General 1 06-07-2009 03:19 AM
Linux desktop GUI tool for CPU utilization and bandwidth utilization karimasif Linux - Software 4 03-03-2008 02:09 PM
CPU utilization ust Linux - Software 1 10-11-2007 07:05 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 09:47 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration