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;

0 Shares:
You May Also Like

AT&T Hires 2,000 Extra Employees For iPhone Launch

AT&T Hires 2,000 Extra Employees For iPhone Launch -

Never again do I want to hear people complaining that they couldn’t find a summer job. Seems AT&T is so confident that people will show up for the iPhone in droves, it has taken the liberty of hiring an extra 2,000 employees to prepare for the madness. To make sense of how big the iPhone launch is going to be, here are some hot statistics:

  • 1,800 AT&T retail stores exist and will all be selling the iPhone
  • AT&T sales staff have received a total of 100,000 hours of training to sell the device, with each employee receiving about six hours of individual training
  • AT&T stores will close locally at 4:30 p.m. on that Friday to prepare for the launch, then reopen at 6 p.m. until 10 p.m. that night.

  • I’m going to be laughing all the way home if Apple and AT&T do all this training and preparation, only to find three dudes with fat wallets sitting outside a store on June 29. It’s almost here kids.

    AT&T hires 2,000 extra workers for iPhone launch [Yahoo! News]

    [CrunchGear]

    How to setup the perfect desktop in Ubuntu Gutsy Gibbon

    The following article from howtoforge.com shows how to setup the perfect Linux Desktop using Ubuntu Gutsy Gibbon. If you've always wanted to use Ubuntu as your desktop OS, then give this article a read and follow along using a Virtual Machine or VMWare Player.

    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.