LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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 07-11-2012, 07:50 PM   #1
yoachan
Member
 
Registered: Nov 2009
Posts: 109

Rep: Reputation: 16
PHP show user/account in TOP command


Dear all,

I want to show apache-php processes that runs on my server and on what account that process belong to. Basically I want top to display something like this:

Code:
  PID USER     PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
20686 user1    17   0  115m  18m 6444 R 56.2  0.2   0:01.69 php
20681 user1    17   0  116m  18m 6444 R 53.9  0.2   0:01.62 php
20574 user2    21   0  117m  21m 6444 R 43.3  0.3   0:04.74 php
20620 user2    19   0  118m  21m 6444 R 37.9  0.3   0:04.83 php
20636 user1    19   0  116m  19m 6444 R 34.3  0.2   0:03.46 php
instead of only showing 'nobody' that runs httpd like this
Code:
  PID USER     PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
18868 nobody   16   0  403m  58m 4248 S  8.0  1.5   0:05.31 httpd
12975 nobody   15   0  422m  74m 5940 S  6.0  1.9   0:20.27 httpd
13753 nobody   15   0  420m  72m 5828 S  4.0  1.9   0:26.25 httpd
12215 nobody   15   0  420m  71m 5900 S  2.0  1.8   0:22.88 httpd
21894 nobody   15   0  488m  91m 8084 S  2.0  2.4   1:39.80 httpd
I know it's possible for I took those two 'TOP' result as is from two separate machines that we have. Anyone has any idea how can I make it happens?

Thanks in advanced....
 
Old 07-11-2012, 10:47 PM   #2
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,724

Rep: Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705
Hi,

did you check the toprc files? Ie check for /etc/toprc on each machine and possibly the users toprc.
Also you should probably compare the version of top on each machine.

Evo2.
 
Old 07-22-2012, 11:36 PM   #3
yoachan
Member
 
Registered: Nov 2009
Posts: 109

Original Poster
Rep: Reputation: 16
@Evo2: sorry for my late reply.
FYI, I can't find toprc file on both machines...
And I'm almost sure that it's some kind of PHP or apache add on...
 
Old 07-23-2012, 12:49 AM   #4
sharadchhetri
Member
 
Registered: Aug 2008
Location: INDIA
Distribution: Redhat,Debian,Suse,Windows
Posts: 179

Rep: Reputation: 23
Quote:
Originally Posted by yoachan View Post
@Evo2: sorry for my late reply.
FYI, I can't find toprc file on both machines...
And I'm almost sure that it's some kind of PHP or apache add on...
try this

top -u user_name
 
Old 07-23-2012, 01:08 AM   #5
yoachan
Member
 
Registered: Nov 2009
Posts: 109

Original Poster
Rep: Reputation: 16
Quote:
Originally Posted by sharadchhetri View Post
try this

top -u user_name
@sharadchhetri: Thanks for your reply.

The result was Obvious:
in the machine that php username enabled, I can see the user and processes.
But for machine that displays 'nobody' only; nobody is the only thing I can get....

Again, it's not about the 'top' command, but something in php and/or apache setting that make each process be user specific...
 
Old 07-26-2012, 06:57 PM   #6
sharadchhetri
Member
 
Registered: Aug 2008
Location: INDIA
Distribution: Redhat,Debian,Suse,Windows
Posts: 179

Rep: Reputation: 23
Quote:
Originally Posted by yoachan View Post
@sharadchhetri: Thanks for your reply.

The result was Obvious:
in the machine that php username enabled, I can see the user and processes.
But for machine that displays 'nobody' only; nobody is the only thing I can get....

Again, it's not about the 'top' command, but something in php and/or apache setting that make each process be user specific...
you can use system function in php and give the top command.
If I am not getting correctly , explain what actually you want .if possible paste ur php script
 
Old 07-27-2012, 12:48 AM   #7
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,362

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
If these are php processes that are run as part of/by Apache (eg using mod-php), then of course they will run as the Apache user eg httpd, nobody, www ... whatever Apache runs as.
If you want to know who the 'user' is, you'd have to implement a login system/webpage and record the username in the program and then log the username + pid from the php program.
 
Old 07-28-2012, 11:33 PM   #8
yoachan
Member
 
Registered: Nov 2009
Posts: 109

Original Poster
Rep: Reputation: 16
Quote:
Originally Posted by chrism01 View Post
If these are php processes that are run as part of/by Apache (eg using mod-php), then of course they will run as the Apache user eg httpd, nobody, www ... whatever Apache runs as.
If you want to know who the 'user' is, you'd have to implement a login system/webpage and record the username in the program and then log the username + pid from the php program.
@Chrism01: thanks for your reply. I don't quite know how to do that though. Is that means that I can see user names using 'TOP' command?
For what I'm looking for is to be able to see them through 'TOP' like my 1st example above.
For a note one of my machines do that...

regards,

YoChan
 
Old 10-11-2012, 09:36 PM   #9
yoachan
Member
 
Registered: Nov 2009
Posts: 109

Original Poster
Rep: Reputation: 16
Finally I've found the answer.
In case anyone looking for the answer, suPHP or suEXEC is all that I need.


Quote:
suPHP is a tool for executing PHP scripts with the permissions of their owners. It consists of an Apache module (mod_suphp) and a setuid root binary (suphp) that is called by the Apache module to change the uid of the process executing the PHP interpreter.
Quote:
The suEXEC feature provides Apache users the ability to run CGI and SSI programs under user IDs different from the user ID of the calling web server. Normally, when a CGI or SSI program executes, it runs as the same user who is running the web server.

Case closed

Last edited by yoachan; 10-11-2012 at 09:53 PM.
 
  


Reply



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
[SOLVED] What's the command to add these groups to user account? cola Slackware 13 01-30-2010 04:39 AM
Root cannot connect to X while on top of normal user account Dankles Debian 4 04-26-2006 11:24 AM
How do you create a user account from command line??? bossdog22 Ubuntu 3 04-18-2006 01:06 PM
Networking command line/user account questions daburz Linux - Networking 1 06-20-2004 09:11 AM
Results from top command...user Q...? cbjhawks Linux - Software 1 09-20-2003 10:06 PM

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

All times are GMT -5. The time now is 02:40 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