perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Torsten Foertsch <torsten.foert...@gmx.net>
Subject Re: changing apache process name?
Date Tue, 01 Sep 2009 18:26:34 GMT
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

Mime
View raw message