[tpm] Best way to monitor a system call

Alex Beamish talexb-Re5JQEeQqe8AvxtiuMwx3w at public.gmane.org
Mon Dec 26 04:08:43 UTC 2005


On 12/24/05, Madison Kelly <linux-5ZoueyuiTZhBDgjK7y7TUQ at public.gmane.org> wrote:
>
> Hi all,
>
>    Is there a module that lets you call a system application (ie: rsync)
> and then watch it's status? I need to find a way to start a system
> program and then reliably report on it's status every # seconds.


When I use rsync, I use 'vv' for verbose output .. although I just look at
the output after it's done, not while it's actually running.

If your destination is local, then I suppose you could run 'du -s' on the
destination directory to get some idea of how much you've transferred so
far.

Getting back to 'vv' for verbosity, what do you get with 'vvv'? Is that
useful?

Good luck.

Alex
ps Happy whatnot to you too. :)

   I currently use the 'FileHandle' module in an attempt to do this:
>
> my $rsync = new FileHandle;
> if ( $rsync->open("$settings{rsync_path} $settings{rsync_switches}
> --files-from=$files_from $source_dir $dest_dir 2>&1 |") )
> {
>         while (<$rsync>)
>         {
>                 s/\n//;
>                 print "rsync: $_\n";
>                 if ( time > $show_time )
>                 {
>                         $show_time=time+$settings{rsync_check};
>                         print "report\n";
>                 }
>         }
> }
> else
> {
>         die "Gak!...";
> }
> $rsync->close;
> print "rsync exit: $?\n";
>
>    The problem I have currently is that the 'while (<$rsync>)' loop only
> iterates through when the 'rsync' program prints something. So, if
> 'rsync' is quiet for a long time 'print "report\n";' can be delayed.
> This causes a problem because I am using a web interface and if I can't
> print the 'report...' then the connection to the client's browser dies.
>
>    I tried playing with perl IPC earlier on (months ago now) but I could
> never quite get it working. No matter what I tried all the file handles
> would be destroyed when the child processes returned.
>
>    I don't want to lose the output from 'rsync' though so if there is an
> answer, can I still read what 'rsync' prints out as it runs?
>
> Thanks all!
>
> Madison
>
> PS - Happy (your holiday of choice)!
> PPS - I've been looking on CPAN for a module that will do the job (and I
> heard that one exists) but I can't seem to find it... Though I may well
> be blind. :P
>
> --
> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
>            Madison Kelly (Digimer)
>     TLE-BU; The Linux Experience, Back Up
> Main Project Page:  http://tle-bu.org
> Community Forum:    http://forum.tle-bu.org
> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
>
> =================================================
> This email appears to originate from the Toronto Perl Mongers Listserver.
>
> Listserv :  tpm-BnhL/mGhxvTYtjvyW6yDsg at public.gmane.org
> Administrative queries: owner-tpm-BnhL/mGhxvTYtjvyW6yDsg at public.gmane.org
>
>


--
----------
Linux, Firefox and GMail .. what a combination.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://gtalug.org/pipermail/legacy/attachments/20051225/678c6766/attachment.html>


More information about the Legacy mailing list