yid has asked for the wisdom of the Perl Monks concerning the following question:
I've written a program that collects stats using system commands (SE Toolkit examples), re-formats the output, and sticks it into an RRD. However, it takes 10 seconds for each to run (since I'm collecting 5 second averages, & the first line of output is useless to me), and I don't want to wait 40 secs for each datapoint.
I'd like to run each of these commands in parallel, and I've looked at the Parallel:ForkManager module, but I don't think it applies since I want to run several different commands.
I also read about using the pipe function to get output back from a child process, but I need to do six at a time. I could just write 6 scipts, but that would mean an RRD for each script. Here's an example of what I'm running now (in serial):
Is there a way to run multiple subroutines at once, and keep the output? Any assistance would be greatly appreciated.sub Vmstat { $vmoutput_time = time; open (VMOUT, "$vmstat |"); $vmoutput = <VMOUT>; close (VMOUT); } sub Cpustat { $cpuoutput_time = time; open (CPUOUT, "$cpustat |"); @cpuoutput = <CPUOUT>; close (CPUOUT); } ... Vmstat () Cpustat ()
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Running Subroutines in Parallel
by Dice (Beadle) on Mar 25, 2002 at 23:49 UTC | |
|
Re: Running Subroutines in Parallel
by zengargoyle (Deacon) on Mar 26, 2002 at 02:25 UTC | |
|
Re: Running Subroutines in Parallel
by busunsl (Vicar) on Mar 26, 2002 at 06:41 UTC | |
|
Re: Running Subroutines in Parallel
by webadept (Pilgrim) on Mar 26, 2002 at 01:16 UTC | |
|
Re: Running Subroutines in Parallel
by drifter (Scribe) on Mar 26, 2002 at 01:03 UTC | |
|
Re: Running Subroutines in Parallel
by tmiklas (Hermit) on Mar 26, 2002 at 01:45 UTC | |
|
Re: Running Subroutines in Parallel
by Dinosaur (Beadle) on Mar 26, 2002 at 17:57 UTC | |
|
Re: Running Subroutines in Parallel
by yid (Initiate) on Mar 28, 2002 at 18:56 UTC |