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

Seagate unveils turmoil-proof EE25.2 hard drive

Seagate unveils turmoil-proof EE25.2 hard drive - As if stuffing a quarter terabyte onto a single Barracuda platter and finally matching Hitachi in the 1TB realm weren't enough to gloat about, Seagate is now unveiling a hard drive aimed squarely at those reading this from the Amazon Rainforest (or a vanilla construction area, but you understand). The second-generation SATA EE25 drive -- easily dubbed the EE25.2 -- is available in sizes up to 80GB and can handle extreme temperatures, sensational heights, 'round the clock operation, 90-percent humidity, and drops / shocks that would likely put you out of commission before your data. No word yet on pricing nor availability, but don't expect 80 gigabytes of nearly indestructible storage to come without a premium.

 

Read | Permalink | Email this | Comments


Office Depot Featured Gadget: Xbox 360 Platinum System Packs the power to bring games to life!

[EnGadget]
Read More

“Hulu” a join venture of NBC and NewsCorp debuts this month

Although this is the first time I've heard of Hulu, I'm sure its not the first time most readers have heard of Hulu. A joint venture by NBC and NewsCorp provide its tv shows, moves and mashups of AOL (TWX), Comcast (CMCSA), MSN (MSFT), MySpace, and Yahoo (YHOO). Some of the shows and movies that will be available are shown on Hulu's main page of their site. Some include Hero's, Conan, Arrested Development, 24hrs and Battlestar Galactica. I've already signed up to be apart of their beta, you can too by visiting their main page at http://www.hulu.com Read the full article at newteevee.com
Read More

WoW Database Site Sells for $1 Million

WoW Database Site Sells for $1 Million - MattHock writes "Wowhead (a WoW information database) has to ZAM (Affinity Media) for the price of $1 Million. ZAM is the owner of several other WoW databases, including Thottbot and Allakhazam. Until recently Affinity was also the owner of IGE, a highly controversial company that sold in-game wealth for real life money. Affinity recently sold IGE, which Wowhead claims as the reason they allowed the sale to go through. But did ZAM really sell IGE? The blogger who put this story online doubts that IGE and ZAM have actually distanced themselves. He believes that the supposed sale was just actually a means of restructuring to hide the relationship, similar to how IGE's relationship to Thottbot was hidden for a number of months through a convoluted set of parent companies."

Read more of this story at Slashdot.

[Slasdot]
Read More