RE: Timing several processes

From: Anthony Akens (AAkens_at_egh.org)
Date: 12/03/03


Date: Wed, 3 Dec 2003 13:07:21 -0500
To: "Akens, Anthony" <AAkens@egh.org>,	"Tom Kinzer" <tomkinzer@earthlink.net>,	<beginners@perl.org>

To clarify, I found the following in "Learning Perl".

It doesn't quite make sense to me, though. Perhaps someone
Can clarify what's going on in this?

defined(my $pid = fork) or die "Cannot fork: $!";
unless ($pid) {
  # Child process is here
  exec "date";
  die "cannot exec date: $!";
}
# Parent process is here
waitpid($pid, 0);

It seems I could use that code, modified to start (5) processes,
And a waitpid() for each of those (5). It doesn't matter
Which processes would finish first. (I put the 5 in quotes,
Because right now I'm looking at using 5 different tools that
I want to monitor).

-Tony

-----Original Message-----
From: Akens, Anthony
Sent: Wednesday, December 03, 2003 12:58 PM
To: Tom Kinzer; beginners@perl.org
Subject: RE: Timing several processes

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:tomkinzer@earthlink.net]
Sent: Wednesday, December 03, 2003 12:35 PM
To: beginners@perl.org
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:AAkens@egh.org]
Sent: Wednesday, December 03, 2003 7:49 AM
To: beginners@perl.org
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: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
-- 
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
-- 
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org


Relevant Pages

  • RE: grep argument list too long...how to get around it?
    ... You can put arguments in a file and then open and parse the file inside ... perl. ... grep argument list too long...how to get around it? ... To unsubscribe, e-mail: beginners-unsubscribe@perl.org ...
    (perl.beginners)
  • Re: [OT] C++ programming: keeping count of data items read from file
    ... about doing signal processing and pattern recognition with that data? ... matching over large datasets, Perl is the language to use, even over ... compiled languages. ... To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx ...
    (Debian-User)
  • RE: parsing very large tcpdump files
    ... dump, and it could do it in a matter of sections, ... If you need any perl pointers, ... Reconstruct all reconstructable sessions in an easy to parse way: ... Find out quickly and easily by testing it with real-world attacks from ...
    (Focus-IDS)
  • Re: Perl <-> C language interaction
    ... > Perl is just great to do the parse of the text file, ... there are regexp libs for C (even Perl compatible ... how can I interact between a perl script to a C program. ...
    (comp.lang.perl.misc)
  • Re: [PHP] Re: Scratch that
    ... (it's a reciprocal linking script) ... I also need to know how to run a expression-ish thing so that when I ... 'parse' the text, it returns all text between x and y, but parse it ... obviously perl is supported on your server. ...
    (php.general)