Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Information about running Perl script

by Sewi (Friar)
on Jan 02, 2012 at 07:14 UTC ( [id://945846]=perlquestion: print w/replies, xml ) Need Help??

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

Happy new year monks,

strace shows syscalls being executed by a running process, lsof (or /proc/PID/fd) shows information about open files), but are there any other (Perl-specific) tools/ways/tricks to get information about an already-running process?

I got some Perl jobs which sometimes run for a long time (hang but recover after some - usually huge - delay). In this case, I know that this is database/mySQL-related and I know which few source lines are looping (waiting for a specific mySQL state), but having any additional information about them would be great, same for other tasks which rarly hang due to other reasons which usually arent' reproduceable.

I can't start all these jobs in the debugger and they're running unattended, only hang/crash-reports show their results and I want to extend these reports.

Thank you.

Replies are listed 'Best First'.
Re: Information about running Perl script
by Anonymous Monk on Jan 02, 2012 at 07:31 UTC

    but are there any other (Perl-specific) tools/ways/tricks to get information about an already-running process?

    Other than turning on logging ( like  DBI->trace(3), or log4perl...), say through statinc ( or log4perl equivalent ), no, there isn't.

Re: Information about running Perl script
by Eliya (Vicar) on Jan 02, 2012 at 12:15 UTC

    There's also ltrace, which is similar to strace but can also trace function calls into dynamic libraries.

    But note that it would typically produce huge amounts of output, and as a result may slow down processes significantly. So, it's not necessarily a good idea to use it as a general purpose long-time monitoring tool for longer running "production" processes. Attaching it in a specific problem situation, though, might help figuring out what's going on.

Re: Information about running Perl script
by Sewi (Friar) on Jan 02, 2012 at 20:20 UTC

    Thank you.

    Sorry, I don't want to monitor the jobs all the time they're running, just "attach" to a already-running job once he's dead. We got a tool which checks the estimated maximum run time for each script and creates some seconds strace and a lsof report for the process before killing it.

    Here is what I did so far:

    open my $strace_logger,'>','/dev/null'; $strace_logger->autoflush(1); [...] print $strace_logger "SHORT STATUS MSG";
    There is no output out of it (everything is going to /dev/null, so no I/O usage, but the print triggers a syscall visible in strace - including some bytes of the content.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2024-04-20 00:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found