It seems as if my example was doing what it was intended to do, the "problem" was in the exec for sar...
It seems that using redirection with the sar command is a little different then I expected... it does not write anything to the output file until it is finished. As for the "Waiting..." line not showing up, when I had done my testing I had left out the /n - which caused it not to print until later. Once I added the /n (as you see in the code below) it printed when I expected it to. Thanks for the help... -Tony -----Original Message----- From: Akens, Anthony Sent: Wednesday, December 03, 2003 1:50 PM To: Wiggins d Anconia; Tom Kinzer; [EMAIL PROTECTED] Subject: RE: Timing several processes Here's the sample code I'm trying... In essence I would expect to see The following output: Running vmstat Running sar Waiting... (at this point a long wait while sar and vmstat finish) Done! Instead I am seeing: Running vmstat Running sar (The long wait is here) Waiting... Done! In watching the file sizes, I can see both files are created at the Same time, but sar does not produce any output in its file until Vmstat finishes. -Tony #!/usr/bin/perl -w use strict; print "Running vmstat\n"; defined(my $vmstat_pid = fork) or die "Cannot fork: $!"; unless ($vmstat_pid) { exec "vmstat 5 5 > /log/monitor/delta/vmstat.out"; die "cannot exec vmstat: $!"; } print "Running sar\n"; defined(my $sar_pid = fork) or die "Cannot fork: $!"; unless ($sar_pid) { exec "sar 5 5 > /log/monitor/delta/sar.out"; die "cannot exec date: $!"; } print "Waiting...\n"; waitpid($vmstat_pid, 0); waitpid($sar_pid, 0); print "done!\n"; -----Original Message----- From: Wiggins d Anconia [mailto:[EMAIL PROTECTED] Sent: Wednesday, December 03, 2003 1:31 PM To: Akens, Anthony; Tom Kinzer; [EMAIL PROTECTED] Subject: RE: Timing several processes I was going to suggest POE as well, 'til I saw that little word 'simple' :-)... Have you read: perldoc perlipc perldoc -f fork perldoc -f wait perldoc -f waitpid Of course POE is what makes keeping track of all those spun off processes trivial, but learning it is I will admit not trivial... http://danconia.org > I already have some ideas for how I want to build the page, how to > parse the data I will generate, etc. > > As I said, I've looked at some of the other tools out there, and want > to stick to some simple perl code to parse out the information and > return the results. > > The only bit I'm not sure of is how to tell if all forked processes > have completed before moving on. > > > -Tony > > -----Original Message----- > From: Tom Kinzer [mailto:[EMAIL PROTECTED] > Sent: Wednesday, December 03, 2003 12:35 PM > To: [EMAIL PROTECTED] > Subject: RE: Timing several processes > > > http://poe.perl.org > > Maybe this would be a good job for POE? > > -Tom Kinzer > > > -----Original Message----- > From: Akens, Anthony [mailto:[EMAIL PROTECTED] > Sent: Wednesday, December 03, 2003 7:49 AM > To: [EMAIL PROTECTED] > Subject: Timing several processes > > > Hi all! > > I'm wanting to write a simple web-based tool to see the status of > several servers at a glance. I know there are many solutions > existing, but I can't learn as much about perl by just using one of > those as I can by writing my own. The first step I want to do is call > a script from cron that runs several basic monitoring tools (sar, > vmstat, df, iostat, etc) and saves the output of each to a file. Then > I'd parse those files up, and write a summary file. > > Easy enough. And I could certainly do it with by calling the tools > one at a time. However, I'd like to get roughly 1 minute of vmstat, > iostat, and sar output.... Simultaneously. So I'm supposing I'd want > to fork off each process, and then when those are all done come back > and run a script that then parses those results out for the individual > statistics I'm looking for. > > I've never used fork before, and while it looks fairly straight > forward what I am not sure of is how to make sure all of those forked > processes have completed before moving on and parsing the files. > > Any pointers? > > Thanks in advance > > -Tony > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]