changing apache process name?

changing apache process name?

am 01.09.2009 19:43:50 von mcvella

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--tp252440 57p25244057.html
Sent from the mod_perl - General mailing list archive at Nabble.com.

Re: changing apache process name?

am 01.09.2009 20:26:34 von torsten.foertsch

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. =A0I am not sure if this is
> technically a mod_perl question. =A0The 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 =A0 =A0 =A0 16 =A0 0 76624 =A061m 6428 S =A0 =A06 =A00.4 =A0 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.

=46reeBSD has a library function called setproctitle to do that as far as=20
I know.

On Linux it can be achieved like this. The original argv and envp are=20
laid out subsequently by the kernel. Normally a program accesses its=20
argv only at startup and the original environment is copied and not=20
used later on. But the argv pointer is where ps and top look for the=20
command line. So there is a buffer of the size of all command line=20
arguments plus all the environment that can be overwritten and thus=20
used to show what you like in ps and top. The only problem is how to=20
get the values of these pointers. This can be solved using a shared=20
library. It may contain a function named _init() that is called when=20
the lib is loaded. Fortunately it is passed argc, argv and envp as=20
parameters. Now, you have all information to figure out the size of the=20
argv and envp buffer and can overwrite it as you like.

This is what the libsetproctitle (http://lmgtfy.com/?q=3Dlibsetproctitle)=20
library does.

I have once (at the time of perl 5.8.0) written a module Sys::Proctitle=20
that uses (and bundles) this lib and also an Apache2::ShowStatus that=20
uses Sys::Proctitle to show the current request in top. But since then=20
I haven't touched these modules. So I don't know if they still work.

Torsten

=2D-=20
Need professional mod_perl support?
Just hire me: torsten.foertsch@gmx.net

Re: changing apache process name?

am 01.09.2009 21:59:22 von Joseph Brenner

Torsten Foertsch 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?

am 01.09.2009 22:28:12 von s.hoogeveen

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


NederHost is ingeschreven bij de Kamer van Koophandel onder dossier
34099781.

Re: changing apache process name?

am 02.09.2009 09:25:10 von torsten.foertsch

On Tue 01 Sep 2009, Sebastiaan Hoogeveen wrote:
> Not sure if this would fix your problem, but you can just set $0 from
> =A0 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=20
prevented it. Hence the Sys::Proctitle module.

Torsten

=2D-=20
Need professional mod_perl support?
Just hire me: torsten.foertsch@gmx.net