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

OiNK.cd Servers Raided, Admin Arrested

The Administrator of the most popular private Torrent Trackers OiNk.cd was arrested. The 24-year-old man from Middlesbrough was arrested. The British and Dutch Police stated that they confiscated the OiNk.cd servers in Amsterdam last week, however reports of the site still being active and fully functional 24 hours ago.
Read More

DIY “beatbox” drives old neighbors crazy

DIY "beatbox" drives old neighbors crazy -

Filed under:


We're pretty sure that he meant "boombox", but regardless, this funky little hack from music enthusiast Gregor Dauth will be making him a lot of new friends at the next break-dancing competition. For this feat of audiophile-DIY, Dauth gutted an old Grundig tape machine, added four 150-watt speakers, installed an amp he purchased on eBay, and flashed it all up with some blue fiber-optic lighting. The end-result? More ass-shaking low-end then you could possibly want.

[Via hackaday]

 

Read | Permalink | Email this | Comments


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

[EnGadget]
Read More