Super “strace” perl script to assist with debugging programs that spawn child processes.

If you have ever ran into a problem with trying to strace apache or other processes that spawn children, then this script will help you out greatly. This small perl script will grab all of the PID’s of the current process and its children and then run an strace command on all of them to provide strace output from all of apache. You can modify the strace line to your liking as well as the log names, by default it logs to a file based on date and time to the /tmp directory. Code included, click ‘Read More’.

If you have ever ran into a problem with trying to strace apache or other processes that spawn children, then this script will help you out greatly. This small perl script will grab all of the PID’s of the current process and its children and then run an strace command on all of them to provide strace output from all of apache. You can modify the strace line to your liking as well as the log names, by default it logs to a file based on date and time to the /tmp directory. Code included, click ‘Read More’.


#!/usr/bin/perl

# Do we have any input?
if(!$ARGV[0]) {
print "Super strace, will strace a running application and all of its children.\nUsage: $0 \nExample: $0 apache2\n";
exit;
}
# get the data we need!
@pids = `pgrep @ARGV[0]`;
# this is the old method, if pidof doesn't exist uncomment if the above breaks
#@pids = `ps auxwwf | grep apache | awk \'\{ print \$2\}\'`;
# get some variables for the current time! Gotta be iso 8601 YYYY-MM-DDThh:mm:ssTZD (eg 1997-07-16T19:20:30+01:00)
#my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime time;
$date = `date +%FT%H:%M:%S%:z`;
chomp ($date);
#$year += 1900;
#$mon += 1;
#$date = "$year-$mon-$mdayT$hour:$min:$sec";
# the strace command! this can be replaced with any command
$go="strace -f -s 40000 -o /tmp/sstrace-$date";
# the separator
$sep = " -p ";
$i=0;
foreach $pid (@pids) {
chomp ($pid);
$go = $go . $sep . $pid;
$i++;
}
print $go . "\n";
exec $go;


Did you like this article?


0 Shares:
You May Also Like

Rumors of new Gnash functionality exaggerated

This really sucks. When I use Debin I have to install the flash player for FireFox from a different source you get all your other applications within Debian. This is done by modifying the apt-get configuration file. Other Distribution's you have to download the linux plugin from Adobe and install it manually.
Rumors of new Gnash functionality exaggerated -

A free Flash viewer is one of the last major gaps in GNU/Linux desktop functionality, so last week's news that Gnash, the free Flash player, had reached the stage where it could play YouTube and Lulu.tv videos seemed too good to be true. Unfortunately, it was.

[Linux.com]

Auto Bounced Messages Management vBulletin Module Helps Purge Bad Email Address On Your Forum

I was browsing through my mail spool on my machine, and I noticed that there were some messages in one of my accounts for a vBulletin forum. After further review, it was some bounce backs that had accumulated from users that didn't have a valid email address. I then started to do some Google searches for a vBulletin module (vBulletin's search is horrendous and practically useless) and found this module.

WoW Sparks Family Dispute

WoW Sparks Family Dispute -

If you’re planning on having children some day then I highly suggest you listen to this audio track. I don’t feel the need to explain what’s going on other than the fact that the brat was playing WoW and his parents wanted him to stop. Oh and be sure to turn your mic off or you’ll be ridiculed for the rest of your life and live infamously on the interwebs. Enjoy!

[CrunchGear]

P2P Remains Dominant Protocol

P2P Remains Dominant Protocol - An anonymous reader writes "Last week, a press release was issued by Ellacotya that suggested something quite startling — HTTP (Hyper Text Transfer Protocol, aka Web traffic) had for the first time in four years overtaken P2P traffic. However a new article from Slyck disputes this, and contends that P2P remains the bandwidth heavyweight."

Read more of this story at Slashdot.

[Slasdot]

Red Hat Vows To Stand Up To Patent Intimidation

It looks like Red Hat isn't going to allow Microsoft to bully them into paying for Patent Protection. Microsoft has stated that linux is infringing on multiple patents and intellectual property. Red Hat provides an enterprise Linux operating system, when you're more or less purchasing continual and automatic updates and the option for Technical Support from RedHat directly. Red Hat previously provided their Variant of Linux for free, and then discontinued it. They now provide a free desktop version called Fedora there are also other variants of Fedora like CentOS which is more of an enterprise operating system very much like Red Hat but not affiliated with Red Hat directly.