|
PTools::SDF::CMD::BDF - Load '/bin/bdf' output into an PTools::SDF::IDX object |
PTools::SDF::CMD::BDF - Load '/bin/bdf' output into an PTools::SDF::IDX object
This document describes version 0.04, released Apr, 2004.
use PTools::SDF::CMD::BDF;
$bdfObj = new PTools::SDF::CMD::BDF;
or $bdfObj = new PTools::SDF::CMD::BDF(
$fsType, $matchCriteria, @fieldNames
);
After that, the $bdfObj acts just like any PTools::SDF::IDX object.
hostname filesystem kbytes used avail pctused mountedon
Use the FieldNameList parameter to supply alternate names. This is used simply to make client scripts more 'readable' to programmers. Just remember to supply names for all seven fields.
Example:
use PTools::SDF::CMD::BDF;
$bdfObj = new PTools::SDF::CMD::BDF;
or $fsType = "vxfs";
$matchCriteria = "\$mountpoint =~ m#ClearCase/newview/#";
(@fieldNames) = qw( hostname fsdev kbytes used avail pctused mountpoint )
$bdfObj = new PTools::SDF::CMD::BDF( $fsType, $matchCriteria, @fieldNames );
Note that in the above example, any FieldName used in the MatchCriteria field ('mountpoint') must match a name in the FieldNames list. Otherwise no entries will match, and no data will be returned in the resulting object.
A few additional public methods are defined here. See the various parent classes for examples of indexing and accessing the data contained in objects of this class.
$kbytes = $bdfObj->param( $recNum, 'kbytes' ); # fetch total "kbytes"
$mbytes = $bdfObj->k2m( $kbytes );
$gbytes = $bdfObj->k2g( $kbytes );
A Format string can be passed, and this is used in Perl's sprintf function to return a nicely formatted number. For example, to turn the total file system size attribute into a GigaByte fraction to one decimal place use the following.
$gbytes = $bdfObj->k2g( $kbytes, "%0.1f" );
Example:
$matchExp = "\$mountpoint =~ m#ClearCase/newview/#";
if ($ARGV[0] and $ARGV[0] eq "-") {
#
# If arg zero is a dash, read lines of text from
# STDIN, assuming this is output from /bin/bdf
#
$bdfObj = new PTools::SDF::CMD::BDF( "no_bdf" );
while (defined ($line = <STDIN>)) {
$text .= $line;
}
$bdfObj->parseText( $text, $matchExp, @fieldNames );
} else {
#
# Otherwise, any "vxfs" entries that match the expression
#
$bdfObj = new PTools::SDF::CMD::BDF( $fsType, $matchExp, @fieldNames );
}
Note that the above example passes a FSType of 'no_bdf' to the new method. This is used to instantiate an object without running any /bin/bdf process.
If no user-defined ``regular expression'' Pattern(s)`` then we will attempt to pull a $uname from the following default pattern space.
qw( ^/home/(.*)$ ^/nethome/(.*)$ ^/users/(.*)$ );
The various patterns are matched sequentially. The first time a match succeeds the value is returned and any subsequent patterns are not used.
$mount = $bdfObj->param( $recNum, 'mountedon' );
$uname = $bdfObj->parseUname( $mount );
In this example, if $mount equals '/home/janedoe', for example, then $uname will equal janedoe as the default pattern list, shown above, is used here.
This class inherits from the PTools::SDF::ARRAY and PTools::SDF::IDX classes. Additional methods are available via these and other parent classes.
See the PTools::SDF::Overview manpage, the PTools::SDF::ARRAY manpage, the PTools::SDF::CSV manpage, the PTools::SDF::DB manpage, the PTools::SDF::DIR manpage, the PTools::SDF::DSET manpage, the PTools::SDF::File manpage, the PTools::SDF::IDX manpage, the PTools::SDF::INI manpage, the PTools::SDF::SDF manpage, the PTools::SDF::TAG manpage the PTools::SDF::Lock::Advisory manpage, the PTools::SDF::Sort::Bubble manpage, the PTools::SDF::Sort::Quick manpage and the PTools::SDF::Sort::Shell manpage.
Chris Cobb, <nospamplease@ccobb.net>
Copyright (c) 2003-2007 by Chris Cobb. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
|
PTools::SDF::CMD::BDF - Load '/bin/bdf' output into an PTools::SDF::IDX object |