home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / lang / perl / 7748 < prev    next >
Encoding:
Internet Message Format  |  1993-01-11  |  1.9 KB

  1. Path: sparky!uunet!cs.utexas.edu!sun-barr!news2me.EBay.Sun.COM!seven-up.East.Sun.COM!newscan!sixgun.East.Sun.COM!matthew
  2. From: matthew@sunpix.East.Sun.COM (Matthew Stier - Sun NC Development Center)
  3. Newsgroups: comp.lang.perl
  4. Subject: Paralleling data collection.
  5. Date: 11 Jan 1993 13:40:32 GMT
  6. Organization: Sun Microsystems, Research Triangle Park, NC
  7. Lines: 46
  8. Distribution: world
  9. Message-ID: <1irtcgINNh5@sixgun.East.Sun.COM>
  10. NNTP-Posting-Host: klondike.east.sun.com
  11.  
  12.  
  13. Okay folks,  here is what I'm doing, and what I'd like to do.
  14.  
  15. First, I'm using perl to collect and process data on file servers at
  16. my worksite.  I currently do this by grabbing a list of hostnames and
  17. then stepping thru each of the hosts, rsh'ling and saving the results,
  18. Then I do my processing.  Here's some sample code.
  19.  
  20. #
  21. # Compile a sorted list of hosts to check
  22. #
  23. @hostnames = ();
  24. while (($hostname, $aliases) = gethostent) {
  25.         push(@hostnames, $hostname) if $aliases =~ /\bserver\d+\b/;
  26. }
  27. @chk_hosts = sort @hostnames;
  28.  
  29. #
  30. # Run $task on each host, and save the result.
  31. #
  32. foreach $host (@chk_hosts) {
  33.         # Rsh to $host, and execute df for local filesystems only
  34.         open(RSH, "($rsh -n $host '$task') 2>&1 |") || next;
  35.         undef $/; $task{$host} = <RSH>; $/ = '\n';
  36.     close(RSH);
  37. }
  38.  
  39.  
  40. Notice that the each host is processed sequentially.  Nothing procludes 
  41. running the $task on each hosts at the same time, except my ability to
  42. write the code.  
  43.  
  44. I'd prefer to key all the data in memory. I don't want to have to juggle
  45. around with log files more than I have to.  If someone has written a 
  46. subroutine to do this, I'd like to get a copy of it.  I'm looking for
  47. something along the lines of:
  48.  
  49. %task_out = &rsh($task, @hosts);
  50.  
  51.  
  52. Thanks in advance
  53. -- 
  54. Matthew Lee Stier                          |
  55. Sun Microsystems ---  RTP, NC  27709-3447  |     "Wisconsin   Escapee"
  56. Email: matthew.stier@East.Sun.COM          |
  57. Phone: (919) 469-8300 fax: (919) 460-8355  | 
  58.