Nice! Which device(s) does DiskFree.pm check for space on? I occasionally run out of room in /tmp, so I would want it to check my swap space.
Can we remove these? (All but the .pm and README files.) trunk/lib/Filesys/Changes trunk/lib/Filesys/MANIFEST trunk/lib/Filesys/Makefile.PL trunk/lib/Filesys/eg/ trunk/lib/Filesys/eg/perldf trunk/lib/Filesys/eg/silly trunk/lib/Filesys/test.pl -Ethan On Tue, Jul/22/2008 09:27:04PM, jsquy...@osl.iu.edu wrote: > Author: jsquyres > Date: 2008-07-22 21:27:04 EDT (Tue, 22 Jul 2008) > New Revision: 1216 > URL: https://svn.open-mpi.org/trac/mtt/changeset/1216 > > Log: > Fixes #370: have MTT exit if there isn't enough disk space left. > > Added: > trunk/lib/Filesys/ > trunk/lib/Filesys/Changes > trunk/lib/Filesys/DiskFree.pm > trunk/lib/Filesys/MANIFEST > trunk/lib/Filesys/Makefile.PL > trunk/lib/Filesys/README > trunk/lib/Filesys/README.mtt > trunk/lib/Filesys/eg/ > trunk/lib/Filesys/eg/perldf (contents, props changed) > trunk/lib/Filesys/eg/silly (contents, props changed) > trunk/lib/Filesys/test.pl > Text files modified: > trunk/client/mtt | 11 ++++---- > > trunk/lib/MTT/Globals.pm | 5 +++ > > trunk/lib/MTT/MPI/Get.pm | 2 > > trunk/lib/MTT/MPI/Install.pm | 4 +- > > trunk/lib/MTT/Test/Build.pm | 4 +- > > trunk/lib/MTT/Test/Get.pm | 2 > > trunk/lib/MTT/Test/Run.pm | 4 +- > > trunk/lib/MTT/Test/RunEngine.pm | 6 ++-- > > trunk/lib/MTT/Util.pm | 50 > ++++++++++++++++++++++++++++++++++++++- > trunk/samples/ompi-core-template.ini | 17 +++++++++++++ > > 10 files changed, 86 insertions(+), 19 deletions(-) > > Modified: trunk/client/mtt > ============================================================================== > --- trunk/client/mtt (original) > +++ trunk/client/mtt 2008-07-22 21:27:04 EDT (Tue, 22 Jul 2008) > @@ -112,6 +112,7 @@ > use MTT::Values; > use MTT::Timer; > use MTT::Util; > +use Filesys::DiskFree; > > my @file_arg; > my $stdin_arg; > @@ -492,31 +493,31 @@ > MTT::Reporter::Init($ini); > } > > - if ($mpi_get && !MTT::Util::find_terminate_file()) { > + if ($mpi_get && !MTT::Util::time_to_terminate()) { > &MTT::Timer::start($time_phases); > MTT::MPI::Get::Get($ini, $source_dir, $force_arg); > &MTT::Timer::stop(); > &MTT::Timer::print("Phase: MPI Get", $time_phases, 1); > } > - if ($mpi_install && !MTT::Util::find_terminate_file()) { > + if ($mpi_install && !MTT::Util::time_to_terminate()) { > &MTT::Timer::start($time_phases); > MTT::MPI::Install::Install($ini, $ini_full, $install_dir, > $force_arg); > &MTT::Timer::stop(); > &MTT::Timer::print("Phase: MPI Install", $time_phases, 1); > } > - if ($test_get && !MTT::Util::find_terminate_file()) { > + if ($test_get && !MTT::Util::time_to_terminate()) { > &MTT::Timer::start($time_phases); > MTT::Test::Get::Get($ini, $source_dir, $force_arg); > &MTT::Timer::stop(); > &MTT::Timer::print("Phase: Test Get", $time_phases, 1); > } > - if ($test_build && !MTT::Util::find_terminate_file()) { > + if ($test_build && !MTT::Util::time_to_terminate()) { > &MTT::Timer::start($time_phases); > MTT::Test::Build::Build($ini, $ini_full, $install_dir, $force_arg); > &MTT::Timer::stop(); > &MTT::Timer::print("Phase: Test Build", $time_phases, 1); > } > - if ($test_run && !MTT::Util::find_terminate_file()) { > + if ($test_run && !MTT::Util::time_to_terminate()) { > &MTT::Timer::start($time_phases); > MTT::Test::Run::Run($ini, $ini_full, $install_dir, $runs_data_dir, > $force_arg); > > Added: trunk/lib/Filesys/Changes > ============================================================================== > --- (empty file) > +++ trunk/lib/Filesys/Changes 2008-07-22 21:27:04 EDT (Tue, 22 Jul 2008) > @@ -0,0 +1,27 @@ > +Revision history for Perl extension Filesys::DiskFree. > + > +0.06 Fri Oct 23 18:26:19 EDT 1998 > + - Now supports HP-UX, thanks to Richard Paul for the patch. > + > +0.05 Wed Aug 26 23:54:15 EDT 1998 > + - Now supports OSF/1, thanks to Eric Foster-Johnson for the details. > + > +0.04 Sat Aug 1 12:15:42 EDT 1998 > + - Fixes problem if passed a barefilename, without any '/'. > + - Bug fix in 'silly' example, accidentally deleted a ; > + - perldf now works on filesystems with 0% free (eg psuedo-fs), and > + formats filesystems with <10% free without decimals. Also changed > + to round to nearest percentage, instead of rounding down. > + - thanks to Lupe Christoph for spotting these problems. > + > +0.03 Fri Jul 24 16:28:54 EDT 1998 > + - Added Irix format, thanks Danial F. Sully for the patch. > + - Changed Solaris to work across more versions of Solaris, > + thanks to Lupe Christoph for the details. > + > +0.02 Thu Jul 23 15:13:20 1998 > + - Fixed a mistake in the documentation > + > +0.01 Tue Jul 14 10:32:48 1998 > + - original version; created by h2xs 1.18 > + > > Added: trunk/lib/Filesys/DiskFree.pm > ============================================================================== > --- (empty file) > +++ trunk/lib/Filesys/DiskFree.pm 2008-07-22 21:27:04 EDT (Tue, 22 Jul > 2008) > @@ -0,0 +1,351 @@ > +# > +# > +# > +# Copyright (c) 1998 Alan R. Barclay. All rights reserved. This program > +# is free software; you can redistribute it and/or modify it under > +# the same terms as Perl itself. > + > +package Filesys::DiskFree; > + > +use Carp; > +use strict; > + > +#qw(); > + > +use vars qw($VERSION $Format %Df); > + > +$VERSION = 0.06; > + > +# > +# The format table > +# > +# Note, the format names are not gauranteed. If I find that there > +# is a reason to rename one, then they be renamed. > +# > + > +%Df = ( > + 'linux' => { > + 'blocks' => "df -P", > + 'inodes' => "df -Pi", > + 'format' => "linuxish", > + }, > + 'solaris' => { > + 'blocks' => "df -k", > + 'inodes' => "df -k -o i -F ufs", > + 'format' => "svish", > + }, > + 'bsdos' => { > + 'blocks' => "df -i", > + 'inodes' => "df -i", > + 'format' => 'bsdish', > + }, > + > + 'irix' => { > + 'blocks' => "df", > + 'inodes' => "df -i", > + 'format' => "irixish", > + }, > + 'hpux' => { > + 'blocks' => "bdf -l -i", > + 'inodes' => "bdf -l -i", > + 'format' => 'hpuxish', > + }, > + 'dec_osf' => { > + 'blocks' => "df", > + 'inodes' => "df -i", > + 'format' => 'svish', > + }, > +); > + > +use strict; > + > +BEGIN { > + $Format = $^O; > +} > + > +sub new { > + my $proto = shift; > + my $class = ref($proto) || $proto; > + my $self = { > + FORMAT => $Format, > + DEVICES => undef, > + MOUNTS => undef, > + MODE => 'blocks' > + }; > + > + bless ($self, $class); > + return $self; > +} > + > +sub set(){ > + my $self=shift; > + my @return; > + > + return undef if(defined $self->{'DEVICES'}); > + > + if(@_){ > + if($_[0] =~ m/format/i){ > + push(@return,$self->{'FORMAT'}); > + $self->{'FORMAT'}=$_[1] if(defined $_[1]); > + } > + > + if($_[0] =~ m/mode/i){ > + push(@return,$self->{'MODE'}); > + $self->{'MODE'}='blocks' if($_[1] =~ m/block/i and defined $_[1]); > + $self->{'MODE'}='inodes' if($_[1] =~ m/inode/i and defined $_[1]); > + } > + } > + return @return; > +} > + > +sub command () { > + my $self=shift; > + return $Df{"\L".$self->{'FORMAT'}."\E"}{$self->{'MODE'}}; > +} > +sub df(){ > + my $self=shift; > + my $cmd="df"; > + > + $cmd=$self->command() or > + croak "No df command known for format ".$self->{'FORMAT'}; > + open(HANDLE,"$cmd|") or croak("Cannot fork $!"); > + return $self->load(\*HANDLE); > + close(HANDLE) or croak("Cannot df $!"); > +} > + > +sub load() { > + my $self=shift; > + my $handle=shift; > + > + if(ref $handle eq "GLOB"){ > + while(<$handle>){ > + $self->readline($_); > + } > + } else { > + map { $self->readline($_) } split(/$\//,$handle); > + } > + return 'true'; > +} > + > +sub readline() { > + my $self=shift; > + my $line=shift; > + my ($device,$btotal,$bused,$bavail,$iused,$iavail,$mount, > + $total,$used,$avail); > + > + chomp($line); > + > + $_=$Df{"\L".$self->{'FORMAT'}."\E"}{'format'}; > + > + if(/linuxish/i){ > + return undef if($line =~ /^Filesystem.*Mounted on/i); > + ($device,$total,$used,$avail,undef,$mount)=split(' ',$line); > + if($self->{'MODE'} eq 'blocks'){ > + $total *= 1024; > + $used *= 1024; > + $avail *= 1024; > + } > + } elsif(/svish/i){ > + return undef if($line =~ /^Filesystem.*Mounted on/i); > + if($self->{'MODE'} eq 'blocks'){ > + ($device,$total,$used,$avail,undef,$mount)=split(' ',$line); > + $total *= 1024; > + $used *= 1024; > + $avail *= 1024; > + } else { > + ($device,$used,$avail,undef,$mount)=split(' ',$line); > + $total=$used+$avail; > + } > + } elsif(/bsdish/){ > + return undef if($line =~ /^Filesystem.*Mounted on/i); > + ($device,$btotal,$bused,$bavail,undef,$iused,$iavail,undef,$mount)= > + split(' ',$line); > + if($self->{'MODE'} eq 'blocks'){ > + $total=$btotal*512; > + $used=$bused*512; > + $avail=$bavail*512; > + } elsif($self->{'MODE'} eq 'inodes'){ > + $total=undef; > + $used=$iused*512; > + $avail=$iavail*512; > + } > + } elsif(/irixish/){ > + return undef if($line =~ /^Filesystem.*Mounted on/i); > + if($self->{'MODE'} eq 'blocks'){ > + ($device,undef,$btotal,$bused,$bavail,undef,$mount)=split(' > ',$line); > + $total=$btotal*512; > + $used=$bused*512; > + $avail=$bavail*512; > + } elsif($self->{'MODE'} eq 'inodes'){ > + > ($device,undef,$btotal,$bused,$bavail,undef,$iused,$iavail,undef,$mount)= > + split(' ',$line); > + return undef if $iused =~ /[A-Za-z]+/ or $iused == 0; > + $total = ($iused + $iavail) * 512; > + $used=$iused*512; > + $avail=$iavail*512; > + } > + } elsif(/hpuxish/){ > + return undef if($line =~ /^Filesystem.*Mounted on/i); > + ($device,$btotal,$bused,$bavail,undef,$iused,$iavail,undef,$mount)= > + split(' ',$line); > + if($self->{'MODE'} eq 'blocks'){ > + $total=$btotal*1024; > + $used=$bused*1024; > + $avail=$bavail*1024; > + } elsif($self->{'MODE'} eq 'inodes'){ > + $total=($iused + $iavail); > + $used=$iused; > + $avail=$iavail; > + } > + } else { > + croak "Unknown encoding ".$Df{"\L".$self->{'FORMAT'}."\E"}{'format'}. > + " for format ".$self->{'FORMAT'}; > + } > + $self->{'MOUNTS'}{$mount}=$device; > + $self->{'DEVICES'}{$device}={}; > + $self->{'DEVICES'}{$device}{'device'}=$device; > + $self->{'DEVICES'}{$device}{'total'} =$total; > + $self->{'DEVICES'}{$device}{'used'} =$used; > + $self->{'DEVICES'}{$device}{'avail'} =$avail; > + $self->{'DEVICES'}{$device}{'mount'} =$mount; > +} > + > +sub device() { return extract(@_,'device'); } > +sub total() { return extract(@_,'total'); } > +sub used() { return extract(@_,'used'); } > +sub avail() { return extract(@_,'avail'); } > +sub mount() { return extract(@_,'mount'); } > + > +sub extract () { > + my $self=shift; > + my $device; > + if(@_) { > + my $thingy=shift; > + if(defined($self->{'DEVICES'}{$thingy})){ > + $device=$thingy; > + } else { > + return undef unless(defined($self->{'MOUNTS'})); > + while(not defined($self->{'MOUNTS'}{$thingy})){ > + return undef if($thingy eq '/'); > + $thingy =~ s!/[^/]*?$!! unless($thingy =~ s!/$!!); > + $thingy = "/" unless($thingy =~ "/"); > + } > + $device=$self->{'MOUNTS'}{$thingy} > + } > + return $self->{'DEVICES'}{$device}{$_[0]}; > + } > + return undef; > +} > + > +sub disks () { > + my $self=shift; > + return undef unless(defined($self->{'MOUNTS'})); > + return keys %{$self->{'MOUNTS'}}; > +} > + > +1; > +__END__ > + > + > +=head1 NAME > + > +Filesys::DiskFree -- perform the Unix command 'df' in a portable fashion > + > +=head1 SYNOPSIS > + > + use Filesys::DiskFree; > + > + $handle = new Filesys::DiskFree; > + $handle->df(); > + print "The root device is ".$handle->device("/")."\n"; > + print "It has ".$handle->avail("/")." bytes available\n"; > + print "It has ".$handle->total("/")." bytes total\n"; > + print "It has ".$handle->used("/")." bytes used\n"; > + > +=head1 DESCRIPTION > + > +Filesys::DiskFree does about what the unix command df(1) does, listing > +the mounted disks, and the amount of free space used & available. > + > +=head2 Functions > + > +=over 4 > + > +=item Filesys::DiskFree->set('option' => 'value') > + > +Sets various options within the module. > + > +The most common option to change is the mode, which can be either > +blocks or inodes. By default, blocks is used. > + > +If reading a file from a 'foreign' OS using the load() function, > +format may be used, which takes the name of an OS as set in the $^O > +variable. > + > +Returns the previous values of the options. > + > +=item Filesys::DiskFree->df() > + > +Perfoms a 'df' command, and stores the values for later use. > + > +=item Filesys::DiskFree->command() > + > +Returns the appropriate command to do a 'df' command, for the current > +format. This is used when you wish to call a df on a remote system. > +Use the df() method for local df's. > + > +Returns undef if there isn't an appropriate command. > + > +=item Filesys::DiskFree->load($line) > + > +Reads in the output of a 'df', $line can be either a scalar or a filehandle. > +If $line is a filehandle, then the filehandle is read until EOF. > + > +Returns undef on failure > + > +=item Filesys::DiskFree->disks() > + > +Returns all the disks known about > + > +=item Filesys::DiskFree->device($id) > + > +Returns the device for $id, which is a scalar containing the device name of > +a disk or a filename, in which case the disk that filename in stored upon > +is used. If a filename doesn't begin with '/', then it is treated as > +if is '/'. > + > +=item Filesys::DiskFree->mount($id) > + > +Returns the mount point for $id, which is a scalar containing the device > +name of a disk or a filename, in which case the disk that filename in > +stored upon is used. > + > +=item Filesys::DiskFree->avail($id) > + > +Returns the amount of available space in bytes for $id, which is a scalar > +containing the device name of a disk or a filename, in which case the > +disk that filename in stored upon is used. > + > +=item Filesys::DiskFree->total($id) > + > +Returns the amount of total space in bytes for $id, which is a scalar > +containing the device name of a disk or a filename, in which case the > +disk that filename in stored upon is used. > + > +=item Filesys::DiskFree->used($id) > + > +Returns the amount of used space in bytes for $id, which is a scalar > +containing the device name of a disk or a filename, in which case the > +disk that filename in stored upon is used. > + > +=head1 BUGS > + > +It should support more formats, currently only Linux, Irix, Solaris & > +BSD are supported. Other formats will be added as available. Please sent > +your OS Name & version, the 'best' df options to use, and the output of > +df with those options, and the contents of $^O if you have access to a > +non-supported format. > + > +=head1 AUTHOR > + > +Alan R. Barclay <gori...@drink.com> > > Added: trunk/lib/Filesys/MANIFEST > ============================================================================== > --- (empty file) > +++ trunk/lib/Filesys/MANIFEST 2008-07-22 21:27:04 EDT (Tue, 22 Jul > 2008) > @@ -0,0 +1,8 @@ > +Changes > +DiskFree.pm > +MANIFEST > +Makefile.PL > +README > +eg/perldf > +eg/silly > +test.pl > > Added: trunk/lib/Filesys/Makefile.PL > ============================================================================== > --- (empty file) > +++ trunk/lib/Filesys/Makefile.PL 2008-07-22 21:27:04 EDT (Tue, 22 Jul > 2008) > @@ -0,0 +1,7 @@ > +use ExtUtils::MakeMaker; > +# See lib/ExtUtils/MakeMaker.pm for details of how to influence > +# the contents of the Makefile that is written. > +WriteMakefile( > + 'NAME' => 'Filesys::DiskFree', > + 'VERSION_FROM' => 'DiskFree.pm', # finds $VERSION > +); > > Added: trunk/lib/Filesys/README > ============================================================================== > --- (empty file) > +++ trunk/lib/Filesys/README 2008-07-22 21:27:04 EDT (Tue, 22 Jul 2008) > @@ -0,0 +1,86 @@ > +NAME > + Filesys::DiskFree -- perform the Unix command 'df' in a portable fashion > + > +SYNOPSIS > + use Filesys::DiskFree; > + > + $handle = new Filesys::DiskFree; > + $handle->df(); > + print "The root device is ".$handle->device("/")."\n"; > + print "It has ".$handle->avail("/")." bytes available\n"; > + print "It has ".$handle->total("/")." bytes total\n"; > + print "It has ".$handle->used("/")." bytes used\n"; > + > +DESCRIPTION > + Filesys::DiskFree does about what the unix command df(1) does, listing > + the mounted disks, and the amount of free space used & available. > + > + Functions > + > + Filesys::DiskFree->set('option' => 'value') > + Sets various options within the module. > + > + The most common option to change is the mode, which can be either > + blocks or inodes. By default, blocks is used. > + > + If reading a file from a 'foreign' OS using the load() function, > + format may be used, which takes the name of an OS as set in the $^O > + variable. > + > + Returns the previous values of the options. > + > + Filesys::DiskFree->df() > + Perfoms a 'df' command, and stores the values for later use. > + > + Filesys::DiskFree->command() > + Returns the appropriate command to do a 'df' command, for the > + current format. This is used when you wish to call a df on a remote > + system. Use the df() method for local df's. > + > + Returns undef if there isn't an appropriate command. > + > + Filesys::DiskFree->load($line) > + Reads in the output of a 'df', $line can be either a scalar or a > + filehandle. If $line is a filehandle, then the filehandle is read > + until EOF. > + > + Returns undef on failure > + > + Filesys::DiskFree->disks() > + Returns all the disks known about > + > + Filesys::DiskFree->device($id) > + Returns the device for $id, which is a scalar containing the device > + name of a disk or a filename, in which case the disk that filename > + in stored upon is used. > + > + Filesys::DiskFree->mount($id) > + Returns the mount point for $id, which is a scalar containing the > + device name of a disk or a filename, in which case the disk that > + filename in stored upon is used. > + > + Filesys::DiskFree->avail($id) > + Returns the amount of available space in bytes for $id, which is a > + scalar containing the device name of a disk or a filename, in which > + case the disk that filename in stored upon is used. > + > + Filesys::DiskFree->total($id) > + Returns the amount of total space in bytes for $id, which is a > + scalar containing the device name of a disk or a filename, in which > + case the disk that filename in stored upon is used. > + > + Filesys::DiskFree->used($id) > + Returns the amount of used space in bytes for $id, which is a scalar > + containing the device name of a disk or a filename, in which case > + the disk that filename in stored upon is used. > + > +BUGS > + It should support more formats, currently only Linux, Irix, Solaris > + & BSD are supported. Other formats will be added as available. > + Please sent your OS Name & version, the 'best' df options to use, > + and the output of df with those options, and the contents of $^O if > + you have access to a non-supported format. > + > +AUTHOR > + Alan R. Barclay <gori...@drink.com> > + > > Added: trunk/lib/Filesys/README.mtt > ============================================================================== > --- (empty file) > +++ trunk/lib/Filesys/README.mtt 2008-07-22 21:27:04 EDT (Tue, 22 Jul > 2008) > @@ -0,0 +1,4 @@ > +All the files in this directory are the Filesys::DiskFree distribution > +from search.cpan.org: > + > +http://search.cpan.org/CPAN/authors/id/A/AB/ABARCLAY/Filesys-DiskFree-0.06.tar.gz > > Added: trunk/lib/Filesys/eg/perldf > ============================================================================== > --- (empty file) > +++ trunk/lib/Filesys/eg/perldf 2008-07-22 21:27:04 EDT (Tue, 22 Jul > 2008) > @@ -0,0 +1,50 @@ > +#!/usr/local/bin/perl -w > +use strict; > + > +# > +# A version of 'df' which produces the same output on any system > +# > + > +use Filesys::DiskFree; > + > +# > +# Create a df handle > +# > +my $df = new Filesys::DiskFree; > + > +# > +# Call the actual df command > +# > +$df->df(); > + > + > +my $disk; > +# > +# Output the information > +# > +my $percent; > +foreach $disk(sort($df->disks)){ > + my $total=($df->used($disk)+$df->avail($disk)); > + $percent=0; > + if($total != 0){ > + $percent=sprintf("%2.0f",($df->used($disk)/$total)*100); > + } > + write; > +} > + > +# > +# Format for the header > +# > +format STDOUT_TOP = > +Filesystem 1024-blocks Used Available Capacity Mounted on > +. > + > +# > +# Format for each data item, notice the /1024's, all sizes are stored in > bytes > +# for portablity > +# > +format STDOUT = > +@<<<<<<<<<<<<<<<<<< @>>>>>>> @>>>>>> @>>>>>>> @>>% > @<<<<<<<<<<<<<<<<<<<<<<< > +$df->device($disk), $df->total($disk)/1024, > $df->used($disk)/1024,$df->avail($disk)/1024, $percent,$df->mount($disk) > +. > + > > Added: trunk/lib/Filesys/eg/silly > ============================================================================== > --- (empty file) > +++ trunk/lib/Filesys/eg/silly 2008-07-22 21:27:04 EDT (Tue, 22 Jul > 2008) > @@ -0,0 +1,72 @@ > +#!/usr/local/bin/perl -w > +# > +# Silly program which shows using this module > +# > +use strict; > + > +use Filesys::DiskFree; > + > +# Create a new handle > +my $df = new Filesys::DiskFree; > + > +# Set the modes > +$df->set('-mode'=>'blocks'); > +$df->set('-format'=>'solaris'); > + > +# Remember what format we're using > +print $df->set('format'),"\n"; > + > +# Load a scalar with the right values. > +my $line= <<EOL; > +/dev/hdc1 366312 345605 1788 99% /home > +/dev/hdd1 366312 345605 1788 99% /usr > +EOL > + > +# And load the scalar into the class > +$df->load($line); > + > +# Some prints of info > +print $df->device('/dev/hdc1')." is mounted on > ".$df->mount('/dev/hdc1')."\n"; > + > +$df = new Filesys::DiskFree; > +$df->set('-mode'=>'blocks'); > +$df->set('-format'=>'bsdos'); > + > +$line= <<EOL; > +Filesystem 512-blocks Used Avail Capacity iused > ifree %iused Mounted on > +/dev/sd0a 396670 191816 185020 51% 1611 > 48307 3% / > +/dev/sd0h 6816728 2251342 4224548 35% 12738 > 840380 1% /home > +EOL > + > +# And load the scalar into the class > +$df->load($line); > + > +print $df->device('/home')." is mounted on ".$df->mount('/home')."\n"; > + > +# Start again, create another new handle > +$df=new Filesys::DiskFree; > + > +# This time we're using a file handle. This is a silly example, > +# because you could do the same thing with just the df() method, > +# but you could use rsh or some similar method to do this on a > +# remote machine > +my $cmd=$df->command(); > +open(DF,"$cmd|") or die "Cannot $cmd $!\n"; > + > +$df->load(\*DF); > + > +close(DF) or die "Cannot $cmd $! $?\n"; > + > +# Now output the disks > +my @disks=$df->disks(); > + > +print join(" ",@disks); > + > +print "\n"; > + > +# Finally, output the # of free inodes on / > +$df=new Filesys::DiskFree; > + > +$df->set('-mode'=>'inodes'); > +$df->df(); > +print "Disk ".$df->device('/')." has ",$df->avail('/')," inodes available\n"; > > Added: trunk/lib/Filesys/test.pl > ============================================================================== > --- (empty file) > +++ trunk/lib/Filesys/test.pl 2008-07-22 21:27:04 EDT (Tue, 22 Jul 2008) > @@ -0,0 +1,20 @@ > +# Before `make install' is performed this script should be runnable with > +# `make test'. After `make install' it should work as `perl test.pl' > + > +######################### We start with some black magic to print on failure. > + > +# Change 1..1 below to 1..last_test_to_print . > +# (It may become useful if the test is moved to ./t subdirectory.) > + > +BEGIN { $| = 1; print "1..1\n"; } > +END {print "not ok 1\n" unless $loaded;} > +use Filesys::DiskFree; > +$loaded = 1; > +print "ok 1\n"; > + > +######################### End of black magic. > + > +# Insert your test code below (better if it prints "ok 13" > +# (correspondingly "not ok 13") depending on the success of chunk 13 > +# of the test code): > + > > Modified: trunk/lib/MTT/Globals.pm > ============================================================================== > --- trunk/lib/MTT/Globals.pm (original) > +++ trunk/lib/MTT/Globals.pm 2008-07-22 21:27:04 EDT (Tue, 22 Jul 2008) > @@ -64,6 +64,9 @@ > after_all_exec => undef, > after_all_exec_timeout => 10, > after_all_exec_pass => "&and(&cmd_wifexited(), &eq(&cmd_wexitstatus(), > 0))", > + > + min_disk_free => "5%", > + min_disk_free_wait => "60", > }; > > #-------------------------------------------------------------------------- > @@ -111,7 +114,7 @@ > > # Simple parameters > > - my @names = qw/max_np textwrap drain_timeout trim_save_successful > trim_save_failed trial http_proxy https_proxy ftp_proxy terminate_files > pause_files/; > + my @names = qw/max_np textwrap drain_timeout trim_save_successful > trim_save_failed trial http_proxy https_proxy ftp_proxy terminate_files > pause_files min_disk_free min_disk_free_wait/; > foreach my $t (qw/before after/) { > foreach my $a (qw/all each/) { > push(@names, $t . "_" . $a . "_exec"); > > Modified: trunk/lib/MTT/MPI/Get.pm > ============================================================================== > --- trunk/lib/MTT/MPI/Get.pm (original) > +++ trunk/lib/MTT/MPI/Get.pm 2008-07-22 21:27:04 EDT (Tue, 22 Jul 2008) > @@ -67,7 +67,7 @@ > foreach my $section ($ini->Sections()) { > # See if we're supposed to terminate > last > - if (MTT::Util::find_terminate_file()); > + if (MTT::Util::time_to_terminate()); > > if ($section =~ /^\s*mpi get:/) { > # Make the active INI section name known > > Modified: trunk/lib/MTT/MPI/Install.pm > ============================================================================== > --- trunk/lib/MTT/MPI/Install.pm (original) > +++ trunk/lib/MTT/MPI/Install.pm 2008-07-22 21:27:04 EDT (Tue, 22 Jul > 2008) > @@ -152,7 +152,7 @@ > # outtermost and innermost loops (even though we *could* check > # at every loop level); that's good enough. > last > - if (MTT::Util::find_terminate_file()); > + if (MTT::Util::time_to_terminate()); > > if ($section =~ /^\s*mpi install:/) { > Verbose(">> $phase_name [$section]\n"); > @@ -224,7 +224,7 @@ > # check at every loop level); that's good > # enough. > last > - if (MTT::Util::find_terminate_file()); > + if (MTT::Util::time_to_terminate()); > > my $mpi_version = $mpi_get->{$mpi_version_key}; > > > Modified: trunk/lib/MTT/Test/Build.pm > ============================================================================== > --- trunk/lib/MTT/Test/Build.pm (original) > +++ trunk/lib/MTT/Test/Build.pm 2008-07-22 21:27:04 EDT (Tue, 22 Jul > 2008) > @@ -85,7 +85,7 @@ > # outtermost and innermost loops (even though we *could* check > # at every loop level); that's good enough. > last > - if (MTT::Util::find_terminate_file()); > + if (MTT::Util::time_to_terminate()); > > if ($section =~ /^\s*test build:/) { > Verbose(">> $phase_name [$section]\n"); > @@ -152,7 +152,7 @@ > # every loop level); that's good > # enough. > last > - if > (MTT::Util::find_terminate_file()); > + if (MTT::Util::time_to_terminate()); > > my $mpi_install = > $mpi_version->{$mpi_install_key}; > # Only take sucessful MPI installs > > Modified: trunk/lib/MTT/Test/Get.pm > ============================================================================== > --- trunk/lib/MTT/Test/Get.pm (original) > +++ trunk/lib/MTT/Test/Get.pm 2008-07-22 21:27:04 EDT (Tue, 22 Jul 2008) > @@ -47,7 +47,7 @@ > foreach my $section ($ini->Sections()) { > # See if we're supposed to terminate > last > - if (MTT::Util::find_terminate_file()); > + if (MTT::Util::time_to_terminate()); > > if ($section =~ /^\s*test get:/) { > # Make the active INI section name known > > Modified: trunk/lib/MTT/Test/Run.pm > ============================================================================== > --- trunk/lib/MTT/Test/Run.pm (original) > +++ trunk/lib/MTT/Test/Run.pm 2008-07-22 21:27:04 EDT (Tue, 22 Jul 2008) > @@ -78,7 +78,7 @@ > # outtermost and innermost loops (even though we *could* check > # at every loop level); that's good enough. > last > - if (MTT::Util::find_terminate_file()); > + if (MTT::Util::time_to_terminate()); > > if ($section =~ /^\s*test run:/) { > > @@ -130,7 +130,7 @@ > # *could* check at every loop level); > # that's good enough. > last > - if (MTT::Util::find_terminate_file()); > + if (MTT::Util::time_to_terminate()); > > if ($test_build_name eq "all" || > $test_build_key eq $test_build_name) { > > Modified: trunk/lib/MTT/Test/RunEngine.pm > ============================================================================== > --- trunk/lib/MTT/Test/RunEngine.pm (original) > +++ trunk/lib/MTT/Test/RunEngine.pm 2008-07-22 21:27:04 EDT (Tue, 22 Jul > 2008) > @@ -143,7 +143,7 @@ > > # See if we're supposed to terminate. > last > - if (MTT::Util::find_terminate_file()); > + if (MTT::Util::time_to_terminate()); > > last > if (MTT::Util::check_break_threshold( > @@ -183,7 +183,7 @@ > foreach my $this_np (@$all_np) { > # See if we're supposed to terminate. > last > - if (MTT::Util::find_terminate_file()); > + if (MTT::Util::time_to_terminate()); > > $test_results->{$this_np} = > _run_one_np($install_dir, $run, $mpi_details, $this_np, > @@ -247,7 +247,7 @@ > foreach my $e (@$execs) { > # See if we're supposed to terminate. > last > - if (MTT::Util::find_terminate_file()); > + if (MTT::Util::time_to_terminate()); > _run_one_test($install_dir, $run, $mpi_details, $e, $name, > $variant++, $force); > } > > Modified: trunk/lib/MTT/Util.pm > ============================================================================== > --- trunk/lib/MTT/Util.pm (original) > +++ trunk/lib/MTT/Util.pm 2008-07-22 21:27:04 EDT (Tue, 22 Jul 2008) > @@ -29,10 +29,12 @@ > get_array_ref > ); > > +use Cwd; > use MTT::Globals; > use MTT::Messages; > use MTT::Values; > use Data::Dumper; > +use Filesys::DiskFree; > > #-------------------------------------------------------------------------- > > @@ -69,7 +71,8 @@ > > my @_terminate_files; > my @_pause_files; > -sub find_terminate_file { > +my $df_handle; > +sub time_to_terminate { > # If we previously found a terminate file, just return > return 1 > if ($MTT::Globals::Values->{time_to_terminate}); > @@ -90,6 +93,17 @@ > push(@_pause_files, MTT::Values::EvaluateString($f)); > } > } > + > + # Setup min_disk_free to be a number of bytes > + $df_handle = new Filesys::DiskFree; > + if ($MTT::Globals::Values->{min_disk_free} =~ m/([0-9]{1,2})\%/) { > + $df_handle->df(); > + my $val = $1; > + $val /= 100.0; > + $val *= $df_handle->total(cwd()); > + $val = int($val); > + $MTT::Globals::Values->{min_disk_free} = $val; > + } > } > > # Check to see if any of the files exist > @@ -124,7 +138,39 @@ > } > } while ($found == 1); > > - # We didn't find any, so return false > + # Check the disk space remaining > + if ($MTT::Globals::Values->{min_disk_free} > 0) { > + my $c = getcwd(); > + $df_handle->df(); > + if ($df_handle->avail($c) < > + $MTT::Globals::Values->{min_disk_free}) { > + Warning("Disk free is less than minimum (" . > + $df_handle->avail($c) . > + " bytes < $MTT::Globals::Values->{min_disk_free} > bytes)\n"); > + Warning("Waiting for up to > $MTT::Globals::Values->{min_disk_free_wait} minutes to see if the situation > resolves itself\n") > + if ($MTT::Globals::Values->{min_disk_free_wait} > 0); > + > + my $i = 0; > + while ($i < 2 * $MTT::Globals::Values->{min_disk_free_wait}) { > + sleep(30); > + $df_handle->df(); > + if ($df_handle->avail($c) > > + $MTT::Globals::Values->{min_disk_free}) { > + last; > + } > + ++$i; > + } > + # If we reach an hour without more disk, then abort > + if ($i >= 2 * $MTT::Globals::Values->{min_disk_free_wait}) { > + Warning("Still not enough disk space available\n"); > + Warning("Exiting...\n"); > + $MTT::Globals::Values->{time_to_terminate} = 1; > + return 1; > + } > + } > + } > + > + # Ok to keep running; return false > return 0; > } > > > Modified: trunk/samples/ompi-core-template.ini > ============================================================================== > --- trunk/samples/ompi-core-template.ini (original) > +++ trunk/samples/ompi-core-template.ini 2008-07-22 21:27:04 EDT (Tue, > 22 Jul 2008) > @@ -152,6 +152,23 @@ > # in the MTT section. > # funclet_files = /path/to/file1.pm, /path/to/file2.pm > > +# OMPI Core: To ensure that MTT doesn't fill up your disk, you can > +# tell MTT to stop when disk space gets too low. You can specify a > +# raw number of bytes or a percentage of overall disk space. For > +# example (default value is "5%"): > +# > +# min_disk_free = 5% # stop when there's less than 5% disk free > +# min_disk_free = 500000 # stop when there's less than 500,000 bytes free > + > +# OMPI Core: When MTT detects a low-disk situation, it can wait a > +# little while before reporting whatever results it has accumulated > +# and exiting. The min_disk_free_wait field specifies a number of > +# minutes to wait for there to be enough disk space to be free. If > +# there is still not enough disk space at the end of that time, MTT > +# will report accumulated results and quit. > +# > +# min_disk_free_wait = 60 > + > #---------------------------------------------------------------------- > > [Lock] > _______________________________________________ > mtt-svn mailing list > mtt-...@open-mpi.org > http://www.open-mpi.org/mailman/listinfo.cgi/mtt-svn