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

Whaddya mean WalMart is sold out of Telekinesis Helmets®, Mommy?

Whaddya mean WalMart is sold out of Telekinesis Helmets®, Mommy? - The latest fashion in mindwear Hitachi: Move the Train With Your Brain The “brain-machine interface” developed by Hitachi Inc. analyzes slight changes in the brain’s blood flow and translates brain motion into electric signals. A cap connects by optical fibers to a mapping device, which links, in turn, to a toy train set via a control computer and [...] [Dvorak]
Read More

Solar motorbike uses snail shell shape for surface area

Solar motorbike uses snail shell shape for surface area -

Filed under:


Powering a car with solar panels is a relatively easy task, but on a motorbike it's a lot harder to find flat surfaces to catch the sun. That means that a solar powered motorbike has got to look rather odd in order to provide enough surface area for the panels: hence the snail shell-like design of SunRed's prototype solar powered bike. When (or if) SunRed completes a real world prototype, the bike's surface area will be 25 square feet, allowing the bike to store enough of the sun's energy to ride for 13 miles at speeds of up to 30 MPH. The motor is integrated into the wheel too, so there's no transmission. Once these "green" bike thinkers sort out the problem of running a bike without oil, we hope they'll move onto making them a little less fugly. It seems like a precedent is being set here.

[Via Autoblog Green]

 

Read | Permalink | Email this | Comments


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

[EnGadget]
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

Volvo treasure hunt delayed after locating $500 million instead

Volvo treasure hunt delayed after locating $500 million instead -

Filed under:


In an interesting turn of events, it seems like the winner of Volvo's lucrative treasure hunt won't be unearthing the $50,000 treasure anytime soon, as the automaker's hunt partner (Odyssey Marine Exploration) has happened upon an actual $500 million treasure instead. The reported fortune is located somewhere in the Atlantic Ocean -- in a secretive area known only as Black Swan -- but reports are claiming that a court in the Spanish coastal town of La Linea has "issued an order for the Spanish Guardia Civil to detain any Odyssey vessel should it leave the port of Gibraltar," which has brought about an abrupt halt to Volvo's retrieval plans. Thankfully, it sounds like the Russian winner will still be awarded the dough and a new XC70 to boot, but there's no telling how long it'll be before Odyssey is able to put aside its bigger worries and dig up the (comparatively) paltry $50k.

[Via CarTechMag]

 

Read | Permalink | Email this | Comments


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

[EnGadget]
Read More