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 ()
In reply to Running Subroutines in Parallel by yid
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |