DBD-Sys
view release on metacpan or search on metacpan
lib/DBD/Sys/Plugin/Unix/Lsof.pm view on Meta::CPAN
Process Group ID of the process opened the file
=head3 uid
User ID
=head3 username
Name of the user who owns the process which has opened the file
=head3 command
executed command (process executable)
=head3 filename
Full qualified path name of the open file
=head3 filetype
File type (VDIR, VREG, ...) of the open file
=head3 inode
Inode number of the open file
=head3 linkcount
Link count of the open file
=head3 mountpoint
Mount point of the file system where the file resides
=head1 METHODS
=head2 get_table_name
Returns 'grent'.
=cut
sub get_table_name() { return 'openfiles'; }
=head2 get_col_names
Returns the column names of the table as named in L</Columns>
=cut
sub get_col_names() { @colNames }
=head2 get_attributes
Return the attributes supported by this module:
=head3 uids
Allows restricting the user ids (see lsof(8) for the C<-u> parameter).
$dbh->{sys_openfiles_uids} = [scalar getpwuid $<];
$dbh->{sys_openfiles_uids} = [$<]; # all opened by myself
=head3 pids
Allows restricting the process ids (see lsof(8) for the C<-p> parameter).
$dbh->{sys_openfiles_pids} = ['^' . $$]; # everything except the current process
=head3 filesys
Allows restricting the scanned file systems (see lsof(8) for the C<+f>
parameter).
$dbh->{sys_openfiles_filesys} = [qw(/usr /var)];
=cut
sub get_attributes() { return qw(uids pids filesys) }
my $havelsof;
my $havesysfsmountpoint;
=head2 collect_data
Retrieves the data from the lsof command and put it into fetchable rows.
=cut
sub collect_data()
{
my $self = $_[0];
my @data;
unless ( defined($havelsof) )
{
$havelsof = 0;
eval {
require Unix::Lsof;
$havelsof = 1;
};
}
unless ( defined($havesysfsmountpoint) )
{
$havesysfsmountpoint = 0;
eval {
require Sys::Filesystem::MountPoint;
$havesysfsmountpoint = 1;
};
}
if ($havelsof)
{
my @args;
if ( $self->{meta}->{uids} )
{
push( @args, '-u' );
push( @args,
ref( $self->{meta}->{uids} ) eq 'ARRAY'
? join( ',', @{ $self->{meta}->{uids} } )
( run in 0.503 second using v1.01-cache-2.11-cpan-39bf76dae61 )