As of 2006/Aug/29 there appears to be no lsof wrapper module available from CPAN.
Here are two examples of usage of Wrappers::Lsof.
As used by IDM_proc.pm:
my $lsof = Lsof->new(FLAGS => "+M", LOG => $self->{LOG}); my $procs = $lsof->procs(); foreach my $p (keys %$procs) { . . unless ($lsof->proc_attrib(PROC=>$p, ATTRIB=>"UNAME") eq "root") { next; } . .
As used by IDM_net_conns.pm:
my $lsof = Lsof->new(FLAGS => "-i4TCP", LOG => $self->{LOG}); my $procs = $lsof->procs(); foreach my $p (keys %$procs) { foreach my $f (keys %{$lsof->open_files(PROC => $p)}) { my $c = {}; $c->{COMMAND} = $lsof->proc_attrib(PROC=>$p, ATTRIB=>"COMMAND"); $c->{UNAME} = $lsof->proc_attrib(PROC=>$p, ATTRIB=>"UNAME"); $c->{LOCAL_HOST} = $lsof->file_attrib(PROC=>$p, FILE=>$f, ATTRIB=>"LOCAL_HOST"); $c->{LOCAL_PORT} = $lsof->file_attrib(PROC=>$p, FILE=>$f, ATTRIB=>"LOCAL_PORT"); $c->{REMOTE_HOST} = $lsof->file_attrib(PROC=>$p, FILE=>$f, ATTRIB=>"REMOTE_HOST"); . .
Make into a fully-functioning, CPAN-style module.
Thankfully output from lsof seems to be more-or-less platform-independent, so the module should work out-of-the-box on most *nix platforms. More functionality should be trivial to add.
...previous | up (conts) | next... |