Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

How to get more information on CGIs I'm watching with Unix's "top" command

by AidanLee (Chaplain)
on Jul 26, 2007 at 20:19 UTC ( [id://628994]=perlquestion: print w/replies, xml ) Need Help??

AidanLee has asked for the wisdom of the Perl Monks concerning the following question:

Hello the Monestary,

So I'm monitoring a client's web site via top and the cgis for the site are chugging merrily (and speedily) along, except that once and a while one of them starts taking over the server's available memory and driving the load on the server way up. Now, this is just the same script (incidentally, index.cgi) as the happy processes, but apparently the path info and potentially the query string are causing a condition that isn't happening the rest of the time.

Problem is, I can't see what the path info and query string are by watching top, so I have no idea what values I should profile with.

So here's my plea for help. I can clearly see the rogue processes, PID and all, but I'm at a loss as to how to find out more about them for debugging and profiling purposes. Any ideas?

  • Comment on How to get more information on CGIs I'm watching with Unix's "top" command

Replies are listed 'Best First'.
Re: How to get more information on CGIs I'm watching with Unix's "top" command
by Fletch (Bishop) on Jul 26, 2007 at 20:28 UTC

    Presuming it's really CGI (not FastCGI) you should be able to use the ps command's e flag (again presuming the OS in question's ps supports BSD-y arguments) to dump the process' environment where you'd see things like path info and query strings and what not. You may also find several w's useful to dump more of the environment.

    Alternately if the OS supports it and permissions allow it you may be able to extract information from the /proc filesystem (e.g. on Linux you could look in /proc/##/environ).

      Yes, Fedora Core's ps accepts BSD style arguments. ps e p PID worked like a charm. Thanks.
Re: How to get more information on CGIs I'm watching with Unix's "top" command
by CountZero (Bishop) on Jul 26, 2007 at 20:28 UTC
    I think Apache-top is exactly what you need. Beware however, it is written in Python! ;-)

    CountZero

    A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

Re: How to get more information on CGIs I'm watching with Unix's "top" command
by f00li5h (Chaplain) on Jul 26, 2007 at 20:49 UTC

    if you don't mind tamperig (just a little), you can hack this onto the top of the script. You may also be able to stick it in play with a PerlModule or similar directive in an apache config...

    BEGIN { $0 = $0 . join ' - '@ENV{qw{QUERY_STRING PATH_INFO}} }

    @_=qw; ask f00li5h to appear and remain for a moment of pretend better than a lifetime;;s;;@_[map hex,split'',B204316D8C2A4516DE];;y/05/os/&print;

Re: How to get more information on CGIs I'm watching with Unix's "top" command
by spatterson (Pilgrim) on Jul 27, 2007 at 14:25 UTC
    What abount modifying index.cgi slightly so that every time it runs, it append the query string to a logfile? On second thoughts I think Apache will do this anyway, so have a look at your Apache access.log too.

    just another cpan module author
      I considered that (using the access log), but i needed to identify which PID was the culprit, as there could be many instances of index.cgi running at the same time.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://628994]
Approved by ikegami
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (9)
As of 2024-04-18 16:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found