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

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

Annoyed, hospitalized teen unplugs neighbor’s life support

Annoyed, hospitalized teen unplugs neighbor's life support -

Filed under:

It should probably go without saying that anything connected to a power source within the confines of a hospital has a fair shot at being pertinent to the livelihood of at least one individual, but obviously a 17-year old teenager in Germany needed the memo. After the perpetual noise of what would prove to be his neighbor's life support machine "got on his nerves," he proceeded to simply unplug the device without precaution in order to ensure that "he got his peace and quiet." Of course, we can only assume that the sirens and squeals that were emitted due to his misreckoning were immensely louder than the prior hum, but some folks just love to learn the hard way. Thankfully, medical personnel stepped in and saved the man from perishing, but the teen at fault lost a lot more sleep after that whilst being questioned by police.

[Via El Reg, image courtesy of NAIAD]

 

Read | Permalink | Email this | Comments


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

[EnGadget]
Read More

10 Ways To Speed Up Digg

Have you found Digg slow during the peak hours? Well peertopress.com has a top 10 for Kevin Rose on how to speed up Digg. The article was put on Digg's front page, and the comments left on peertopress.com website are pretty hilarious.
Read More

Creators Of Mobile Chat For the iPhone Twenty08 Hires AplloIM Developer

If you bought the iPhone when it first came out, you had two choices for Instant Messaging. Twenty08's MobileChat and Alex Schaefer's ApolloIM. Twenty08 has now hired Alex Schaefer to work exclusively on MobileChat
twenty08 would like to formally welcome aboard…Alex Schaefer. Many of you may know him as the founder of the world’s first Native iPhone IM Application, ApolloIM. ApolloIM was an amazing application and during it’s run, MobileChat and Apollo stood head to head and constantly battled to create the better app. (Friendly war of course!) The best part about it was that no one won! Only our respective users benefited from the friendly competition, and you can’t ask for anything better than that as far as I’m concerned. Now with Alex working on our side, we believe that MobileChat will be able to rise up and regain its glory as the number one iPhone application that we all know it can be. He is a very talented developer (plus a great guy) who has already brought some great ideas to the table and we’re all very excited to see our new-found relationship grow.
Read the full article on Twenty08's site. MobileChat's website
Read More

Guide to upgrading Drupal using SSH Commands

A well written guide on how to upgrade Drupal using SSH commands
This guide is meant to augment the official Upgrade guide. Please read the official upgrade steps in UPGRADE.txt as well as in the Drupal.org Dcoumentation thoroughly to ensure that you understand every aspect of the upgrade process. This guide is for more advanced users with SSH experience.
Read More