You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by mcvella <mc...@collective2.com> on 2009/09/01 19:43:50 UTC
changing apache process name?
Hello-
I am wondering if anyone knows if there is a way to configure what it shown
as the running apache process name. I am not sure if this is technically a
mod_perl question. The problem is that the process name is partially
truncated, so we are unable to determine exactly what perl app is running
for a given apache process.
For example, here is one running apache process as seen in top:
31122 www 16 0 76624 61m 6428 S 6 0.4 0:04.03
/opt/myapp/www/cgi-perl/sig -f /opt/c2/preview/tmp/httpd.conf
there is more to the perl app name than 'sig', (for example, it could be
signal.pl or signoff.pl) but it is truncated.
Is there any way to configure apache to show more characters in its process
names?
--
View this message in context: http://www.nabble.com/changing-apache-process-name--tp25244057p25244057.html
Sent from the mod_perl - General mailing list archive at Nabble.com.
Re: changing apache process name?
Posted by Torsten Foertsch <to...@gmx.net>.
On Tue 01 Sep 2009, Sebastiaan Hoogeveen wrote:
> Not sure if this would fix your problem, but you can just set $0 from
> within the mod_perl module to whatever you'd like to show up in the
> process list, just as with a regular perl script. It probably depends
> on the OS you're running whether this works as it should; I can
> confirm that it works on Linux.
This should work in mod_perl as well. Perl 5.8.0 had a bug that
prevented it. Hence the Sys::Proctitle module.
Torsten
--
Need professional mod_perl support?
Just hire me: torsten.foertsch@gmx.net
Re: changing apache process name?
Posted by Sebastiaan Hoogeveen <s....@nederhost.nl>.
On 1 sep 2009, at 19:43, mcvella wrote:
> I am wondering if anyone knows if there is a way to configure what
> it shown
> as the running apache process name. I am not sure if this is
> technically a
> mod_perl question. The problem is that the process name is partially
> truncated, so we are unable to determine exactly what perl app is
> running
> for a given apache process.
>
> For example, here is one running apache process as seen in top:
>
> 31122 www 16 0 76624 61m 6428 S 6 0.4 0:04.03
> /opt/myapp/www/cgi-perl/sig -f /opt/c2/preview/tmp/httpd.conf
>
> there is more to the perl app name than 'sig', (for example, it
> could be
> signal.pl or signoff.pl) but it is truncated.
>
> Is there any way to configure apache to show more characters in its
> process
> names?
Not sure if this would fix your problem, but you can just set $0 from
within the mod_perl module to whatever you'd like to show up in the
process list, just as with a regular perl script. It probably depends
on the OS you're running whether this works as it should; I can
confirm that it works on Linux.
You could probably use some wrapper code or write a handler to set $0
to the name of the script or module that is executed.
Kind regards,
--
Sebastiaan Hoogeveen
<s....@nederhost.nl>
NederHost is ingeschreven bij de Kamer van Koophandel onder dossier
34099781.
Re: changing apache process name?
Posted by Joe Brenner <do...@kzsu.stanford.edu>.
Torsten Foertsch <to...@gmx.net> wrote:
> mcvella wrote:
> > I am wondering if anyone knows if there is a way to configure what it
> > shown as the running apache process name. I am not sure if this is
> > technically a mod_perl question. The problem is that the process
> > name is partially truncated, so we are unable to determine exactly
> > what perl app is running for a given apache process.
> >
> > For example, here is one running apache process as seen in top:
> >
> > 31122 www 16 0 76624 61m 6428 S 6 0.4 0:04.03
> > /opt/myapp/www/cgi-perl/sig -f /opt/c2/preview/tmp/httpd.conf
> >
> > there is more to the perl app name than 'sig', (for example, it could
> > be signal.pl or signoff.pl) but it is truncated.
Just look into the options on the ps command, I think you'll find you
can see long process names with the "w" (wide) option, or "ww" for
"unlimited width":
ps axwwl
Or perhaps:
ps axwwl | egrep cgi-perl
> > Is there any way to configure apache to show more characters in its
> > process names?
Um... both perl's exec and system has a list form that allows you to
start up a program with a fictious name (you give it the program name
first, and follow that with the ficitious name, followed by any other
arguments).
Off the top of my head, I'm not sure if there's a way to use that
feature from within mod_perl.
Re: changing apache process name?
Posted by Torsten Foertsch <to...@gmx.net>.
On Tue 01 Sep 2009, mcvella wrote:
> I am wondering if anyone knows if there is a way to configure what it
> shown as the running apache process name. I am not sure if this is
> technically a mod_perl question. The problem is that the process
> name is partially truncated, so we are unable to determine exactly
> what perl app is running for a given apache process.
>
> For example, here is one running apache process as seen in top:
>
> 31122 www 16 0 76624 61m 6428 S 6 0.4 0:04.03
> /opt/myapp/www/cgi-perl/sig -f /opt/c2/preview/tmp/httpd.conf
>
> there is more to the perl app name than 'sig', (for example, it could
> be signal.pl or signoff.pl) but it is truncated.
>
> Is there any way to configure apache to show more characters in its
> process names?
It depends upon your operating system.
FreeBSD has a library function called setproctitle to do that as far as
I know.
On Linux it can be achieved like this. The original argv and envp are
laid out subsequently by the kernel. Normally a program accesses its
argv only at startup and the original environment is copied and not
used later on. But the argv pointer is where ps and top look for the
command line. So there is a buffer of the size of all command line
arguments plus all the environment that can be overwritten and thus
used to show what you like in ps and top. The only problem is how to
get the values of these pointers. This can be solved using a shared
library. It may contain a function named _init() that is called when
the lib is loaded. Fortunately it is passed argc, argv and envp as
parameters. Now, you have all information to figure out the size of the
argv and envp buffer and can overwrite it as you like.
This is what the libsetproctitle (http://lmgtfy.com/?q=libsetproctitle)
library does.
I have once (at the time of perl 5.8.0) written a module Sys::Proctitle
that uses (and bundles) this lib and also an Apache2::ShowStatus that
uses Sys::Proctitle to show the current request in top. But since then
I haven't touched these modules. So I don't know if they still work.
Torsten
--
Need professional mod_perl support?
Just hire me: torsten.foertsch@gmx.net