dbs has asked for the wisdom of the Perl Monks concerning the following question:
__OUTPUT__use strict; my (@dfary,@stats,$free,$stat); format LOG_TOP = REPORT OF FILESYSTEM USAGE on: @<<<<<<<<<<< my ($host) = qx(hostname) =~ /^([^.]+)/; page @<< $% MBblocks, Free, %Used, Mount, . format LOG = ^* $stat.+"," ~~ . my $DFOUT = new FileHandle "/usr/bin/df -m|" || die "df did not open $ +!"; my $percent = q|30|; while (<$DFOUT>) { next if $. == 1; next if /proc|net/i; for $stat ( (split(" ", $_, 0))[1,2,3,6]) { chomp $stat; ($free) = /(\d+)%/; if ( $free >= $percent ) { write (LOG); #last; #push (@stats, $stat); } else { next; } } } $DFOUT->close; # for (@stats) { # write (LOG); #}
should beREPORT OF FILESYSTEM USAGE on: xxxxxxxx page 1 MBblocks, Free, %Used, Mount, 8512.00, 3232.28, 63%, /usr, 10240.00, 2367.96, 77%, /var, 4096.00, 1923.06, 54%, /tmp,
thankU!MBblocks, Free, %Used, Mount, 8512.00, 3232.28, 63%, /usr, 10240.00,2367.96,77%,/var, etc.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: format 1 line per row
by dbs (Sexton) on Aug 25, 2011 at 18:53 UTC |