|
|
|
@ -11,11 +11,11 @@ Net::Connection - Represents a network connection as a object.
|
|
|
|
|
|
|
|
|
|
=head1 VERSION
|
|
|
|
|
|
|
|
|
|
Version 0.0.0
|
|
|
|
|
Version 0.2.0
|
|
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
|
|
our $VERSION = '0.0.0';
|
|
|
|
|
our $VERSION = '0.2.0';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
=head1 SYNOPSIS
|
|
|
|
@ -129,12 +129,24 @@ This is the PTR address for local_host.
|
|
|
|
|
If ptrs is not true and local_host appears to be
|
|
|
|
|
a hostname, then it is set to the same as local_host.
|
|
|
|
|
|
|
|
|
|
=head2 pctcpu
|
|
|
|
|
|
|
|
|
|
Percent of CPU usage by the PID for this connection.
|
|
|
|
|
|
|
|
|
|
=head2 pctmem
|
|
|
|
|
|
|
|
|
|
Percent of memory usage by the PID for this connection.
|
|
|
|
|
|
|
|
|
|
=head4 pid
|
|
|
|
|
|
|
|
|
|
This is the pid for a connection.
|
|
|
|
|
|
|
|
|
|
If defined, it needs to be numeric.
|
|
|
|
|
|
|
|
|
|
=head4 pid_start
|
|
|
|
|
|
|
|
|
|
The start time in seconds of the PID for the connection.
|
|
|
|
|
|
|
|
|
|
=head4 ports
|
|
|
|
|
|
|
|
|
|
If true, it will attempt to resolve the port names.
|
|
|
|
@ -147,6 +159,10 @@ This needs to be defined, but unfortunately no real checking is done
|
|
|
|
|
as of currently as various OSes uses varrying capitalizations and slightly
|
|
|
|
|
different forms of TCP, TCP4, tcp4, tcpv4, and the like.
|
|
|
|
|
|
|
|
|
|
=head4 proc
|
|
|
|
|
|
|
|
|
|
Either the command line or fname if that is blank for the PID.
|
|
|
|
|
|
|
|
|
|
=head4 ptrs
|
|
|
|
|
|
|
|
|
|
If is true, then attempt to look up the PTRs for the hosts.
|
|
|
|
@ -198,6 +214,10 @@ will attempt to be automatically contemplated.
|
|
|
|
|
If uid_resolve is true and uid is defined, then this
|
|
|
|
|
will attempt to be automatically contemplated.
|
|
|
|
|
|
|
|
|
|
=head4 wchan
|
|
|
|
|
|
|
|
|
|
The current wait channel for the PID of the connection in question.
|
|
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
|
|
sub new{
|
|
|
|
@ -264,6 +284,10 @@ sub new{
|
|
|
|
|
'proto' => $args{'proto'},
|
|
|
|
|
'local_ptr' => undef,
|
|
|
|
|
'foreign_ptr' => undef,
|
|
|
|
|
'pctcpu' => undef,
|
|
|
|
|
'pctmem' => undef,
|
|
|
|
|
'proc' => undef,
|
|
|
|
|
'wchan' => undef,
|
|
|
|
|
};
|
|
|
|
|
bless $self;
|
|
|
|
|
|
|
|
|
@ -289,6 +313,18 @@ sub new{
|
|
|
|
|
if (defined( $args{'username'} )){
|
|
|
|
|
$self->{'username'}=$args{'username'};
|
|
|
|
|
}
|
|
|
|
|
if (defined( $args{'proc'} )){
|
|
|
|
|
$self->{'proc'}=$args{'proc'};
|
|
|
|
|
}
|
|
|
|
|
if (defined( $args{'wchan'} )){
|
|
|
|
|
$self->{'wchan'}=$args{'wchan'};
|
|
|
|
|
}
|
|
|
|
|
if (defined( $args{'pctmem'} )){
|
|
|
|
|
$self->{'pctmem'}=$args{'pctmem'};
|
|
|
|
|
}
|
|
|
|
|
if (defined( $args{'pctcpu'} )){
|
|
|
|
|
$self->{'pctcpu'}=$args{'pctcpu'};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# resolve port names if asked to
|
|
|
|
|
if ( $args{ports} ){
|
|
|
|
@ -299,6 +335,8 @@ sub new{
|
|
|
|
|
if (defined( $service )){
|
|
|
|
|
$self->{'local_port'}=$service;
|
|
|
|
|
}
|
|
|
|
|
}elsif( $self->{'local_port'} =~ /^[0-9]+$/ ){
|
|
|
|
|
$self->{'local_port_name'}=getservbyport( $self->{'local_port'}, 'tcp' );
|
|
|
|
|
}
|
|
|
|
|
if ( $self->{'foreign_port'} =~ /[A-Za-z]/ ){
|
|
|
|
|
$self->{'foreign_port_name'}=$self->{'foreign_port'};
|
|
|
|
@ -306,6 +344,8 @@ sub new{
|
|
|
|
|
if (defined( $service )){
|
|
|
|
|
$self->{'foreign_port'}=$service;
|
|
|
|
|
}
|
|
|
|
|
}elsif( $self->{'foreign_port'} =~ /^[0-9]+$/ ){
|
|
|
|
|
$self->{'foreign_port_name'}=getservbyport( $self->{'foreign_port'}, 'tcp' );
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
# If the port is non-numeric, set it as the port name
|
|
|
|
@ -449,7 +489,7 @@ This returns the PTR for the foreign host.
|
|
|
|
|
If one was not supplied or if it could not be found
|
|
|
|
|
if resolving was enabled then undef will be returned.
|
|
|
|
|
|
|
|
|
|
my $f_ptr=$conn-<foreign_ptr;
|
|
|
|
|
my $f_ptr=$conn->foreign_ptr;
|
|
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
|
@ -496,7 +536,7 @@ sub local_port_name{
|
|
|
|
|
return $_[0]->{'local_port_name'};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
=head2 foreign_ptr
|
|
|
|
|
=head2 local_ptr
|
|
|
|
|
|
|
|
|
|
This returns the PTR for the local host.
|
|
|
|
|
|
|
|
|
@ -511,6 +551,68 @@ sub local_ptr{
|
|
|
|
|
return $_[0]->{'local_ptr'};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
=head2 pctcpu
|
|
|
|
|
|
|
|
|
|
Returns the percent of memory in use by the process
|
|
|
|
|
that has connection.
|
|
|
|
|
|
|
|
|
|
This may not be if it was not set. Please see new
|
|
|
|
|
for more information.
|
|
|
|
|
|
|
|
|
|
my $pctcpu=$conn->pctcpu;
|
|
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
|
|
sub pctcpu{
|
|
|
|
|
return $_[0]->{'pctcpu'};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
=head2 pctmem
|
|
|
|
|
|
|
|
|
|
Returns the percent of memory in use by the process
|
|
|
|
|
that has connection.
|
|
|
|
|
|
|
|
|
|
This may not be if it was not set. Please see new
|
|
|
|
|
for more information.
|
|
|
|
|
|
|
|
|
|
my $pctmem=$conn->pctmem;
|
|
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
|
|
sub pctmem{
|
|
|
|
|
return $_[0]->{'pctmem'};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
=head2 pid
|
|
|
|
|
|
|
|
|
|
This returns the pid of a connection.
|
|
|
|
|
|
|
|
|
|
This may return undef.
|
|
|
|
|
|
|
|
|
|
my $pid=$conn->pid;
|
|
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
|
|
sub pid{
|
|
|
|
|
return $_[0]->{'pid'};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
=head2 proc
|
|
|
|
|
|
|
|
|
|
Returns the command line or fname for the process
|
|
|
|
|
that has the connection.
|
|
|
|
|
|
|
|
|
|
This may not be if it was not set. Please see new
|
|
|
|
|
for more information.
|
|
|
|
|
|
|
|
|
|
my $proc=$conn->proc;
|
|
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
|
|
sub proc{
|
|
|
|
|
return $_[0]->{'proc'};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
=head2 proto
|
|
|
|
|
|
|
|
|
|
Returns the protocol in use by the connection.
|
|
|
|
@ -598,6 +700,21 @@ sub username{
|
|
|
|
|
return $_[0]->{'username'};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
=head2 wchan
|
|
|
|
|
|
|
|
|
|
Returns the wchan for the process that has the connection.
|
|
|
|
|
|
|
|
|
|
This may not be if it was not set. Please see new
|
|
|
|
|
for more information.
|
|
|
|
|
|
|
|
|
|
my $wchan=$conn->wchan;
|
|
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
|
|
sub wchan{
|
|
|
|
|
return $_[0]->{'wchan'};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
=head1 AUTHOR
|
|
|
|
|
|
|
|
|
|
Zane C. Bowers-Hadley, C<< <vvelox at vvelox.net> >>
|
|
|
|
|