filesys-df's Introduction
INSTALL TO INSTALL RUN: perl Makefile.PL make make test make install During the build process, the makefile will try to figure out which system calls to use to obtain filesystem information. It will look for statvfs() first via the Config module and a include directory search. If it locates statvfs(), it will assume the system also has fstatvfs(). If it cannot find statvfs(), it will then begin the same search for statfs(). If statfs() is found it will assume fstatfs() is also available. During the 'make test', test.pl will try to test with '/' and then open test.pl in the current directory and use that for a filehandle test. Once installed, run 'perldoc Filesys::Df' for more information. If you have any problems or questions please email me at [email protected] with "Filesys::Df" in the subject line. If you run into a build problem, please include the output of the install commands, the version of Perl you are using (perl -v), and what operating system you are using. Module Documentation: This distribution contains the module Filesys::Df Filesys::Df - Perl extension for filesystem disk space information. SYNOPSIS use Filesys::Df; #### Get information by passing a scalar directory/filename value my $ref = df("/tmp"); # Default output is 1K blocks if(defined($ref)) { print "Total 1k blocks: $ref->{blocks}\n"; print "Total 1k blocks free: $ref->{bfree}\n"; print "Total 1k blocks avail to me: $ref->{bavail}\n"; print "Total 1k blocks used: $ref->{used}\n"; print "Percent full: $ref->{per}\n"; if(exists($ref->{files})) { print "Total inodes: $ref->{files}\n"; print "Total inodes free: $ref->{ffree}\n"; print "Inode percent full: $ref->{fper}\n"; } } #### Get information by passing a filehandle open(FILE, "some_file"); # Get information for filesystem at "some_file" my $ref = df(\*FILE); #### or my $ref = df(*FILE); #### or my $fhref = \*FILE; my $ref = df($fhref); #### Get information in other than 1k blocks my $ref = df("/tmp", 8192); # output is 8K blocks my $ref = df("/tmp", 1); # output is bytes DESCRIPTION This module provides a way to obtain filesystem disk space information. This is a Unix only distribution. If you want to gather this information for Unix and Windows, use Filesys::DfPortable. The only major benefit of using Filesys::Df over Filesys::DfPortable, is that Filesys::Df supports the use of open filehandles as arguments. The module should work with all flavors of Unix that implement the statvfs() and fstatvfs() calls, or the statfs() and fstatfs() calls. This would include Linux, *BSD, HP-UX, AIX, Solaris, Mac OS X, Irix, Cygwin, etc ... df() requires a argument that represents the filesystem you want to query. The argument can be either a scalar directory/file name or a open filehandle. There is also an optional block size argument so you can tailor the size of the values returned. The default block size is 1024. This will cause the function to return the values in 1k blocks. If you want bytes, set the block size to 1. df() returns a reference to a hash. The keys available in the hash are as follows: {blocks} = Total blocks on the filesystem. {bfree} = Total blocks free on the filesystem. {bavail} = Total blocks available to the user executing the Perl application. This can be different than bfree if you have per-user quotas on the filesystem, or if the super user has a reserved amount. {bavail} can also be a negative value because of this. For instance if there is more space being used then you have available to you. {used} = Total blocks used on the filesystem. {per} = Percent of disk space used. This is based on the disk space available to the user executing the application. In other words, if the filesystem has 10% of its space reserved for the superuser, then the percent used can go up to 110%. You can obtain inode information through the module as well. But you must call exists() on the {files} key to make sure the information is available: if(exists($ref->{files})) { #### Inode info is available } Some filesystems may not return inode information, for example some NFS filesystems. Here are the available inode keys: {files} = Total inodes on the filesystem. {ffree} = Total inodes free on the filesystem. {favail} = Total inodes available to the user executing the application. See the rules for the {bavail} key. {fused} = Total inodes used on the filesystem. {fper} = Percent of inodes used on the filesystem. See rules for the {per} key. There are some undocumented keys that are defined to maintain backwards compatibility: {su_blocks}, {user_blocks}, etc ... If the df() call fails for any reason, it will return undef. This will probably happen if you do anything crazy like try to get information for /proc, or if you pass an invalid filesystem name, or if there is an internal error. df() will croak() if you pass it a undefined value. Requirements: Your system must contain statvfs() and fstatvfs(), or statfs() and fstatfs() You must be running Perl 5.6 or higher. Copyright (c) 2006 Ian Guthrie. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
filesys-df's People
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.