LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-22-2009, 03:16 AM   #1
ravibhure
Member
 
Registered: May 2007
Posts: 75

Rep: Reputation: 15
How to know cpu running process


Hello

I have Intel(R) Xeon(R) CPU with 4 processors, I need to know which processor (i.e. from 1 to 4) running which processes.

example
If I am running apache on my box then want to know
http process running or using which cpu instead of above 4

[root@ravitestbed ~]# PID=`pgrep http` ;ps -o pcpu,pmem,nlwp -p $PID
%CPU0 %MEM NLWP
0.0 0.9 1
0.0 0.4 1
0.0 0.4 1
%CPU1 %MEM NLWP
0.0 0.4 1
0.0 0.4 1
0.0 0.4 1
%CPU2 %MEM NLWP
0.0 0.4 1
0.0 0.4 1
0.0 0.4 1
%CPU4 %MEM NLWP
0.0 0.4 1
0.0 0.4 1
0.0 0.4 1
 
Old 07-22-2009, 03:20 AM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
1. Apache runs multiple client handlers, 'httpd' processes
2. The OS/kernel will move those process around the cpus as it sees fit...
 
Old 07-22-2009, 03:37 AM   #3
ravibhure
Member
 
Registered: May 2007
Posts: 75

Original Poster
Rep: Reputation: 15
Thanks Chris,
But can we know which cpu hold how many apache threads/handlers
 
Old 07-22-2009, 03:44 AM   #4
ravibhure
Member
 
Registered: May 2007
Posts: 75

Original Poster
Rep: Reputation: 15
I wanna know, i.e simple question is I have 4 cpu's in server and know that which one is using by apache

is that clear
 
Old 07-22-2009, 03:49 AM   #5
karamarisan
Member
 
Registered: Jul 2009
Location: Illinois, US
Distribution: Fedora 11
Posts: 374

Rep: Reputation: 55
Yes, but what is it you are really trying to do? The scheduler can and will move the various httpd processes around as often as it likes. Tell us what your real goal is; maybe we can point you down a more productive path.

Also, please don't double-post. Use the edit button to add the text to your first post.
 
Old 07-22-2009, 07:26 AM   #6
ravibhure
Member
 
Registered: May 2007
Posts: 75

Original Poster
Rep: Reputation: 15
I have found the solution
thanks for reply

ps -C httpd -eo psr,pcpu,pid,cmd | grep httpd | grep -vE 'ps -C | grep'

%processor %cpuload %pid %cmd

[root@puneserver extra]# ps -C httpd -eo psr,pcpu,pid,cmd | grep httpd | grep -vE 'ps -C | grep'
2 0.0 19122 /usr/local/apache2/bin/httpd -k restart
2 0.0 19211 /usr/local/apache2/bin/httpd -k restart
2 1.0 19212 /usr/local/apache2/bin/httpd -k restart
1 1.2 19213 /usr/local/apache2/bin/httpd -k restart
1 1.0 19235 /usr/local/apache2/bin/httpd -k restart
2 1.0 19296 /usr/local/apache2/bin/httpd -k restart
[root@puneserver extra]#
 
Old 07-22-2009, 07:33 AM   #7
karamarisan
Member
 
Registered: Jul 2009
Location: Illinois, US
Distribution: Fedora 11
Posts: 374

Rep: Reputation: 55
Looks like that'll do it. I'd really like to know what you intend to do with this information, though. Please share?
 
Old 07-22-2009, 10:04 AM   #8
ravibhure
Member
 
Registered: May 2007
Posts: 75

Original Poster
Rep: Reputation: 15
We are using the threaded apache and to know how much memory and cpu processors and the cpu load used by apache per thread.
Basically to do this things we will optimize well and improve the server and apache health.
We have running 1100 sites over just 70 servers so it's need to look better towards all these things
We are using memcached and as well varnish and ha for load balancing, really we are doing well, now we will allocating number of cpu's from total cpu processor to apache to run better.

that's the story ......
 
  


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
how to tell which CPU process is running on? abolishtheun Linux - Software 2 04-09-2009 08:01 AM
Get Process size and Thread count for a particular running process haseit Linux - Newbie 2 01-23-2009 12:09 AM
Shell Script : Kill a running process when another process starts ashmew2 Linux - General 3 08-20-2008 04:47 AM
CPU running at 100% usage while no applications are running mike_morley Linux - Desktop 14 05-17-2007 10:39 PM
Process scheduling (CPU) kiwi_bloke *BSD 1 08-29-2004 10:07 PM


All times are GMT -5. The time now is 05:00 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration