title: My Perl program Stas
body: <p>I need your help to implement something to monitor CPU/MEM usage during or at the end of the execution of a perl program.</p>
  
  <p>Imagine that a program that runs every N minutes which is launched by another Perl program, the execution of the latter can vary from a few seconds to 1 minute. How can I get CPU/MEM usage that result from executing this program.</p>
  
  <p>some of the requirements are:</p>
  
  <ul>
  <li>monitoring should interfere as little
  as possible with the execution of the
  program.</li>
  <li>monitoring should use a minimum of
  system resources</li>
  <li>OS independent as possible. should
  run in Linux, Win32, HP-UX, Solaris,
  AIX. Ok but lets focus first in
  Linux.</li>
  </ul>
  
  <p>I've thought in some approaches:</p>
  
  <ol>
  <li>Implement my own Devel::MyProfiler
  and run the program with -d
  "option". (ex: $ perl -dMyProfiler
  program.pl)</li>
  <li>Implement a wrapper that get stats
  every N seconds from /proc/pid or "$
  ps aux", and gets the average stats
  at the end of the program</li>
  <li>Implement a parallel program that
  makes a "$ ps aux" every N seconds</li>
  <li>Using a process trace tool!!</li>
  <li>???</li>
  </ol>
  
  <p>Any tip will be helpfull!!!</p>
  
  <p><strong>Note:</strong> this question was also posted in <a href="http://perlmonks.com/?node_id=909934" rel="nofollow">http://perlmonks.com/?node_id=909934</a></p>
  
  <p>Tks,</p>
  
  <p>gulden</p>